Skip to content

Commit

Permalink
friendlier error message for gradient failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Abbott committed Dec 19, 2020
1 parent 1d1221d commit f389f2b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/grad/reverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using .ReverseDiff
ReverseDiff.@grad function (ev::Eval)(args...)
Z = ev.fwd(ReverseDiff.value.(args)...)
Z, Δ -> begin
isnothing(ev.rev) && error("no gradient definition here!")
ev.rev===nothing && throw("No gradient definition found! Running `@tullio` with keyword `verbose=true` may print the reason")
ev.rev(ReverseDiff.value(Δ), Z, ReverseDiff.value.(args)...)
end
end
2 changes: 1 addition & 1 deletion src/grad/tracker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using .Tracker
Tracker.@grad function (ev::Eval)(args...)
Z = ev.fwd(Tracker.data.(args)...)
Z, Δ -> begin
isnothing(ev.rev) && error("no gradient definition here!")
ev.rev===nothing && throw("No gradient definition found! Running `@tullio` with keyword `verbose=true` may print the reason")
tuple(ev.rev(Tracker.data(Δ), Z, Tracker.data.(args)...)...)
end
end
2 changes: 1 addition & 1 deletion src/grad/zygote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using .Zygote
Zygote.@adjoint function (ev::Eval)(args...)
Z = ev.fwd(args...)
Z, Δ -> begin
isnothing(ev.rev) && error("no gradient definition here!")
ev.rev===nothing && throw("No gradient definition found! Running `@tullio` with keyword `verbose=true` may print the reason")
tuple(nothing, ev.rev(Δ, Z, args...)...)
end
end
Expand Down

0 comments on commit f389f2b

Please sign in to comment.