We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MWE:
module MWE using LogExpFunctions: xlogy using FiniteDifferences using Enzyme # function xlogy(x::Number, y::Number) # result = x * log(y) # return iszero(x) && !isnan(y) ? zero(result) : result # end f(x) = xlogy(x[1], 23.0) x = [0.0] finitediff = FiniteDifferences.grad(central_fdm(5, 1), f, x)[1] grad_forward = Enzyme.gradient(Enzyme.Forward, f, x) grad_reverse = Enzyme.gradient(Enzyme.Reverse, f, x) @show finitediff @show grad_forward @show grad_reverse end
Commented out is the actual body of xlogy.
xlogy
Output:
finitediff = [3.1354942159291497] grad_forward = (0.0,) grad_reverse = [0.0]
The iszero(x) throws things off. E.g. ForwardDiff.jl and ReverseDiff.jl deal with this by depending on DiffRules.jl, which defines a rule here: https://github.com/JuliaDiff/DiffRules.jl/blob/8842177391b07dcd8234ac7612b9ca8ca72d28e0/src/rules.jl#L305
iszero(x)
Could Enzyme do the same?
The text was updated successfully, but these errors were encountered:
Completed here: #1615
Sorry, something went wrong.
No branches or pull requests
MWE:
Commented out is the actual body of
xlogy
.Output:
The
iszero(x)
throws things off. E.g. ForwardDiff.jl and ReverseDiff.jl deal with this by depending on DiffRules.jl, which defines a rule here: https://github.com/JuliaDiff/DiffRules.jl/blob/8842177391b07dcd8234ac7612b9ca8ca72d28e0/src/rules.jl#L305Could Enzyme do the same?
The text was updated successfully, but these errors were encountered: