JuliaGPU / Adapt.jl

Other
86 stars 24 forks source link

Adapt data instead of type #15

Closed ngphuoc closed 5 years ago

ngphuoc commented 5 years ago

I'd like to adapt the data to a matching type. I try the following but it doesn't work. It seems Adapt is designed only for type?

using Adapt

struct A
  a
end

x = [[[A(1), A("a")]]]
adapt("to", x)

adapt_storage(to, x::A) = A(to)
adapt("to", x)

Adapt.adapt_structure(to, x::A) = A(to)
adapt("to", x)

output: [[[A(1), A("a")]]]
ngphuoc commented 5 years ago

Just realize my need is not suitable for Adapt!