changeset 1297:c33d0d837b4a performance/lazy_tensors

Merge with default
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 05 Oct 2022 20:27:59 +0200
parents 97dfca9ec054 (diff) 5f701e795d44 (current diff)
children b469f4d20a8f
files
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Tue Oct 04 22:28:08 2022 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Wed Oct 05 20:27:59 2022 +0200
@@ -91,11 +91,11 @@
 domain_size(tm::TensorComposition) = domain_size(tm.t2)
 
 function apply(c::TensorComposition{T,R,K,D}, v::AbstractArray{<:Any,D}, I::Vararg{Any,R}) where {T,R,K,D}
-    apply(c.t1, c.t2*v, I...)
+    apply(c.t1, @inline c.t2*v, I...)
 end
 
 function apply_transpose(c::TensorComposition{T,R,K,D}, v::AbstractArray{<:Any,R}, I::Vararg{Any,D}) where {T,R,K,D}
-    apply_transpose(c.t2, c.t1'*v, I...)
+    apply_transpose(c.t2, @inline c.t1'*v, I...)
 end
 
 """
--- a/test/LazyTensors/lazy_tensor_operations_test.jl	Tue Oct 04 22:28:08 2022 +0200
+++ b/test/LazyTensors/lazy_tensor_operations_test.jl	Wed Oct 05 20:27:59 2022 +0200
@@ -189,6 +189,16 @@
     @test range_size(a*Ã) == range_size(Ã)
     @test domain_size(a*Ã) == domain_size(Ã)
     @test a*Ã*v == a.*A*v
+
+    @testset "Inference of application" begin
+        tm = Ã∘B̃
+        v = rand(4)
+
+        @inferred apply(tm,v,1)
+        @inferred apply(tm,v,2)
+        @inferred (tm*v)[1]
+        @inferred (tm*v)[2]
+    end
 end