Skip to content

Commit a926cd3

Browse files
authored
Revert "[SOT][Exception] Add with support (#72736)" (#73816)
1 parent 26ef5eb commit a926cd3

2 files changed

Lines changed: 1 addition & 193 deletions

File tree

python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@
113113
VariableBase,
114114
VariableFactory,
115115
)
116-
from .virtual_frame import BlockStackItem
117116

118117
if TYPE_CHECKING:
119118
from .function_graph import CompileGraphResult, FunctionGraph
120119
from .variable_stack import VariableStack
121120
from .virtual_frame import VirtualFrame
122121

123122
from .exception_stack import ExceptionStack
123+
from .virtual_frame import BlockStackItem
124124

125125
COMPARE_OP_NAME_TO_FN = {
126126
">": operator.gt,
@@ -2189,45 +2189,6 @@ def RETURN_VALUE(self, instr: Instruction):
21892189
ret_val = self.stack.pop()
21902190
return self.compile_return(ret_val)
21912191

2192-
@call_break_graph_decorator(push_n=2)
2193-
@fallback_if_python_version_unsupported
2194-
def SETUP_WITH(self, instr: Instruction):
2195-
mgr = self.stack.pop()
2196-
exit = BuiltinVariable(
2197-
getattr, graph=self._graph, tracker=DanglingTracker()
2198-
)(mgr, ConstantVariable.wrap_literal("__exit__", self._graph))
2199-
2200-
self.stack.push(exit)
2201-
2202-
enter = BuiltinVariable(
2203-
getattr, graph=self._graph, tracker=DanglingTracker()
2204-
)(mgr, ConstantVariable.wrap_literal("__enter__", self._graph))
2205-
2206-
res = enter.call_function()
2207-
self.vframe.block_stack.append(
2208-
BlockStackItem(
2209-
"SETUP_FINALLY", instr, instr.jump_to, len(self.stack)
2210-
)
2211-
)
2212-
self.stack.push(res)
2213-
2214-
@fallback_if_python_version_unsupported
2215-
def WITH_EXCEPT_START(self, instr: Instruction):
2216-
"""
2217-
At the top of the stack are 7 values (top is last):
2218-
[exit_func, previous_tb, previous_val, previous_exc, tb, val, exc]
2219-
We call exit_func(exc, val, tb).
2220-
Then push exc and the __exit__ return value.
2221-
"""
2222-
exc = self.stack.peek[1]
2223-
val = self.stack.peek[2]
2224-
tb = self.stack.peek[3]
2225-
2226-
exit_func = self.stack.peek[7]
2227-
res = exit_func.call_function(exc, val, tb)
2228-
2229-
self.stack.push(res)
2230-
22312192
def RETURN_CONST(self, instr: Instruction):
22322193
ret_const = self.vframe.consts[instr.arg]
22332194
return self.compile_return(ret_const)

test/sot/test_25_with.py

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)