JuliaGPU / Adapt.jl

Other
90 stars 24 forks source link

Replace with Flatten.jl #32

Open maleadt opened 3 years ago

maleadt commented 3 years ago

Turns out Flatten.jl has something similar: Flatten.modify(CuArray, obj, Array). Doesn't use rules, instead eagerly tries to reconstruct objects by calling constructure. That doesn't always work of course:

julia> Flatten.modify(CuArray, view(rand(2,2),:,:), Array)
ERROR: MethodError: no method matching SubArray(::CuArray{Float64,2}, ::Tuple{Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}}}, ::Int64, ::Int64)

Furthermore, we currently need the WrappedArray dispatch rules, but once we have Base.AbstractWrappedArray (https://github.com/JuliaLang/julia/pull/31563) we should investigate using this.