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

Remove projection rule for VectorOfArray #377

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions ext/RecursiveArrayToolsZygoteExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ end
view(A, I...), view_adjoint
end

function ChainRulesCore.ProjectTo(a::AbstractVectorOfArray)
ChainRulesCore.ProjectTo{VectorOfArray}((sz = size(a)))
end

function (p::ChainRulesCore.ProjectTo{VectorOfArray})(x::Union{
AbstractArray, AbstractVectorOfArray})
if eltype(x) <: Number
arr = reshape(x, p.sz)
return VectorOfArray([arr[:, i] for i in 1:p.sz[end]])
elseif eltype(x) <: AbstractArray
return VectorOfArray(x)
end
end
# function ChainRulesCore.ProjectTo(a::AbstractVectorOfArray)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't comment out code like this. You've done it in a few PRs. Just remove the code if it's to be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do.

# ChainRulesCore.ProjectTo{VectorOfArray}((sz = size(a)))
# end
#
# function (p::ChainRulesCore.ProjectTo{VectorOfArray})(x::Union{
# AbstractArray, AbstractVectorOfArray})
# if eltype(x) <: Number
# arr = reshape(x, p.sz)
# return VectorOfArray([arr[:, i] for i in 1:p.sz[end]])
# elseif eltype(x) <: AbstractArray
# return VectorOfArray(x)
# end
# end
ChrisRackauckas marked this conversation as resolved.
Show resolved Hide resolved

@adjoint function Broadcast.broadcasted(::typeof(+), x::AbstractVectorOfArray,
y::Union{Zygote.Numeric, AbstractVectorOfArray})
Expand Down
Loading