|
| 1 | +#===== stuff =====# |
| 2 | + |
| 3 | +t2 = time() |
| 4 | + |
| 5 | +@testset "parsing all the things" begin include("parsing.jl") end |
| 6 | + |
| 7 | +@testset "tests from Einsum.jl" begin include("einsum.jl") end |
| 8 | + |
| 9 | +@info @sprintf("Basic tests took %.1f seconds", time()-t2) |
| 10 | + |
| 11 | +@testset "internal pieces" begin include("utils.jl") end |
| 12 | + |
| 13 | +@testset "matrix multiplication" begin |
| 14 | + # size 200 is big enough to test block_halves even with MINIBLOCK = 64^3 |
| 15 | + @testset "size $N, elements $T" for N in [2, 20, 200], T in [1:99, Float32, Float64, ComplexF64] |
| 16 | + for f in [identity, adjoint] |
| 17 | + A = f(rand(T, N,N)); |
| 18 | + B = f(rand(T, N,N)); |
| 19 | + @test A * B ≈ @tullio C[i,k] := A[i,j] * B[j,k] |
| 20 | + end |
| 21 | + if N < 200 |
| 22 | + X = rand(T, N,N+1); |
| 23 | + Y = rand(T, N+1,N+2); |
| 24 | + Z = rand(T, N+2,N+1); |
| 25 | + @test X * Y * Z ≈ @tullio C[a,d] := X[a,b] * Y[b,c] * Z[c,d] |
| 26 | + end |
| 27 | + end |
| 28 | + @testset "@allocated" begin |
| 29 | + m!(C,A,B) = @tullio C[i,k] = A[i,j] * B[j,k] threads=false |
| 30 | + C1, A1, B1 = rand(4,4), rand(4,4), rand(4,4) |
| 31 | + @allocated m!(C1, A1, B1) |
| 32 | + @test 0 == @allocated m!(C1, A1, B1) |
| 33 | + end |
| 34 | +end |
| 35 | + |
| 36 | +#===== Tracker =====# |
| 37 | + |
| 38 | +t3 = time() |
| 39 | +using Tracker |
| 40 | + |
| 41 | +GRAD = :Tracker |
| 42 | +_gradient(x...) = Tracker.gradient(x...) |
| 43 | + |
| 44 | +@tullio grad=Base |
| 45 | +@testset "gradients: Tracker + DiffRules" begin include("gradients.jl") end |
| 46 | + |
| 47 | +@tullio grad=Dual |
| 48 | +@testset "gradients: Tracker + ForwardDiff" begin include("gradients.jl") end |
| 49 | + |
| 50 | +@info @sprintf("Tracker tests took %.1f seconds", time()-t3) |
0 commit comments