def test_empty_like_reshape_contiguity3_cupy_only(self, dtype, order): a = testing.shaped_arange((2, 3, 4), cupy, dtype) # test strides that are both non-contiguous and non-descending a = a[:, ::2, :].swapaxes(0, 1) b = cupyx.empty_like_pinned(a, order=order, shape=self.shape) b.fill(0) shape = self.shape if not numpy.isscalar(self.shape) else ( self.shape, ) if len(shape) == 1: assert b.flags.c_contiguous assert b.flags.f_contiguous elif order in ['k', 'K', None] and len(shape) == a.ndim: assert not b.flags.c_contiguous assert not b.flags.f_contiguous elif order in ['f', 'F']: assert not b.flags.c_contiguous assert b.flags.f_contiguous else: assert b.flags.c_contiguous assert not b.flags.f_contiguous c = cupyx.zeros_pinned(self.shape) c.fill(0) testing.assert_array_equal(b, c)
def __init__(self, size, dtype): self.size = size self.dtype = dtype self.host = cupyx.zeros_pinned(size, dtype) self.device = cp.zeros(size, dtype)
def test_zeros_like_reshape_cupy_only(self, dtype, order): a = testing.shaped_arange((2, 3, 4), cupy, dtype) b = cupyx.zeros_like_pinned(a, shape=self.shape) c = cupyx.zeros_pinned(self.shape, order=order, dtype=dtype) numpy.testing.assert_array_equal(b, c)
def test_zeros_strides(self, order): a = numpy.zeros((2, 3), dtype='d', order=order) b = cupyx.zeros_pinned((2, 3), dtype='d', order=order) assert b.strides == a.strides