Skip to content

Commit 26bd575

Browse files
Copilotjustinchuby
andcommitted
Fix DFT dimension calculation after unsqueeze in aten__fft_r2c
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
1 parent b51737e commit 26bd575

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • onnxscript/function_libs/torch_lib/ops

onnxscript/function_libs/torch_lib/ops/fft.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ def aten__fft_r2c(
164164
dim = [d + 1 for d in dim]
165165
else:
166166
transformed = op.Unsqueeze(self, axes=[-1])
167+
# Adjust dimension indices to account for the new trailing dimension.
168+
# Negative indices need to be shifted: -1 becomes -2, -2 becomes -3, etc.
169+
# Positive indices remain unchanged as they're not affected by appending.
170+
dim = [d - 1 if d < 0 else d for d in dim]
167171

168172
for idx, dimension in enumerate(reversed(dim)):
169173
transformed = _fftn_onnx_normalization(

0 commit comments

Comments
 (0)