Skip to content

Commit f65531b

Browse files
Swap to better default symshapeevalue pass
Differential Revision: D62136390 Pull Request resolved: #5033
1 parent 6961eed commit f65531b

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

examples/models/llava/export_llava.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333

3434
from executorch.exir.passes import MemoryPlanningPass
3535
from executorch.exir.passes.quant_fusion_pass import QuantFusionPass
36-
from executorch.exir.passes.sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass
36+
from executorch.exir.passes.sym_shape_eval_pass import (
37+
ConstraintBasedSymShapeEvalPass,
38+
HintBasedSymShapeEvalPass,
39+
)
3740

3841
from executorch.extension.llm.export.builder import DType, LLMEdgeManager
3942
from executorch.extension.llm.tokenizer.tokenizer import Tokenizer
@@ -227,6 +230,8 @@ def export_all(llava_model: LlavaModel):
227230
memory_planning_pass=MemoryPlanningPass("greedy", alloc_graph_input=False),
228231
sym_shape_eval_pass={
229232
"image_encoder": ConstraintBasedSymShapeEvalPass(),
233+
"text_model": ConstraintBasedSymShapeEvalPass(),
234+
"token_embedding": HintBasedSymShapeEvalPass(),
230235
},
231236
)
232237
)

exir/capture/_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from executorch.exir.dynamic_shape import DynamicMemoryPlanningMode
1313
from executorch.exir.pass_manager import PassType
1414
from executorch.exir.passes import MemoryPlanningPass, ToOutVarPass
15-
from executorch.exir.passes.sym_shape_eval_pass import HintBasedSymShapeEvalPass
15+
from executorch.exir.passes.sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass
1616
from executorch.exir.tracer import ExirDynamoConfig
1717
from torch.fx._compatibility import compatibility
1818

@@ -86,7 +86,7 @@ class ExecutorchBackendConfig:
8686
# A single sym shape eval pass can be defined for all the programs in the
8787
# EdgeProgramManager or can be defined per program.
8888
sym_shape_eval_pass: Union[PassType, Dict[str, PassType]] = (
89-
HintBasedSymShapeEvalPass()
89+
ConstraintBasedSymShapeEvalPass()
9090
)
9191

9292
# If set to true, view_copy operations will be converted to lightweight

exir/passes/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ python_library(
202202
],
203203
deps = [
204204
"//caffe2:torch",
205+
"//executorch/exir:_warnings",
205206
"//executorch/exir:pass_base",
206207
"//executorch/exir:sym_util",
207208
"//executorch/exir:tensor",

exir/passes/sym_shape_eval_pass.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import torch
1212
import torch.utils._pytree as pytree
13+
14+
from executorch.exir._warnings import deprecated
1315
from executorch.exir.dialects._ops import ops as exir_ops
1416
from executorch.exir.pass_base import PassBase, PassResult
1517
from executorch.exir.sym_util import eval_expr, eval_shape, eval_upper_bound
@@ -164,8 +166,21 @@ def index_Tensor(args, kwargs) -> List[Optional[int]]: # noqa: C901
164166
return out_sizes
165167

166168

169+
@deprecated(
170+
"`HintBasedSymShapeEvalPass` is deprecated "
171+
"and will be removed in a future version of ExecuTorch. "
172+
"Please use `ConstraintBasedSymShapeEvalPass` instead.",
173+
category=FutureWarning,
174+
)
167175
class HintBasedSymShapeEvalPass(PassBase):
168176
"""
177+
178+
.. warning::
179+
180+
'HintBasedSymShapeEvalPass` is deprecated
181+
and will be removed in a future version of ExecuTorch.
182+
Please use `ConstraintBasedSymShapeEvalPass` instead.
183+
169184
If we enable dynamic shape tracing, a tensor's shape may become a symbolic
170185
formula. We should convert those symbolic formula to concrete value for
171186
static/upperbound tensors so we can properly do memory planning for them.

0 commit comments

Comments
 (0)