-
Notifications
You must be signed in to change notification settings - Fork 128
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
Support qdq decomposition of TanOp #2459
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Jul 24, 2024
GleasonK
approved these changes
Jul 24, 2024
GleasonK
reviewed
Jul 24, 2024
ce20302
to
6591cbd
Compare
sdasgup3
added a commit
that referenced
this pull request
Jul 26, 2024
This PR does the followings: 1. Merges `stablehlo-legalize-quantized-op-to-qdq` into `stablehlo-legalize-quant-to-int`. 1. Rename `stablehlo-legalize-quant-to-int` to `stablehlo-legalize-quant-to-math`. This is to clarify for scenario when the fallback `qdq` is used and sull integer quantized program cannot be generated. 1. Removes `stablehlo-legalize-quantized-op-to-qdq` pass and replace its uses with `stablehlo-legalize-quant-to-math`. 1. Remove QDQ lit checks from `stablehlo/tests/ops_stablehlo_quantized.mlir` and merges the tests added for qdq pass in `stablehlo/tests/stablehlo_legalize_quant_to_int.mlir` 1. Updates the tests in `stablehlo/tests/stablehlo_legalize_quant_to_int.mlir` updating __only__ negatives tests, which are previously unhanded by `stablehlo-legalize-quant-to-int`. The current `stablehlo-legalize-quant-to-math` uses the fallback to handle these cases. 1. About the pass `stablehlo-legalize-quant-to-math` - It uses `Patternbenefit` to assign highest priority (`benefit=10`) to pattern which has specialized handling in `stablehlo-legalize-quant-to-int`. Next in priority (`benefit=0`) are the QDQ patterns. With that the following program, which `stablehlo-legalize-quant-to-int` has specialized handling, will avoid the fallback path. ``` func.func @max_per_tensor_same_quant_parameters( %arg0: tensor<1x2x!quant.uniform<i8:f32, 2.000000e+00:3>> ) -> tensor<1x2x!quant.uniform<i8:f32, 2.000000e+00:3>> { %0 = "stablehlo.maximum"(%arg0, %arg0) : ( tensor<1x2x!quant.uniform<i8:f32, 2.000000e+00:3>>, tensor<1x2x!quant.uniform<i8:f32, 2.000000e+00:3>> ) -> tensor<1x2x!quant.uniform<i8:f32, 2.000000e+00:3>> return %0 : tensor<1x2x!quant.uniform<i8:f32, 2.000000e+00:3>> } ``` whereas the following, which is not supported in `stablehlo-legalize-quant-to-int` will choose the fallback path. ``` func.func @max_per_tensor_diff_quant_parameters(%arg0: tensor<!quant.uniform<i8:f32,1.0:0>>, %arg1: tensor<!quant.uniform<i8:f32,2.0:1>>) -> tensor<!quant.uniform<i8:f32,3.0:2>> { %0 = "stablehlo.maximum"(%arg0, %arg1) : (tensor<!quant.uniform<i8:f32,1.0:0>>, tensor<!quant.uniform<i8:f32,2.0:1>>) -> tensor<!quant.uniform<i8:f32,3.0:2>> func.return %0 : tensor<!quant.uniform<i8:f32,3.0:2>> } ``` - Currently handles qdq fallback for AddOp and a bunch of `GenericOps` op [cs](https://github.com/openxla/stablehlo/blob/eba821aa1c54a21d70331d7926dfc8b929f988f3/stablehlo/transforms/StablehloLegalizeQuantToInt.cpp#L1239). qdq fallback for `dot_general` and `convolution` will be handled in a follow up PR. What this means is we will still see quantized dot_gneral/convolution program, which are currently unsupported by `stablehlo-legalize-quant-to-int`, error out. [childPR](#2459)
6591cbd
to
8fe560e
Compare
sdasgup3
added a commit
that referenced
this pull request
Jul 26, 2024
[ParentPR](#2459) Previously while creating the QDQ pattern we use `create` API without using the result type and hence reply on the type inference to derive the result type. That works for most of the element-wise operations, however, for dot_general and convolution the result type can might be infeasible to infer in the presense of input quantize types. The PR fixes that. Note to the reviewers: To may just focus on the very last commit of the chain. The rest is coming from parent PR. [ChildPR](#2461)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
parent PR
The PR adds patterns for qdq decomposition patterns for newly added
TanOp
Note to the reviewers: To may just focus on the very last commit of the chain. The rest is coming from parent PR.
childPR