Adapt.jl
Adapt.jl copied to clipboard
CUDA.jl, oneAPI.jl, etc. all provide a `...Device` type, but without a common supertype. Likewise, our GPU packages all provide functionality to get the device that a given array lives on,...
Finally got around to #46 (long since closed but never fixed) Bonus: I noticed that the existing support for `Symmetric` was buggy as it didn't support the `uplo` parameter, i.e.,...
```julia using Zygote, Adapt #v3.3.0 f(x,p) = sum(sin.(adapt(typeof(p),x).* p)) x = [1.5,2.0] function testf(p) f(x,p) end p = [1.5f0,2.0f0] dp1 = Zygote.gradient(testf,p) ERROR: Mutating arrays is not supported ```
From https://github.com/JuliaGPU/CUDA.jl/issues/131#issuecomment-772610843.
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,...
```julia using CuArrays CuArrays.allowscalar(false) cu(reshape(cu(randn(2,2))', 1,4)) # fails at displaying CuArray(reshape(cu(randn(2,2))', 1,4)) # fails at the outermost call to CuArray ``` Details on Julia: ``` julia> versioninfo() Julia Version 1.3.0-rc5.1...
``` julia> view(CuArray([1]), CuArray([1])) 1-element view(::CuArray{Int64,1}, [1]) with eltype Int64: 1 julia> parentindices(ans) ([1],) julia> typeof(ans) Tuple{CuArray{Int64,1}} ``` The indices needs an adapt as well: ``` Adapt.adapt_structure(to, A::SubArray{
why we have this ```julia adapt_(T, x) = x ``` instead of ```julia adapt_(T, x) = convert(T, x) ``` so that `adapt` could be used as an opt-out replacement to...
Reverted due to CUDA.jl breakage: https://github.com/JuliaGPU/Adapt.jl/pull/70#issue-1964143921
See #52 (closed to experiment with those concepts outside of Adapt/ArrayInterfaceCore for a while before proposing a new common scheme for computing units/devices). Exploring this within [HeterogeneousComputing.jl](https://github.com/oschulz/HeterogeneousComputing.jl) , this issue...