Skip to content

Commit d79ba63

Browse files
tarun292facebook-github-bot
authored andcommitted
In remove noop pass check for symints (#3577)
Summary: Pull Request resolved: #3577 This check will fail if there are SymInt's in the shape, and it's not a valid check to do anyways when there are SymInt's. Reviewed By: JacobSzwejbka Differential Revision: D57225749 fbshipit-source-id: ec84bf6e8d05942d929cb324cc255a7a23062a7c
1 parent 900e39b commit d79ba63

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

exir/passes/remove_noop_pass.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ def call(self, graph_module: GraphModule) -> PassResult:
7777
continue
7878

7979
if node.target == torch.ops.aten.slice_copy.Tensor:
80-
if orig_tensor.size() == node.meta["val"].size():
81-
# If the graph is quantized, we must remove the entire pattern consisting of dq->op->q.
82-
# Otherwise, removing only the op will suffice.
83-
if node.args[0].target in _DEQUANT_OPS:
84-
dequant_nodes += [node.args[0]]
85-
node.replace_all_uses_with(node.args[0])
80+
# Only do this check if all the dims are static.
81+
if all(isinstance(dim, int) for dim in orig_tensor.size()):
82+
if orig_tensor.shape == node.meta["val"].shape:
83+
# If the graph is quantized, we must remove the entire pattern consisting of dq->op->q.
84+
# Otherwise, removing only the op will suffice.
85+
if node.args[0].target in _DEQUANT_OPS:
86+
dequant_nodes += [node.args[0]]
87+
node.replace_all_uses_with(node.args[0])
8688

8789
graph_module.graph.eliminate_dead_code()
8890
eliminate_dq_q(graph_module, dequant_nodes)

0 commit comments

Comments
 (0)