Change import order
+import numpy
+
from cupy import core
from cupy.core import fusion
from cupy.core import ndarray
from cupy.cuda import memory
-import numpy
def array(obj, dtype=None, copy=True, order='K', subok=False, ndmin=0):
@@ -48,13 +49,15 @@ def _convert_object_with_cuda_array_interface(a):
desc = a.__cuda_array_interface__
shape = desc['shape']
dtype = numpy.dtype(desc['typestr'])
- nbytes = numpy.prod(shape) * dtype.itemsize
- mem = memory.UnownedMemory(desc['data'][0], nbytes, a)
- memptr = memory.MemoryPointer(mem, 0)
if 'strides' in desc:
strides = desc['strides']
+ # this should be fixed.
+ nbytes = numpy.max(numpy.array(shape) * numpy.array(strides))
else:
strides = None
+ nbytes = numpy.prod(shape) * dtype.itemsize
+ mem = memory.UnownedMemory(desc['data'][0], nbytes, a)
+ memptr = memory.MemoryPointer(mem, 0)
return ndarray(shape, dtype=dtype, memptr=memptr, strides=strides)
