Skip to content

Commit fd9d9db

Browse files
authored
[Relax][ONNX] Fix shape/dynamic restrictions for Squeeze/Unsqueeze and Slice (#18955)
## Summary Relates to #18945. This PR improves ONNX frontend handling for dynamic `Unsqueeze`/`Squeeze`/`Slice`, tightens validation paths, and adds targeted structural/negative regression tests. - Refactor constant-path `Unsqueeze` lowering to use a single `reshape` based on computed target shape. - Remove scalar-specific branching and repeated `expand_dims` in the constant path. - Add/keep structural helper usage in ONNX frontend tests for Relax call-op checks. - Add regression coverage for scalar-input `Unsqueeze`. ## Changes - Add dynamic-axes conversion paths for `Unsqueeze` and `Squeeze`: - infer output shape via runtime shape-tensor construction - lower to `relax.reshape` with validated shape rank/length assumptions - Improve `Slice` conversion robustness: - support dynamic parameter forms with stricter rank/length validation - reject invalid zero-step inputs when statically known - fix docstring wording (`Splice` -> `Slice`) - Strengthen ONNX frontend tests: - negative test for duplicate `Unsqueeze` axes - structural IR check for dynamic `Slice` (`relax.dynamic_strided_slice` present, `relax.strided_slice` absent) - negative test for zero-step `Slice` - Refactor constant-path `Unsqueeze` scalar handling: - replace scalar special-casing + repeated `expand_dims` with one target-shape `reshape` - add scalar-input regression test - Restore shared test helper used by structural Relax call-op checks. ## validation - `ruff check`: passed - `pre-commit --files`: passed - `pytest`: 8 passed
1 parent d293b7a commit fd9d9db

2 files changed

Lines changed: 630 additions & 74 deletions

File tree

0 commit comments

Comments
 (0)