File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,11 @@ ArrayInterface.can_setindex(::Type{<:Tracker.TrackedArray}) = false
9
9
ArrayInterface. fast_scalar_indexing (:: Type{<:Tracker.TrackedArray} ) = false
10
10
ArrayInterface. aos_to_soa (x:: AbstractArray{<:Tracker.TrackedReal,N} ) where {N} = Tracker. collect (x)
11
11
12
+ function ArrayInterface. restructure (x:: Array , y:: TrackedArray )
13
+ reshape (y, Base. size (x)... )
14
+ end
15
+ function ArrayInterface. restructure (x:: Array , y:: Array{<:Tracker.TrackedReal} )
16
+ reshape (y, Base. size (x)... )
17
+ end
18
+
12
19
end # module
Original file line number Diff line number Diff line change @@ -18,3 +18,12 @@ x = Tracker.TrackedArray([4.0,4.0])
18
18
x = reduce (vcat, Tracker. TrackedArray ([4.0 ,4.0 ]))
19
19
x = [x[1 ],x[2 ]]
20
20
@test ArrayInterface. aos_to_soa (x) isa Tracker. TrackedArray
21
+
22
+ x = rand (4 )
23
+ y = Tracker. TrackedReal .(rand (2 ,2 ))
24
+ @test ArrayInterface. restructure (x, y) isa Array
25
+ @test eltype (ArrayInterface. restructure (x, y)) <: Tracker.TrackedReal
26
+ @test size (ArrayInterface. restructure (x, y)) == (4 ,)
27
+ y = Tracker. TrackedArray (rand (2 ,2 ))
28
+ @test ArrayInterface. restructure (x, y) isa Tracker. TrackedArray
29
+ @test size (ArrayInterface. restructure (x, y)) == (4 ,)
You can’t perform that action at this time.
0 commit comments