Skip to content

Commit 0f65b2e

Browse files
committed
check last axis is valid size
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
1 parent 5fdc5e1 commit 0f65b2e

File tree

1 file changed

+5
-1
lines changed
  • onnxruntime/core/providers/cpu/signal

1 file changed

+5
-1
lines changed

onnxruntime/core/providers/cpu/signal/dft.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,18 @@ static Status discrete_fourier_transform(OpKernelContext* ctx, int64_t axis, boo
421421
const auto& X_shape = X->Shape();
422422
const auto is_real_valued = X_shape[X_shape.NumDimensions() - 1] == 1;
423423
const auto is_complex_valued = X_shape[X_shape.NumDimensions() - 1] == 2;
424+
424425
axis = HandleNegativeAxis(axis, X_shape.NumDimensions());
425426
ORT_RETURN_IF(axis == static_cast<int64_t>(X_shape.NumDimensions()) - 1,
426-
"DFT axis must refer to a signal dimension, not the last real/imag dimension.");
427+
"DFT axis must refer to a signal dimension, not the last (real/imag) dimension.");
427428

428429
// Validate input for IRFFT
429430
if (inverse && is_onesided) {
430431
ORT_RETURN_IF(!is_complex_valued,
431432
"Inverse one-sided DFT (IRFFT) requires complex-valued input (last dimension must be 2)");
433+
} else {
434+
ORT_RETURN_IF(!(is_real_valued || is_complex_valued),
435+
"Input layout not supported. The input tensor must have a last dimension of 1 (real) or 2 (complex).");
432436
}
433437

434438
int64_t number_of_samples = static_cast<int64_t>(X_shape[onnxruntime::narrow<size_t>(axis)]);

0 commit comments

Comments
 (0)