Skip to content

Commit

Permalink
device agnostic convert
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed May 14, 2024
1 parent 3957332 commit 9bf6c85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RecursiveArrayTools"
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
authors = ["Chris Rackauckas <[email protected]>"]
version = "3.16.0"
version = "3.16.1"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
6 changes: 6 additions & 0 deletions src/vector_of_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ function Base.Array{U}(VA::AbstractVectorOfArray) where {U}
vecs = vec.(VA.u)
Array(reshape(reduce(hcat, vecs), size(VA.u[1])..., length(VA.u)))
end

function Base.convert(::Type{AbstractArray}, VA::AbstractVectorOfArray)
vecs = vec.(VA.u)
return reshape(stack(vecs), size(VA.u[1])..., length(VA.u))
end

function Adapt.adapt_structure(to, VA::AbstractVectorOfArray)
Adapt.adapt(to, Array(VA))
end
Expand Down

0 comments on commit 9bf6c85

Please sign in to comment.