ArrayInterface.jl
ArrayInterface.jl copied to clipboard
use StructArrays.jl
Your currently just have
aos_to_soa(x) = x
I feel like it might be worth it to just add a dependancy on StructArrays.jl, which imo should really be a baked in part of Julia's array interface.
Does that work with Tracker?
Hm, no it appears to not work with it at least out of the box:
julia> using Tracker
julia> v = rand(10) |> param
Tracked 10-element Array{Float64,1}:
0.19747042290556305
0.3577805915969372
0.41164333584420354
0.07956973618070462
0.3882813140794923
0.030429901869670095
0.13329838162061325
0.3263069803112133
0.32484677886198
0.37871805455668994
julia> using StructArrays
julia> StructArray(v)
0-element StructArray() with eltype Float64 with indices 1:0
I wonder if we just need to pirate in the right constructor though. I don't really know anything about Tracker.
Alternatively, we could just define the default to be aos_to_soa(x) = StructArray(x) and then use some custom implementation that doesn't use StructArray for Tracker.
I don't have any stakes in this, just a random thought, so feel free to ignore if this isn't the direction you're interested.
Yeah maybe it's a better default than doing nothing. But I'd like to keep this pretty much dependency free. StructArrays seems to leak to some weird data stuff...