From 93cdee00e7c0834de17ddd1405c4758aabfa215e Mon Sep 17 00:00:00 2001 From: Ryosuke Okuta Date: Thu, 27 Jul 2017 01:27:27 +0900 Subject: [PATCH] Fix contiguous check --- cupy/core/core.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cupy/core/core.pyx b/cupy/core/core.pyx index 276dc8c03d6..4aa5c8eff48 100644 --- a/cupy/core/core.pyx +++ b/cupy/core/core.pyx @@ -1549,10 +1549,13 @@ cdef class ndarray: arr.dtype, self.dtype)) if self.shape != arr.shape: raise ValueError('Shape mismatch') - if not self._c_contiguous: + if self._c_contiguous: + arr = numpy.ascontiguousarray(arr) + elif self._f_contiguous: + arr = numpy.asfortranarray(arr) + else: raise RuntimeError('Cannot set to non-contiguous array') - arr = numpy.ascontiguousarray(arr) ptr = arr.ctypes.get_as_parameter() if stream is None: self.data.copy_from_host(ptr, self.nbytes)