def ascontiguousarray(shp, dtype, offseted_o, offseted_i, sliced, order): cpu, gpu = gen_gpuarray(shp, dtype, offseted_o, offseted_i, sliced, order, ctx=ctx) a = numpy.ascontiguousarray(cpu) b = pygpu.ascontiguousarray(gpu) # numpy upcast with a view to 1d scalar. if (sliced != 1 or shp == () or (offseted_i and len(shp) > 1)): assert b is not gpu if sliced == 1 and not offseted_i: assert (a.data is cpu.data) == (b.bytes is gpu.bytes) else: assert b is gpu assert a.shape == b.shape assert a.dtype == b.dtype assert a.flags.c_contiguous assert b.flags['C_CONTIGUOUS'] assert a.strides == b.strides assert numpy.allclose(cpu, a) assert numpy.allclose(cpu, b)
def ascontiguousarray(shp, dtype, offseted_o, offseted_i, sliced, order): cpu, gpu = gen_gpuarray(shp, dtype, offseted_o, offseted_i, sliced, order, ctx=ctx) a = numpy.ascontiguousarray(cpu) b = pygpu.ascontiguousarray(gpu) # numpy upcast with a view to 1d scalar. if sliced != 1 or shp == () or (offseted_i and len(shp) > 1): assert b is not gpu if sliced == 1 and not offseted_i: assert (a.data is cpu.data) == (b.bytes is gpu.bytes) else: assert b is gpu assert a.shape == b.shape assert a.dtype == b.dtype assert a.flags.c_contiguous assert b.flags["C_CONTIGUOUS"] assert a.strides == b.strides assert numpy.allclose(cpu, a) assert numpy.allclose(cpu, b)