Skip to content

[Relax][FRONTEND][ONNX] Support Softmax, LogSoftmax and Hardmax when opset version ≤12#19428

Merged
tlopex merged 8 commits into
apache:mainfrom
cchung100m:issue-19420
Apr 23, 2026
Merged

[Relax][FRONTEND][ONNX] Support Softmax, LogSoftmax and Hardmax when opset version ≤12#19428
tlopex merged 8 commits into
apache:mainfrom
cchung100m:issue-19420

Conversation

@cchung100m

@cchung100m cchung100m commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Hi Commiters,

This PR is going to fix Softmax-family legacy semantics for opset<=12 and harden Hardmax fallback.

Summary:

  • Implement legacy ONNX semantics for Softmax / LogSoftmax / Hardmax in opset <= 12, including flatten-to-2D + reshape-back behavior.
  • Keep opset >= 13 behavior unchanged (_impl_v13 axis-based path).
  • Add compatibility-first fallback warnings for unknown rank/shape paths.
  • Harden Hardmax internals: normalize input before struct_info access and add backward-compatible helper signature handling.
  • Extend regression coverage for softmax-family across opset 1/11/13 and key axis scenarios.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request implements legacy semantics for ONNX Softmax, LogSoftmax, and Hardmax operators (opset <= 12), which require flattening the input tensor into a 2D matrix based on the axis attribute. The review feedback correctly identifies that the current fallback logic for tensors with unknown static rank incorrectly defaults to modern (opset >= 13) behavior. It is recommended to raise a ValueError in these cases to prevent silent calculation errors for dynamic-rank tensors.

Comment thread python/tvm/relax/frontend/onnx/onnx_frontend.py
Comment thread python/tvm/relax/frontend/onnx/onnx_frontend.py
Comment thread python/tvm/relax/frontend/onnx/onnx_frontend.py Outdated
@cchung100m cchung100m marked this pull request as ready for review April 23, 2026 05:06
@cchung100m

Copy link
Copy Markdown
Contributor Author

Hi @tlopex @mshr-h

This PR is trying to fix issues #19420. Any suggestions would be appreciated if you are available.

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@tlopex tlopex merged commit 7eea6df into apache:main Apr 23, 2026
12 of 13 checks passed
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