Skip to content

Commit ef23e8f

Browse files
authored
[SOT][DynamicShape] add flag for break graph on get symbolilc value (#69354)
1 parent a81b3b6 commit ef23e8f

File tree

2 files changed

+6
-0
lines changed
  • python/paddle/jit/sot

2 files changed

+6
-0
lines changed

python/paddle/jit/sot/opcode_translator/executor/variables/basic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
log,
4343
printable,
4444
)
45+
from ....utils.envs import ENV_SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE
4546
from ....utils.exceptions import HasNoAttributeError, InnerError
4647
from ..dispatch_functions import tensor_numel
4748
from ..guard import (
@@ -785,6 +786,8 @@ def disable_symbolic(var: VariableBase):
785786
)
786787

787788
def get_py_value(self, allow_tensor: bool = False) -> bool | int | float:
789+
if ENV_SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE.get():
790+
raise BreakGraphError("get_py_value from SymbolicVariable")
788791
self.need_guard_value = True
789792
if isinstance(self.value, SymbolicValue):
790793
assert isinstance(

python/paddle/jit/sot/utils/envs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
ENV_ENABLE_SOT_STEP_PROFILER = BooleanEnvironmentVariable(
4747
"ENABLE_SOT_STEP_PROFILER", False
4848
)
49+
ENV_SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE = BooleanEnvironmentVariable(
50+
"SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE", False
51+
)
4952

5053

5154
@contextmanager

0 commit comments

Comments
 (0)