mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add RAISE_VARARGS 0
(#146493)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/146493 Approved by: https://github.com/zou3519 ghstack dependencies: #146498, #146492
This commit is contained in:
committed by
PyTorch MergeBot
parent
134723ee1c
commit
cefd9805de
@ -11897,6 +11897,27 @@ fn
|
||||
self.assertFalse(ne)
|
||||
self.assertEqual(len(counters["graph_break"]), 1)
|
||||
|
||||
@unittest.skipIf(sys.version_info < (3, 11), "Python 3.11+")
|
||||
def test_RAISE_VARARGS_0(self):
|
||||
def foo():
|
||||
try:
|
||||
raise ValueError
|
||||
except:
|
||||
raise
|
||||
|
||||
@torch.compile(backend="eager", fullgraph=True)
|
||||
def fn(t):
|
||||
try:
|
||||
foo()
|
||||
except ValueError:
|
||||
return t.sin()
|
||||
except Exception:
|
||||
return t.cos()
|
||||
|
||||
t = torch.randn(2)
|
||||
y = fn(t)
|
||||
self.assertEqual(y, t.sin())
|
||||
|
||||
def test_overridden_getattribute(self):
|
||||
class Foo:
|
||||
attribute_map = {}
|
||||
|
@ -1562,7 +1562,12 @@ class InstructionTranslatorBase(
|
||||
|
||||
def RAISE_VARARGS(self, inst):
|
||||
if inst.arg == 0:
|
||||
unimplemented("re-raise")
|
||||
# duplicate the top of the stack and re-raise it
|
||||
if sys.version_info < (3, 11):
|
||||
unimplemented("re-raise")
|
||||
assert isinstance(self.stack[-1], ExceptionVariable)
|
||||
self.stack.append(self.stack[-1])
|
||||
self._raise_exception_variable(inst)
|
||||
elif inst.arg == 1:
|
||||
self._raise_exception_variable(inst)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user