CUDArt.jl icon indicating copy to clipboard operation
CUDArt.jl copied to clipboard

cannot initialize CudaArray with Int32 size

Open denizyuret opened this issue 10 years ago • 1 comments

This took me a while to figure out today, while debugging the new CUSPARSE package:

ERROR: LoadError: MethodError: `convert` has no method matching convert(::Type{CUDArt.CudaArray{T,N}}, ::Type{Int32}, ::Tuple{Int32})
This may have arisen from a call to the constructor CUDArt.CudaArray{T,N}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  CUDArt.CudaArray(::Type{T}, !Matched::Integer...)
  CUDArt.CudaArray(::Type{T}, !Matched::Tuple{Vararg{Int64}})
  call{T}(::Type{T}, ::Any)
  ...

The relevant part from arrays.jl:

CudaArray(T::Type, dims::Integer...) = CudaArray(T, dims)

function CudaArray(T::Type, dims::Dims)

i.e. CudaArray(T,Int32) is happy, but CudaArray(T,(Int32,)) is not. Dims is defined strictly as Int64:

Dims => Tuple{Vararg{Int64}}

Should Dims also be Tuple{Vararg{Integer}} ? Maybe this is a Base problem...

denizyuret avatar Sep 19 '15 20:09 denizyuret

Not a Base problem. We need a second method that takes a tuple input. Good catch!

timholy avatar Sep 19 '15 23:09 timholy