Exemple #1
0
 def test_np_to_tensor_float(self, shape, np_dtype, torch_dtype):
     array = np.empty(shape, np_dtype)
     tensor = array_to_tensor(array, dtype=torch_dtype)
     if torch_dtype is None:
         assert tensor.dtype == torch.float32
     else:
         assert tensor.dtype == torch_dtype
Exemple #2
0
 def test_np_to_tensor_int(self, shape, dtypes):
     np_dtype, torch_dtype = dtypes
     array = np.empty(shape, np_dtype)
     tensor = array_to_tensor(array, dtype=torch_dtype)
     if torch_dtype is None:
         assert tensor.dtype == torch.int64
     else:
         assert tensor.dtype == torch_dtype
Exemple #3
0
 def test_np_to_tensor_bool(self, shape, dtype):
     array = np.empty(shape, dtype)
     tensor = array_to_tensor(array)
     assert tensor.dtype == torch.bool
Exemple #4
0
 def test_shape(self, shape, dtype):
     array = np.empty(shape, dtype)
     tensor = array_to_tensor(array)
     assert tensor.shape == array.shape