Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions ext/RecursiveArrayToolsZygoteExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ end

function (p::ChainRulesCore.ProjectTo{VectorOfArray})(x::Union{
AbstractArray, AbstractVectorOfArray})
arr = reshape(x, p.sz)
return VectorOfArray([arr[:, i] for i in 1:p.sz[end]])
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

@adjoint function Broadcast.broadcasted(::typeof(+), x::AbstractVectorOfArray,
Expand Down
6 changes: 6 additions & 0 deletions test/downstream/symbol_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ sol_new = DiffEqArray(sol.u[1:10],
@test_throws Exception sol[τ]
@test_throws Exception sol_new[τ]

gs, = Zygote.gradient(sol) do sol
sum(sol[fol_separate.x])
end

@test "Symbolic Indexing ADjoint" all(all.(isone, gs.u))

# Tables interface
test_tables_interface(sol_new, [:timestamp, Symbol("x(t)")], hcat(sol_new[t], sol_new[x]))

Expand Down