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
it sure would be nice if Unitful played better with CuArrays. for example, currently, one cannot ustrip a CuArray and then assign to it:
julia> using Unitful, CUDA
julia> c = CuArray(zeros(3) * 1u"s")
3-element CuArray{Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}, 1, CUDA.Mem.DeviceBuffer}:
0.0 s
0.0 s
0.0 s
julia> ustrip(c)[1]=1 # innocuous warning about scalar indexing removed for succinctness
1
julia> c
3-element CuArray{Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}, 1, CUDA.Mem.DeviceBuffer}:
0.0 s
0.0 s
0.0 s
however, if i simply add a new method identical to this one but with CuArray, then it works fine:
julia> import Unitful: ustrip
julia> @inline ustrip(A::CuArray{Q}) where {Q <: Quantity} = reinterpret(Unitful.numtype(Q), A)
ustrip (generic function with 16 methods)
julia> ustrip(c)[1]=1
1
julia> c
3-element CuArray{Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}, 1, CUDA.Mem.DeviceBuffer}:
1.0 s
0.0 s
0.0 s
to be all inclusive, i think the right way to go here is just use AbstractArray. then it'll work too for MtlArray, ROCArray, etc.
it sure would be nice if Unitful played better with CuArrays. for example, currently, one cannot
ustrip
aCuArray
and then assign to it:however, if i simply add a new method identical to this one but with
CuArray
, then it works fine:to be all inclusive, i think the right way to go here is just use
AbstractArray
. then it'll work too for MtlArray, ROCArray, etc.Originally posted by @bjarthur in #630 (comment)
The text was updated successfully, but these errors were encountered: