Skip to content

Commit

Permalink
Use copy
Browse files Browse the repository at this point in the history
  • Loading branch information
okuta committed Jul 14, 2017
1 parent 3289dfc commit e6056b1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cupy/core/core.pyx
Expand Up @@ -439,7 +439,7 @@ cdef class ndarray:
if strides.size() == shape.size():
newarray = self.view()
else:
newarray = ascontiguousarray(self)
newarray = self.copy()
strides = _get_strides_for_nocopy_reshape(newarray, shape)

if shape.size() != strides.size():
Expand Down Expand Up @@ -2621,7 +2621,7 @@ cpdef ndarray _take(ndarray a, indices, li=None, ri=None, ndarray out=None):
if li is not None and ri is not None and li == ri:
a = rollaxis(a, li)
if out is None:
return ascontiguousarray(a[indices])
return a[indices].copy()
else:
if out.dtype != a.dtype:
raise TypeError('Output dtype mismatch')
Expand Down Expand Up @@ -3387,14 +3387,14 @@ cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):
lda = a._shape[0]
return a, trans, lda
if not a._c_contiguous:
a = ascontiguousarray(a)
a = a.copy()
return a, 1 - trans, a._strides[0] // a.itemsize


@cython.profile(False)
cpdef inline tuple _to_cublas_vector(ndarray a, Py_ssize_t rundim):
if a._strides[rundim] < 0:
return ascontiguousarray(a), 1
return a.copy(), 1
else:
return a, a._strides[rundim] // a.itemsize

Expand Down

0 comments on commit e6056b1

Please sign in to comment.