fix: mapreduce type stability, VoA broadcast adjoints#325
Merged
Conversation
| @inline Base.sum(VA::AbstractVectorOfArray; kwargs...) = sum(identity, VA; kwargs...) | ||
| @inline function Base.sum(f, VA::AbstractVectorOfArray; kwargs...) | ||
| if hasproperty(kwargs, :dims) | ||
| sum(Array(VA); kwargs...) |
Member
There was a problem hiding this comment.
This can be a potentially big allocation
Member
Author
There was a problem hiding this comment.
That was the default implementation, but I just realized two things:
- that method is probably not necessary
- mapreduce is implemented wrong
|
|
||
| Base.map(f, A::RecursiveArrayTools.AbstractVectorOfArray) = map(f, A.u) | ||
|
|
||
| function Base.mapreduce(f, op, A::AbstractVectorOfArray) |
Member
There was a problem hiding this comment.
probably need to have an init
2a55225 to
1f9b577
Compare
| _minus(Δ) = .-Δ | ||
| _minus(::Nothing) = nothing | ||
|
|
||
| @adjoint function Broadcast.broadcasted(::typeof(-), x::AbstractVectorOfArray, y::Union{AbstractVectorOfArray, Zygote.Numeric}) |
Member
There was a problem hiding this comment.
you're never supposed to define specific broadcasts like this, and I don't think digging into Zygote's broadcast system is the answer. It just relies on the Julia-level broadcast
Member
|
This will need a real fix, but let's at least get downstream tests passing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #323
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.