If a torch.* returns non-Tensor, make this unimplemented rather than assert. (#89918)

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/89918
Approved by: https://github.com/albanD
This commit is contained in:
Edward Z. Yang
2022-12-16 05:46:27 +08:00
committed by PyTorch MergeBot
parent a66af1feba
commit e686a442b4
9 changed files with 17 additions and 3 deletions

View File

@ -246,6 +246,7 @@ class SparseQuantizedModel(nn.Module):
class TestQuantizedSparseLayers(TestCase):
@override_qengines
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_sparse_qlinear(self):
# Note: At the moment, for sparse kernels
# fbgemm supports only static quantized sparse linear
@ -278,6 +279,7 @@ class TestQuantizedSparseLayers(TestCase):
)
@override_qengines
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_sparse_qlinear_serdes(self):
# Note: At the moment, for sparse kernels
# fbgemm supports only static quantized sparse linear

View File

@ -2552,6 +2552,7 @@ class TestScriptList(JitTestCase):
with self.assertRaises(TypeError):
script_data.append("str")
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_clear(self):
"""
Test clear.

View File

@ -8,7 +8,7 @@ from typing import Union
import unittest
import torch.testing._internal.common_utils as common
from torch.testing._internal.common_utils import IS_WINDOWS
from torch.testing._internal.common_utils import IS_WINDOWS, skipIfTorchDynamo
from torch.testing._internal.common_cuda import TEST_CUDA
import torch
import torch.backends.cudnn
@ -295,6 +295,7 @@ class TestRNGExtension(common.TestCase):
def setUp(self):
super(TestRNGExtension, self).setUp()
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_rng(self):
fourty_two = torch.full((10,), 42, dtype=torch.int64)

View File

@ -1,6 +1,6 @@
# Owner(s): ["module: meta tensors"]
from torch.testing._internal.common_utils import TestCase, run_tests, skipIfCrossRef, skipIfRocm
from torch.testing._internal.common_utils import TestCase, run_tests, skipIfCrossRef, skipIfRocm, skipIfTorchDynamo
import torch
import torch._dynamo
import itertools
@ -557,6 +557,7 @@ class FakeTensorConverterTest(TestCase):
y_conv = converter(mode, y)
self.assertEqual(torch._C._storage_id(x_conv), torch._C._storage_id(y_conv))
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_separate_tensor_storages_non_view(self):
x = torch.rand(2, 2, 2)
y = torch.rand(4, 2)
@ -577,6 +578,7 @@ class FakeTensorConverterTest(TestCase):
self.assertEqual(len(converter.meta_converter.storage_memo), 0)
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_dead_weak_ref(self):
x = torch.rand(2, 2, 2)
y = x[0]
@ -589,6 +591,7 @@ class FakeTensorConverterTest(TestCase):
y_conv = converter(mode, y)
self.assertEqual(x_conv_storage, torch._C._storage_id(y_conv))
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_dead_key(self):
x = torch.rand(2, 2, 2)
mode = FakeTensorMode()
@ -617,6 +620,7 @@ class FakeTensorConverterTest(TestCase):
y = torch.empty(2, 2, device="cpu")
self.assertRaises(Exception, lambda: x, y)
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_no_ref_cycle(self):
x = torch.rand([4])
mode = FakeTensorMode()

View File

@ -12,6 +12,7 @@ from torch._dispatch.python import enable_python_dispatcher
from torch.testing._internal.common_utils import (
TestCase,
skipIfCrossRef,
skipIfTorchDynamo,
suppress_warnings,
TEST_WITH_ASAN,
run_tests,
@ -251,6 +252,7 @@ class TestMetaConverter(TestCase):
m = MetaConverter()(y)
self.assertMetadataMatches(m, y)
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_weakref(self):
x = torch.randn(4, 4, 4)
m = MetaConverter()
@ -274,6 +276,7 @@ class TestMetaConverter(TestCase):
m.check_for_expired_weak_storages()
self.assertEqual(len(m.storage_memo), 0)
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_tensor_outlives_converter(self):
m = MetaConverter()
ref = weakref.ref(m)

View File

@ -235,6 +235,7 @@ class TestSparse(TestSparseBase):
@coalescedonoff
@dtypes(torch.double, torch.cdouble, torch.bfloat16)
@precisionOverride({torch.bfloat16: 1e-2})
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
def test_coalesce(self, device, dtype, coalesced):
def _test_coalesce(t):

View File

@ -2390,6 +2390,7 @@ class TestTensorCreation(TestCase):
self.assertEqual(d.shape[0], 800)
# TODO: this test should be updated
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
@onlyCPU
def test_arange_inference(self, device):
saved_dtype = torch.get_default_dtype()

View File

@ -222,6 +222,7 @@ class TestTorchDeviceType(TestCase):
s[2:7] = 1
self.assertEqual(s, storage_type(l))
@skipIfTorchDynamo("https://github.com/pytorch/torchdynamo/issues/1991")
@onlyNativeDeviceTypes
@dtypes(*all_types_and_complex_and(torch.half, torch.bool, torch.bfloat16))
def test_tensor_storage_type(self, device, dtype):

View File

@ -919,7 +919,7 @@ def wrap_fx_proxy_cls(
proxy.node.meta["example_value"] = example_value
return DynamicShapeVariable(proxy, example_value, **options)
else:
raise AssertionError(
unimplemented(
"torch.* op returned non-Tensor "
+ f"{typestr(example_value)} {proxy.node.op} {proxy.node.target}"
)