mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix tensor creation with empty names crash (#163957)
Partially fixes #148324 Pull Request resolved: https://github.com/pytorch/pytorch/pull/163957 Approved by: https://github.com/malfet, https://github.com/janeyx99
This commit is contained in:
committed by
PyTorch MergeBot
parent
9534c59311
commit
d7491fb1c1
@ -280,6 +280,11 @@ class TestNamedTensor(TestCase):
|
||||
self.assertEqual(named_tensor.diagonal(outdim='E', dim1='B', dim2='D').names,
|
||||
['A', 'C', 'E'])
|
||||
|
||||
def test_empty_names(self):
|
||||
ref_tensor = torch.tensor([[1, 2, 3, 4], [4, 3, 2, 1]])
|
||||
empty_named_tensor = torch.tensor([[1, 2, 3, 4], [4, 3, 2, 1]], names=[])
|
||||
self.assertEqual(ref_tensor, empty_named_tensor)
|
||||
|
||||
def test_max_pooling(self):
|
||||
def check_tuple_return(op, inputs, expected_names):
|
||||
values, indices = op(*inputs)
|
||||
|
||||
Reference in New Issue
Block a user