Mercurial > repos > public > sbplib_julia
comparison src/LazyTensors/lazy_tensor_operations.jl @ 1356:49d03d1169ef feature/variable_derivatives
Remove code designed to help inference because it seems to have been solved elsewhere
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 08 Feb 2023 21:32:48 +0100 |
parents | 102ebdaf7c11 |
children | 74ceac9c91e4 |
comparison
equal
deleted
inserted
replaced
1355:102ebdaf7c11 | 1356:49d03d1169ef |
---|---|
1 using Sbplib.RegionIndices | |
2 | |
3 """ | 1 """ |
4 TensorApplication{T,R,D} <: LazyArray{T,R} | 2 TensorApplication{T,R,D} <: LazyArray{T,R} |
5 | 3 |
6 Struct for lazy application of a LazyTensor. Created using `*`. | 4 Struct for lazy application of a LazyTensor. Created using `*`. |
7 | 5 |
323 | 321 |
324 function Base.showerror(io::IO, err::RangeSizeMismatch) | 322 function Base.showerror(io::IO, err::RangeSizeMismatch) |
325 print(io, "RangeSizeMismatch: ") | 323 print(io, "RangeSizeMismatch: ") |
326 print(io, "range size $(range_size(err.tm)) of LazyTensor not matching size $(err.sz)") | 324 print(io, "range size $(range_size(err.tm)) of LazyTensor not matching size $(err.sz)") |
327 end | 325 end |
328 | |
329 # TODO: These should probably be removed. From new testing in performance/get_region_type_inference it seems that the problems are solved without these | |
330 function apply_with_region(op, v, boundary_width::Integer, dim_size::Integer, i) | |
331 if 0 < i <= boundary_width | |
332 return LazyTensors.apply(op,v,Index(i,Lower)) | |
333 elseif boundary_width < i <= dim_size-boundary_width | |
334 return LazyTensors.apply(op,v,Index(i,Interior)) | |
335 elseif dim_size-boundary_width < i <= dim_size | |
336 return LazyTensors.apply(op,v,Index(i,Upper)) | |
337 else | |
338 error("Bounds error") # TODO: Make this more standard | |
339 end | |
340 end | |
341 # TBD: Can these methods be merge by having a function as an arguement instead? | |
342 # TODO: Add inference test that show where things break and how this rewrite fixes it. | |
343 function apply_transpose_with_region(op, v, boundary_width::Integer, dim_size::Integer, i) | |
344 if 0 < i <= boundary_width | |
345 return LazyTensors.apply_transpose(op,v,Index(i,Lower)) | |
346 elseif boundary_width < i <= dim_size-boundary_width | |
347 return LazyTensors.apply_transpose(op,v,Index(i,Interior)) | |
348 elseif dim_size-boundary_width < i <= dim_size | |
349 return LazyTensors.apply_transpose(op,v,Index(i,Upper)) | |
350 else | |
351 error("Bounds error") # TODO: Make this more standard | |
352 end | |
353 end |