This should be easy, but I haven’t found a way to do it.
I want a function that takes some concrete array type (<: AbstractArray), that might be backed by Array, or CuArray, or ROCArray or whatever, and returns the unparameterised constructor. e.g.
arraytype(::Array{T, N}) -> Array
or
arraytype(::CuArray{T, N}) -> CuArray
I want to do this in a way that doesn’t require knowing, ahead of time, the concrete array types.
Something like:
function arraytype(::A{T, N}) where {T <: Type, N <: Int, A <: AbstractArray}
return A
end
(Which isn’t legal code: TypeError: in Type{...} expression, expected UnionAll, got a value of type TypeVar
)
Is something like this possible?