Skip to content

Commit 20e8be7

Browse files
committed
Move
1 parent d10ab87 commit 20e8be7

2 files changed

Lines changed: 53 additions & 54 deletions

File tree

DifferentiationInterface/test/Back/Enzyme/hints.jl

Lines changed: 0 additions & 54 deletions
This file was deleted.

DifferentiationInterface/test/Back/Enzyme/test.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,56 @@ end
148148
f_nocontext, AutoEnzyme(; mode=Enzyme.Reverse), rand(10), ConstantOrCache(nothing)
149149
)
150150
end
151+
152+
@testset "Hints" begin
153+
@testset "MutabilityError" begin
154+
f = let
155+
cache = [0.0]
156+
x -> sum(copyto!(cache, x))
157+
end
158+
159+
e = nothing
160+
try
161+
gradient(f, AutoEnzyme(), [1.0])
162+
catch e
163+
end
164+
msg = sprint(showerror, e)
165+
@test occursin("AutoEnzyme", msg)
166+
@test occursin("function_annotation", msg)
167+
@test occursin("ADTypes", msg)
168+
@test occursin("DifferentiationInterface", msg)
169+
end
170+
171+
@testset "RuntimeActivityError" begin
172+
function g(active_var, constant_var, cond)
173+
if cond
174+
return active_var
175+
else
176+
return constant_var
177+
end
178+
end
179+
180+
function h(active_var, constant_var, cond)
181+
return [g(active_var, constant_var, cond), g(active_var, constant_var, cond)]
182+
end
183+
184+
e = nothing
185+
try
186+
pushforward(
187+
h,
188+
AutoEnzyme(; mode=Enzyme.Forward),
189+
[1.0],
190+
([1.0],),
191+
Constant([1.0]),
192+
Constant(true),
193+
)
194+
catch e
195+
end
196+
msg = sprint(showerror, e)
197+
@test occursin("AutoEnzyme", msg)
198+
@test occursin("mode", msg)
199+
@test occursin("set_runtime_activity", msg)
200+
@test occursin("ADTypes", msg)
201+
@test occursin("DifferentiationInterface", msg)
202+
end
203+
end

0 commit comments

Comments
 (0)