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
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
def test_np_to_tensor_bool(self, shape, dtype): array = np.empty(shape, dtype) tensor = array_to_tensor(array) assert tensor.dtype == torch.bool
def test_shape(self, shape, dtype): array = np.empty(shape, dtype) tensor = array_to_tensor(array) assert tensor.shape == array.shape