changeset 2084:51a005910f19 bugfix/lazy_tensors/tensor_sum_inference

Revert to using map and +() instead of sum to help the compiler infer the resulting types
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 02 Mar 2026 13:18:27 +0100
parents 118c09b168f5
children be972af59d06
files src/LazyTensors/lazy_tensor_operations.jl
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Wed Feb 18 21:33:00 2026 +0100
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Mon Mar 02 13:18:27 2026 +0100
@@ -99,15 +99,19 @@
 end
 
 function apply(tmBinOp::TensorSum{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg{Any,R}) where {T,R,D}
-    return sum(tmBinOp.tms) do tm
+    vs = map(tmBinOp.tms) do tm
         apply(tm,v,I...)
     end
+
+    return +(vs...)
 end
 
 function apply_transpose(tmBinOp::TensorSum{T,R,D}, v::AbstractArray{<:Any,D}, I::Vararg{Any,R}) where {T,R,D}
-    return sum(tmBinOp.tms) do tm
+    vs = map(tmBinOp.tms) do tm
         apply_transpose(tm,v,I...)
     end
+
+    return +(vs...)
 end
 
 range_size(tmBinOp::TensorSum) = range_size(tmBinOp.tms[1])