def test_astensor_empty_gpu(): a = cupy.array([], dtype=cupy.float32) t = tensor.astensor(a) assert isinstance(t, torch.Tensor) assert t.device.type == 'cuda' t += 1 numpy.testing.assert_array_equal(a.get(), t.cpu().numpy())
def test_astensor_empty_cpu(): a = numpy.array([], dtype=numpy.float32) t = tensor.astensor(a)
def test_astensor_negative_stride(): a = numpy.array([1, 2, 3]) a = a[::-1] t = tensor.astensor(a) numpy.testing.assert_array_equal(a, t.numpy())
def test_astensor_gpu(): a = cupy.arange(5, dtype=cupy.float32) t = tensor.astensor(a) assert isinstance(t, torch.Tensor) t += 1 numpy.testing.assert_array_equal(a.get(), t.cpu().numpy())
def test_astensor_empty_cpu(): a = numpy.array([], dtype=numpy.float32) t = tensor.astensor(a) assert t.device.type == 'cpu'