You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some special array types, such as CUDA.CuArray which currently silently fail when writing to disk (e.g., in the case of CuArray, it writes the array meta-data and device pointer to disk which is no longer valid when de-serializing).
One way to fix this is to add extensions to those packages to customize the serialization logic. For example, I opened such a PR here: JuliaGPU/CUDA.jl#2789
However, I am opening this issue to discuss if it may make sense to provide a more general fallback directly in JLD2. Here is what I had in mind:
function JLD2.writeas(t::Type{<:AbstractArray{T, N}}) where {T, N}
ifhasmethod(convert, Tuple{Type{t}, Array{T, N}})
Array{T,N}
else
t
endend
The reason for checking for convertability here rather than doing this for all AbstractArray is that some abstract arrays (such as those from ComponentArrays.jl) may have additional meta-data that does not allow them to be constructed from AbstractArray alone.