-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathscale.jl
More file actions
40 lines (38 loc) · 1.96 KB
/
Copy pathscale.jl
File metadata and controls
40 lines (38 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Test, TestExtras
using TensorKit
using TensorOperations
using Enzyme, EnzymeTestUtils
using Random
spacelist = ad_spacelist(fast_tests)
eltypes = (Float64, ComplexF64)
@testset "Enzyme - VectorInterface (scale!)" begin
@timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
atol = default_tol(T)
rtol = default_tol(T)
α = randn(T)
@testset for TC in (Duplicated,)
for Tα in (Active, Const)
C = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
EnzymeTestUtils.test_reverse(scale!, TC, (C, TC), (α, Tα); atol, rtol)
C = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
EnzymeTestUtils.test_reverse(scale!, TC, (C', TC), (α, Tα); atol, rtol)
@testset for TA in (Duplicated,), (fc, fa) in ((identity, identity), (adjoint, adjoint))
C = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
A = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
EnzymeTestUtils.test_reverse(scale!, TC, (fc(C), TC), (fa(A), TA), (α, Tα); atol, rtol)
end
end
for Tα in (Duplicated, Const)
C = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
EnzymeTestUtils.test_forward(scale!, TC, (C, TC), (α, Tα); atol, rtol)
C = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
EnzymeTestUtils.test_forward(scale!, TC, (C', TC), (α, Tα); atol, rtol)
@testset for TA in (Duplicated,), (fc, fa) in ((identity, identity), (adjoint, adjoint))
C = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
A = randn(T, V[1] ⊗ V[2] ← V[3] ⊗ V[4] ⊗ V[5])
EnzymeTestUtils.test_forward(scale!, TC, (fc(C), TC), (fa(A), TA), (α, Tα); atol, rtol)
end
end
end
end
end