def test_dlpack_conversions(): array = numpy.arange(0, 10, 0.5) reshaped = array.reshape((2, 10, 1)) slice = reshaped[:, 2:5, :] dlpack = ops._dlpack_from_array(slice) result_array = ops._dlpack_to_array(dlpack) print(slice) print(result_array) assert result_array.shape == slice.shape assert numpy.array_equal(result_array, slice)
def dlflip(image): image = ops._dlpack_to_array(image) out = numpy.fliplr(image) out = ops._dlpack_from_array(out) return out