Skip to content

[WebNN EP] Add output rank validation - #31708

Merged
Dwayne Robinson (fdwr) merged 2 commits into
microsoft:mainfrom
Honry:limit-output-rank
Aug 12, 2026
Merged

Dwayne Robinson (fdwr) merged 2 commits into
microsoft:mainfrom
Honry:limit-output-rank

Conversation

@Honry

@Honry Wanming Lin (Honry) commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Mirror the existing input rank check by validating each node's output rank against the WebNN opSupportLimits's rankRange.

  • Rename IsInputRankSupported -> IsRankSupportedByWebNNOp.
  • Add IsOutputRankSupportedByOp for the common single-"output" case.
  • Add output rank checks to multi-output ops (gru, lstm, split) using their specific output parameter names.
  • Skip decomposed ops (their type checks loop over sub-ops whose ranks differ from the final output).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@Honry
Wanming Lin (Honry) force-pushed the limit-output-rank branch 2 times, most recently from e2838e2 to ae08201 Compare August 10, 2026 01:30
Mirror the existing input rank check by validating each node's output
rank against the WebNN opSupportLimits rankRange.

- Rename IsInputRankSupported -> IsRankSupportedByWebNNOp.
- Add IsOutputRankSupportedByOp for the common single-"output" case.
- Add output rank checks to multi-output ops (gru, lstm, split) using
  their specific output parameter names.
- Skip decomposed ops (their type checks loop over sub-ops whose ranks
  differ from the final output).
@Honry

Copy link
Copy Markdown
Contributor Author

Dwayne Robinson (@fdwr), PTAL, thanks!

@fdwr Dwayne Robinson (fdwr) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘

@fdwr
Dwayne Robinson (fdwr) merged commit 8bbb81e into microsoft:main Aug 12, 2026
96 of 99 checks passed
Wanming Lin (Honry) added a commit to Honry/onnxruntime that referenced this pull request Aug 13, 2026
The output rank validation added in microsoft#31708 wrongly falls back ops whose
ONNX output rank differs from the WebNN operand rank:

- InstanceNormalization, Conv (conv1d) and MatMul (1-D input) reshape the
  input to a WebNN-valid rank and reshape the output back. Skip the output
  rank check exactly when that workaround fires, mirroring the existing
  input-side skips. Also make the InstanceNormalization input-side check
  symmetric (only validate the 4D direct path).
- Gather with 0-D indices yields a valid 0-D output, but the WebNN gather
  output rankRange is reported with min=1; permit 0-D output.
Dwayne Robinson (fdwr) pushed a commit that referenced this pull request Aug 14, 2026
The output rank validation added in #31708 wrongly falls back ops whose
ONNX output rank differs from the WebNN operand rank:

- InstanceNormalization, Conv (conv1d) and MatMul (1-D input) reshape
the input to a WebNN-valid rank and reshape the output back. Skip the
output rank check exactly when that workaround fires, mirroring the
existing input-side skips. Also make the InstanceNormalization
input-side check symmetric (only validate the 4D direct path).
- Gather with 0-D indices yields a valid 0-D output, but the WebNN
gather output rankRange is reported with min=1; permit 0-D output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants