Skip to content

Commit 92b5aea

Browse files
zhxchen17facebook-github-bot
authored andcommitted
Fix remove _to_copy pass.
Summary: Turns out that .to() can also change memory format, therefore we need to ensure the strides and shapes don't change before removing _to_copy node. Reviewed By: cccclai Differential Revision: D56637766 fbshipit-source-id: 50f59daac6ed69a833e67a276065ed911b31b054
1 parent 8dcc1ad commit 92b5aea

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

exir/passes/remove_noop_pass.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def call(self, graph_module: GraphModule) -> PassResult:
110110
if (
111111
orig_tensor.dtype == node.meta["val"].dtype
112112
and orig_tensor.device == node.meta["val"].device
113+
and orig_tensor.shape == node.meta["val"].shape
114+
and orig_tensor.stride() == node.meta["val"].stride()
113115
):
114116
node.replace_all_uses_with(node.args[0])
115117

0 commit comments

Comments
 (0)