|
|
@@ -600,50 +600,58 @@ def test_others_tensor(): |
|
|
|
tensor = pytorch.ByteTensor() |
|
|
|
tensor = pytorch.ByteTensor(3, 5) |
|
|
|
assert tensor.shape == (3, 5) |
|
|
|
assert tensor.dtype == ms.uint8 |
|
|
|
assert tensor.dtype == pytorch.uint8 |
|
|
|
tensor = pytorch.ByteTensor([1, 2, 3]) |
|
|
|
assert tensor.shape == (3,) |
|
|
|
assert tensor.dtype == ms.uint8 |
|
|
|
assert tensor.dtype == pytorch.uint8 |
|
|
|
|
|
|
|
tensor = pytorch.CharTensor() |
|
|
|
tensor = pytorch.CharTensor(3, 5) |
|
|
|
assert tensor.shape == (3, 5) |
|
|
|
assert tensor.dtype == ms.int8 |
|
|
|
assert tensor.dtype == pytorch.int8 |
|
|
|
tensor = pytorch.CharTensor([1, 2, 3]) |
|
|
|
assert tensor.shape == (3,) |
|
|
|
assert tensor.dtype == ms.int8 |
|
|
|
assert tensor.dtype == pytorch.int8 |
|
|
|
|
|
|
|
tensor = pytorch.ShortTensor() |
|
|
|
tensor = pytorch.ShortTensor(3, 5) |
|
|
|
assert tensor.shape == (3, 5) |
|
|
|
assert tensor.dtype == pytorch.int16 |
|
|
|
tensor = pytorch.ShortTensor([1, 2, 3]) |
|
|
|
assert tensor.shape == (3,) |
|
|
|
assert tensor.dtype == pytorch.int16 |
|
|
|
|
|
|
|
|
tensor = pytorch.IntTensor() |
|
|
|
tensor = pytorch.IntTensor(3, 5) |
|
|
|
assert tensor.shape == (3, 5) |
|
|
|
assert tensor.dtype == ms.int32 |
|
|
|
assert tensor.dtype == pytorch.int32 |
|
|
|
tensor = pytorch.IntTensor([1, 2, 3]) |
|
|
|
assert tensor.shape == (3,) |
|
|
|
assert tensor.dtype == ms.int32 |
|
|
|
assert tensor.dtype == pytorch.int32 |
|
|
|
|
|
|
|
tensor = pytorch.HalfTensor() |
|
|
|
tensor = pytorch.HalfTensor(3, 5) |
|
|
|
assert tensor.shape == (3, 5) |
|
|
|
assert tensor.dtype == ms.float16 |
|
|
|
assert tensor.dtype == pytorch.float16 |
|
|
|
tensor = pytorch.HalfTensor([1, 2, 3]) |
|
|
|
assert tensor.shape == (3,) |
|
|
|
assert tensor.dtype == ms.float16 |
|
|
|
assert tensor.dtype == pytorch.float16 |
|
|
|
|
|
|
|
tensor = pytorch.FloatTensor() |
|
|
|
tensor = pytorch.FloatTensor(3, 5) |
|
|
|
assert tensor.shape == (3, 5) |
|
|
|
assert tensor.dtype == ms.float32 |
|
|
|
assert tensor.dtype == pytorch.float32 |
|
|
|
tensor = pytorch.FloatTensor([1, 2, 3]) |
|
|
|
assert tensor.shape == (3,) |
|
|
|
assert tensor.dtype == ms.float32 |
|
|
|
assert tensor.dtype == pytorch.float32 |
|
|
|
|
|
|
|
tensor = pytorch.DoubleTensor() |
|
|
|
tensor = pytorch.DoubleTensor(3, 5) |
|
|
|
assert tensor.shape == (3, 5) |
|
|
|
assert tensor.dtype == ms.float64 |
|
|
|
assert tensor.dtype == pytorch.float64 |
|
|
|
tensor = pytorch.DoubleTensor([1, 2, 3]) |
|
|
|
assert tensor.shape == (3,) |
|
|
|
assert tensor.dtype == ms.float64 |
|
|
|
assert tensor.dtype == pytorch.float64 |
|
|
|
|
|
|
|
def test_is_floating_point(): |
|
|
|
x = [1, 2, -1, 2, 0, -3.5] |
|
|
|
done