File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
backends/xnnpack/operators Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 16
16
XNNStaticReshape ,
17
17
XNode ,
18
18
)
19
+
19
20
from executorch .backends .xnnpack .utils .utils import check_or_raise , get_input_node
21
+ from torch .fx .experimental .symbolic_shapes import free_symbols
20
22
21
23
22
24
@register_node_visitor
@@ -57,7 +59,7 @@ def define_node(
57
59
58
60
num_dynamic_dims = 0
59
61
for dim in dynamic_shape :
60
- if isinstance (dim , torch . SymInt ):
62
+ if free_symbols (dim ):
61
63
num_dynamic_dims += 1
62
64
new_shape .append (0 )
63
65
else :
@@ -119,7 +121,7 @@ def define_node(
119
121
120
122
num_dynamic_dims = 0
121
123
for dim in dynamic_shape :
122
- if isinstance (dim , torch . SymInt ):
124
+ if free_symbols (dim ):
123
125
num_dynamic_dims += 1
124
126
new_shape .append (0 )
125
127
else :
Original file line number Diff line number Diff line change 23
23
24
24
from executorch .exir .lowered_backend_module import create_submodule_from_nodes
25
25
from torch ._export .utils import is_buffer , is_lifted_tensor_constant , is_param
26
+ from torch .fx .experimental .symbolic_shapes import has_free_symbols
26
27
from torch .fx .node import Node
27
28
from torch .fx .passes .utils .source_matcher_utils import SourcePartition
28
29
@@ -424,10 +425,7 @@ def is_shape_dynamic(node: torch.fx.Node) -> bool:
424
425
Check if the node shape is dynamic.
425
426
"""
426
427
427
- # Shape is dynamic if any of the dimensions don't evaluate to a static value
428
- return "val" in node .meta and any (
429
- isinstance (d , torch .SymInt ) for d in node .meta ["val" ].shape
430
- )
428
+ return has_free_symbols (node .meta ["val" ].shape )
431
429
432
430
433
431
# TODO - style: use templated types
You can’t perform that action at this time.
0 commit comments