Use handwritten rules for zero and one#773
Conversation
|
Appears to have the same failure profile as #774. @oxinabox any thoughts on what we should do? If there's problems in NeuralPDE, there's probably also issues in other parts of the ecosystem. Here's a demo of these methods fixing the problem that NeuralPDE had: SciML/NeuralPDE.jl#792 |
|
Why is this not: function frule((_, _), ::typeof(zero), x)
return (zero(x), ZeroTangent())
end
function rrule(::typeof(zero), x)
zero_pullback(_) = (NoTangent(), ZeroTangent())
return (zero(x), zero_pullback)
end
# `one`
function frule((_, _), ::typeof(one), x)
return (one(x), ZeroTangent())
end
function rrule(::typeof(one), x)
one_pullback(_) = (NoTangent(), ZeroTangent())
return (one(x), one_pullback)
endThis extra stuff with projection and multiplication all should just cancel away for if the tangent is I agree the We should probably add a test for this since it has caused bugs now. Thank you for playing wack-a-mole with this. |
Mostly because I was copy-pasting and then tweaking the output from
can do |
|
test failures on 1.x are unrelated. |
Attempt to fix the problems raised in SciML/NeuralPDE.jl#791 that was caused by #770
I think this is the right way to generalize the scalar rule to any input type, and always return a
ZeroTangent()instead of aNoTangent()like the old@non_differentiablerule did which was quite mathematically suspect.