mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Remove legacy constructor calls from pytorch codebase. (#54142)
Summary: Follow up from https://github.com/pytorch/pytorch/issues/53889 Related to https://github.com/pytorch/pytorch/issues/47112 Removing every occurrence of the legacy constructor call present in PyTorch at: - _docs_ - _benchmarks_ - _test_ - _caffe2_ - _CONTRIBUTING.md_ Pull Request resolved: https://github.com/pytorch/pytorch/pull/54142 Reviewed By: ngimel Differential Revision: D27699450 Pulled By: mruberry fbshipit-source-id: 530aa3f5746cc8bc1407d5d51b2bbd8075e30546
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fa29a647db
commit
93bf0ae6fc
@ -63,11 +63,11 @@ class TestShapeOps(TestCase):
|
||||
@onlyCPU
|
||||
def test_tolist(self, device):
|
||||
list0D = []
|
||||
tensor0D = torch.Tensor(list0D)
|
||||
tensor0D = torch.tensor(list0D)
|
||||
self.assertEqual(tensor0D.tolist(), list0D)
|
||||
|
||||
table1D = [1, 2, 3]
|
||||
tensor1D = torch.Tensor(table1D)
|
||||
table1D = [1., 2., 3.]
|
||||
tensor1D = torch.tensor(table1D)
|
||||
storage = torch.Storage(table1D)
|
||||
self.assertEqual(tensor1D.tolist(), table1D)
|
||||
self.assertEqual(storage.tolist(), table1D)
|
||||
@ -75,10 +75,10 @@ class TestShapeOps(TestCase):
|
||||
self.assertEqual(storage.tolist(), table1D)
|
||||
|
||||
table2D = [[1, 2], [3, 4]]
|
||||
tensor2D = torch.Tensor(table2D)
|
||||
tensor2D = torch.tensor(table2D)
|
||||
self.assertEqual(tensor2D.tolist(), table2D)
|
||||
|
||||
tensor3D = torch.Tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
|
||||
tensor3D = torch.tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
|
||||
tensorNonContig = tensor3D.select(1, 1)
|
||||
self.assertFalse(tensorNonContig.is_contiguous())
|
||||
self.assertEqual(tensorNonContig.tolist(), [[3, 4], [7, 8]])
|
||||
|
Reference in New Issue
Block a user