From 8ec26b56c6e898d9b8564bfc45ccd48bcada4fa6 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sat, 13 Mar 2021 11:24:21 -0500 Subject: [PATCH 1/2] mark all shifted indices unsafe for gradients --- src/macro.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/macro.jl b/src/macro.jl index 1e47a1a..c68c976 100644 --- a/src/macro.jl +++ b/src/macro.jl @@ -310,6 +310,7 @@ function parse_input(expr, store) unique!(store.leftind) store.sharedind = unique!(setdiff(store.sharedind, store.notfree)) store.rightind = unique!(setdiff(store.rightind, store.notfree)) + union!(store.unsaferight, store.shiftedind) any(==(:_), vcat(store.leftind, store.rightind)) && throw("can't use _ as an index name") unique!(store.outpre) # kill mutiple assertions, and evaluate any f(A) only once From 1d7d1504c247f43eedb02fe8ff0fe0e23e15900a Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Sat, 13 Mar 2021 11:47:24 -0500 Subject: [PATCH 2/2] re-enable one cuda test --- test/cuda.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cuda.jl b/test/cuda.jl index a8f516d..80bd0dc 100644 --- a/test/cuda.jl +++ b/test/cuda.jl @@ -2,7 +2,7 @@ using Tullio, Test using CUDA, KernelAbstractions CUDA.allowscalar(false) -using Tracker +using Tracker, ForwardDiff @tullio grad=Base # matmul @@ -17,7 +17,6 @@ A = rand(3,40); B = rand(40,500); @test ΔA ≈ ones(3,500) * B' @test cu(ΔA) ≈ Tracker.gradient((A,B) -> sum(mul(A, B)), cu(A), cu(B))[1] -#= # shifts @tullio D[i,j] := A[i,j+k] k in 0:10 @test axes(D) == (1:3, 1:30) @@ -25,6 +24,7 @@ A = rand(3,40); B = rand(40,500); @test cD isa CuArray @test cD ≈ cu(D) +#= # ranges @tullio E[i,j] := A[i,j+k-1] + (-1:0.5:1)[k] @test axes(E) == (1:3, 1:36)