Skip to content

Fix last-element indexing mixed with slices or scalar indices - #3056

Open
林SO (Linxiushen) wants to merge 1 commit into
microsoft:mainfrom
Linxiushen:fix/negative-scalar-slices
Open

林SO (Linxiushen) wants to merge 1 commit into
microsoft:mainfrom
Linxiushen:fix/negative-scalar-slices

Conversation

@Linxiushen

Copy link
Copy Markdown

Expressions such as x[-1, :2], x[:2, -1], and x[-1, -1] currently lower the last-element index to an empty Slice(-1, 0) before squeezing that axis. This raises an error in both eager evaluation and exported ONNX models

Use the axis end as the stop for scalar -1: the known dimension length in eager mode and the converter's existing maximum-int64 bound for exported models. Add public @script regressions comparing values and shapes with NumPy across two symbolic input shapes, including mixed scalar indices, reverse slicing, and a positive-index control

Validation:

  • New regression matrix on unchanged main: 20 failed, 4 controls passed
  • New regressions plus existing tensor, argument and evaluator tests: 58 passed using Python 3.12, ONNX 1.23 and CPU ONNX Runtime 1.30
  • Repository-configured lintrunner -a on all three changed files and git diff --check: passed

The full repository and Torch/GPU suites were not run. This change addresses last-element indexing mixed with slices or scalar indices; it does not address general advanced-index handling

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant