Skip to content

Commit 769004c

Browse files
Copilotmshr-h
andauthored
Avoid deprecated x.T in default ONNX Transpose handling (#2)
* Initial plan * Fix default transpose warning Co-authored-by: mshr-h <8973217+mshr-h@users.noreply.github.com> * Remove added transpose regression test Co-authored-by: mshr-h <8973217+mshr-h@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mshr-h <8973217+mshr-h@users.noreply.github.com>
1 parent 3713c77 commit 769004c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/onnx2fx/ops/tensor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def transpose(builder: "GraphBuilder", node: onnx.NodeProto) -> torch.fx.Node:
142142
perm = get_attribute(node, "perm")
143143
if perm is None:
144144
# Default: reverse all dimensions
145-
return builder.call_function(lambda t: t.T, args=(x,))
145+
return builder.call_function(
146+
lambda t: torch.permute(t, tuple(range(t.ndim - 1, -1, -1))),
147+
args=(x,),
148+
)
146149
return builder.call_function(torch.permute, args=(x, perm))
147150

148151

0 commit comments

Comments
 (0)