Skip to content

Commit efbdb0e

Browse files
author
Michael Abbott
committed
friendlier error message for gradient failure
1 parent 3e45c31 commit efbdb0e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/grad/reverse.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using .ReverseDiff
88
ReverseDiff.@grad function (ev::Eval)(args...)
99
Z = ev.fwd(ReverseDiff.value.(args)...)
1010
Z, Δ -> begin
11-
isnothing(ev.rev) && error("no gradient definition here!")
11+
ev.rev===nothing && throw("No gradient definition found! Running `@tullio` with keyword `verbose=true` may print the reason")
1212
ev.rev(ReverseDiff.value(Δ), Z, ReverseDiff.value.(args)...)
1313
end
1414
end

src/grad/tracker.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using .Tracker
88
Tracker.@grad function (ev::Eval)(args...)
99
Z = ev.fwd(Tracker.data.(args)...)
1010
Z, Δ -> begin
11-
isnothing(ev.rev) && error("no gradient definition here!")
11+
ev.rev===nothing && throw("No gradient definition found! Running `@tullio` with keyword `verbose=true` may print the reason")
1212
tuple(ev.rev(Tracker.data(Δ), Z, Tracker.data.(args)...)...)
1313
end
1414
end

src/grad/zygote.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using .Zygote
44
Zygote.@adjoint function (ev::Eval)(args...)
55
Z = ev.fwd(args...)
66
Z, Δ -> begin
7-
isnothing(ev.rev) && error("no gradient definition here!")
7+
ev.rev===nothing && throw("No gradient definition found! Running `@tullio` with keyword `verbose=true` may print the reason")
88
tuple(nothing, ev.rev(Δ, Z, args...)...)
99
end
1010
end

0 commit comments

Comments
 (0)