Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove element type restriction in softmax lowering #3051

Merged

Conversation

srcarroll
Copy link
Contributor

@srcarroll srcarroll commented Jan 25, 2025

This patch removes the assertion that input element type is f32 in the softmax to stablehlo lowering. There appears to be no good reason for this restriction as stablehlo supports more types.

The original Softmax.mlir test has been renamed to Softmax-Decompose.mlir and replaced by a new one the leaves out the decompose-onnx pass. The primary reason for this is to be able to test bf16 lowering which is still not supported by the decomposition. An error is thrown while computing the identity for max reduction (see https://github.com/onnx/onnx-mlir/blob/main/src/Dialect/Mlir/DialectBuilder.cpp#L698). Since downstream users don't necessarily need the decomposition it suffices to test without it for now. However, plans to support lower precision types elsewhere is a todo.

Note: The decomposition does stabilize softmax to prevent overflow, which is especially important for lower precision. Nevertheless, the straight conversion should allow it if people to choose to opt out of the decomp.

Copy link
Collaborator

@AlexandreEichenberger AlexandreEichenberger left a comment

Choose a reason for hiding this comment

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

LGTM

@AlexandreEichenberger
Copy link
Collaborator

Let me know if you want me to merge it @srcarroll

@srcarroll
Copy link
Contributor Author

Let me know if you want me to merge it @srcarroll

thanks. yes please

@AlexandreEichenberger AlexandreEichenberger merged commit cf17e0d into onnx:main Jan 27, 2025
7 checks passed
@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15190 [push] Remove element type rest... started at 12:32

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16161 [push] Remove element type rest... started at 11:13

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16163 [push] Remove element type rest... started at 12:13

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16161 [push] Remove element type rest... passed after 1 hr 17 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16163 [push] Remove element type rest... passed after 1 hr 39 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15190 [push] Remove element type rest... passed after 2 hr 25 min

christopherlmunoz pushed a commit to christopherlmunoz/onnx-mlir that referenced this pull request Jan 30, 2025
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.

3 participants