Exemplo n.º 1
0
 def test_enable_python_mode_unrelated_tensors(self) -> None:
     x = torch.randn([])
     y = torch.randn([])
     with enable_python_mode(LoggingTensor):
         z = x + y
         self.assertTrue(isinstance(z, LoggingTensor))
Exemplo n.º 2
0
 def test_nested_enable_python_mode(self) -> None:
     with self.assertRaisesRegex(RuntimeError, "has already been set"):
         with enable_python_mode(LoggingTensor):
             with enable_python_mode(LoggingTensor):
                 pass
Exemplo n.º 3
0
 def test_enable_python_mode_basic(self) -> None:
     with enable_python_mode(LoggingTensor):
         z = torch.empty([])
         self.assertTrue(isinstance(z, LoggingTensor))
Exemplo n.º 4
0
 def test_storage_can_be_converted_to_python_object(self):
     with enable_python_mode(LoggingTensor):
         s = torch.Storage()
         z = LoggingTensor(torch.empty([]))
         z.set_(s)