-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add testdata files for quantized stablohlo programs #2404
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
GleasonK
approved these changes
Jun 20, 2024
This was referenced Jul 19, 2024
sdasgup3
added a commit
that referenced
this pull request
Jul 23, 2024
Check dialect is an auxiliary dialect used in StableHLO repository for validation of StableHLO program evaluation. Currently there is no cleaner way to parse a module containing check dialect operations or to create them. One way to go around this is to textually modify the check dialect ops to normalize them to generic MLIR text and allow unregistered dialect to pars that text. However, this PR provodes a cleaner way to process check dialect. This PR prepares for open sourcing some of the utilities, leveraged in #2404, for auto-generating testdata formatted test files.
sdasgup3
added a commit
that referenced
this pull request
Aug 20, 2024
This PR exposes some key APIs to auto-generate StableHLO test programs in testdata format, which are leveraged in #2404. ## Proposed API ```python def testdata_generator( module: ir.Module, args: Sequence[np.ndarray] = [] ) -> ir.Module: ``` - `module`: The StableHLO module to generate test data for. - `args`: (Optional) A sequence of NumPy arrays representing input values for the module. If not provided, the function will attempt to extract input values from the module itself. ## Example ```python # Input (module_str) module_str = """ module { func.func @main(%arg0: tensor<2xf32>, %arg1: tensor<2xf32>) -> tensor<2xf32> { %0 = stablehlo.add %arg0, %arg1 : tensor<2xf32> return %0 : tensor<2xf32> } } """ # Input (args) args = [ np.array([1.0, 2.0], dtype=np.float32), np.array([3.0, 4.0], dtype=np.float32) ] # Generate test data module_output = testdata_generator(module, args) # Output (module_output) module_output_str = """ module { func.func @main() -> tensor<i1> { %cst = stablehlo.constant dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf32> %cst_0 = stablehlo.constant dense<[3.000000e+00, 4.000000e+00]> : tensor<2xf32> %cst_1 = stablehlo.constant dense<[4.000000e+00, 6.000000e+00]> : tensor<2xf32> %0 = stablehlo.add %cst, %cst_0 : tensor<2xf32> %1 = stablehlo.custom_call @check.eq(%cst_1, %0) : (tensor<2xf32>, tensor<2xf32>) -> tensor<i1> return %1 : tensor<i1> } } """ ``` Note to reviewer: The current PR is based on #2445, so please review that first.
This was referenced Aug 23, 2024
abhigunj
added a commit
that referenced
this pull request
Aug 23, 2024
refer parent PR #2404 for 6 test files zero_point of DotGeneralOp `rhs` is not 0.
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.
Add quantized tests for the following stablehlo operations
A few details
testdata-generator
tool which takes an input a non-quantized program file from https://github.com/openxla/stablehlo/tree/main/stablehlo/tests/interpret or https://github.com/openxla/stablehlo/tree/main/stablehlo/testdata and generates a quantized program file in the same format as the input file._qi8
appended, suggesting that all the quantized program involvesi8
as storage type.A few limitations
f32
floating point programs only. In future this case be improved.testdata-generator
tool currently supports, but in very near future we can expect the tool to work on input test files with mutiple operations being tested.Keep an eye on more quantized tests to be populated!