Skip to content
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

Allow pullback through 0-length arrays in unbroadcast #1530

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

BioTurboNick
Copy link
Contributor

I'm having trouble boiling down a MWE, because it seems to depend on other factors? But it is related to executing the pullback through a form like this:

@views foo.(eachrow(μs)[mask], eachrow(σs)[mask], permutedims(eachcol(x)[xmask]))

unbroadcast only compares lengths of the inputs, but arrays with a 0-length dimension will naturally have the same length. In this PR, NoTangent() is returned if a zero-length array is recieved.

Test for the transform added, but unfortunately without an MWE can't test the broadcast directly.

ERROR: DimensionMismatch: dimensions must match: a has dims (Base.OneTo(1600), Base.OneTo(0)), b has dims (Base.OneTo(1), Base.OneTo(0)), mismatch at 1
Stacktrace:
  [1] promote_shape
    @ .\indices.jl:178 [inlined]
  [2] _promote_tuple_shape
    @ .\iterators.jl:394 [inlined]
  [3] axes
    @ .\iterators.jl:391 [inlined]
  [4] axes
    @ .\generator.jl:52 [inlined]
  [5] _similar_shape
    @ .\array.jl:711 [inlined]
  [6] collect(itr::Base.Generator{Base.Iterators.Zip{Tuple{…}}, Base.var"#4#5"{typeof(Zygote.z2d)}})
    @ Base .\array.jl:833
  [7] map
    @ .\abstractarray.jl:3409 [inlined]
  [8] z2d
    @ 
  [9] zygote2differential
    @ C:\Users\nicho\.julia\packages\Zygote\Tt5Gx\src\compiler\chainrules.jl:275 [inlined]
 [10] _project
    @ 
 [11] unbroadcast(x::Base.ReshapedArray{SubArray{…}, 2, SubArray{…}, Tuple{}}, x̄::Matrix{Any})
    @

@BioTurboNick BioTurboNick changed the title Allow pullback through 0-length arrays Allow pullback through 0-length arrays in unbroadcast Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant