Open mtfishman opened 3 weeks ago
I'm not sure that's so valuable. Why don't you just call adapt(MtlArray{eltype(x),ndims(x),Managed}, x)
? The MtlArray
-based adaptor shouldn't ever change the eltype
.
The application is that I want to adapt a nested data structure that stores a number of GPU arrays where the GPU arrays can have different numbers of dimensions (say schematically of type Vector{Union{MtlArray{Float32,1},MtlArray{Float32,2}}}
), so it isn't straightforward/possible to choose the number of dimensions ahead of time. Same thing with the element type, the GPU arrays could have different element types, i.e. Vector{Union{MtlArray{Float32,1},MtlArray{Complex{Float32},2}}}
.
This could of course be done with custom adapters, but I prefer to not need to define my own adapters if it can be avoided and also give users options that "just work" that are directly from the GPU ecosystem so we don't have to support our own custom GPU functionality/interfaces.
For example:
I think there is the same issue in other GPU backends.