-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
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
Array getindex
rule unable to handle Zero types and NotImplemented
#697
Comments
Yes, this should be handled in the AD system before it calls pullback. |
If I'm not mistaken it'd have to be handled in |
Oh it is arrays containing Zeros/NotImplemented? |
Collapsing arrays of Zeros seems reasonable. Is there a rule for what happens when that array contains both |
Technically speaking we should keep them seperate. |
I can't make a MWE for this, that isn't purely zeros (which should be removed before hitting the rrule) E.g. following works _, back3 = rrule(getindex, [10, 0, -1], :)
gs3 = back3([2.0, NoTangent(), (@not_implemented "test2")])
num, notan, not_imp = unthunk(gs3[2])
@test num isa Real
@test iszero(notan) # We don't care if this gets converted to a 0.0
@test not_imp isa NotImplemented |
I will try to get back to this and the PR which spawned it this weekend. IIRC doing some types of collapsing made certain Zygote tests very unhappy. |
I've been revisiting FluxML/Zygote.jl#1328 as part of a larger PR, and discovered this behaviour while running https://github.com/FluxML/Zygote.jl/blob/108e5a19d8fa7187f6eaece7a142c48d71dfd0d2/test/chainrules.jl#L275.
MWE:
The lines at fault are
ChainRules.jl/src/rulesets/Base/indexing.jl
Lines 104 to 105 in 4ee4ef5
x
's eltype in the final array would be beneficial, but I'm not familiar enough with all the edge cases to be sure. Maybe the correct solution is to catch this at a higher level.The text was updated successfully, but these errors were encountered: