Reduce other unnecessary array copies
@@ -514,15 +514,17 @@ cpdef scan_core(ndarray a, axis, scan_op op, dtype=None, ndarray out=None):
else:
if (out.flags.c_contiguous or out.flags.f_contiguous):
result = out
- else:
- result = a.astype(out.dtype)
result[...] = a
+ else:
+ result = a.astype(out.dtype, copy=True, order='C',
+ casting=None, subok=None)
if axis is None:
for accelerator in _accelerator._routine_accelerators:
if accelerator == _accelerator.ACCELERATOR_CUB:
if result is None:
- result = a.astype(dtype=dtype).ravel()
+ result = a.astype(dtype, copy=False, order='C',
+ casting=None, subok=None).ravel()
# result will be None if the scan is not compatible with CUB
if op == scan_op.SCAN_SUM:
cub_op = cub.CUPY_CUB_CUMSUM
@@ -538,7 +540,8 @@ cpdef scan_core(ndarray a, axis, scan_op op, dtype=None, ndarray out=None):
scan(result, op, dtype=dtype, out=result)
else:
if result is None:
- result = a.astype(dtype=dtype)
+ result = a.astype(dtype, copy=False, order='C',
+ casting=None, subok=None)
axis = internal._normalize_axis_index(axis, a.ndim)
result = _proc_as_batch(result, axis, dtype, op)
# This is for when the original out param was not contiguous
