rebias uint8 to int8 on models with mixed datatypes#5075
Draft
kahmed10 wants to merge 2 commits into
Draft
Conversation
Comment on lines
+393
to
+395
| auto q1 = add_quantize_op(m1, "quantizelinear", x, scale, zero); | ||
| auto rs = m1.add_instruction(migraphx::make_op("reshape", {{"dims", {1, 1024}}}), q1); | ||
| auto d1 = add_quantize_op(m1, "dequantizelinear", rs, scale, zero); |
Contributor
There was a problem hiding this comment.
[format.py] reported by reviewdog 🐶
Suggested change
| auto q1 = add_quantize_op(m1, "quantizelinear", x, scale, zero); | |
| auto rs = m1.add_instruction(migraphx::make_op("reshape", {{"dims", {1, 1024}}}), q1); | |
| auto d1 = add_quantize_op(m1, "dequantizelinear", rs, scale, zero); | |
| auto q1 = add_quantize_op(m1, "quantizelinear", x, scale, zero); | |
| auto rs = m1.add_instruction(migraphx::make_op("reshape", {{"dims", {1, 1024}}}), q1); | |
| auto d1 = add_quantize_op(m1, "dequantizelinear", rs, scale, zero); |
Comment on lines
+41
to
+42
| auto scale = mm->add_literal(migraphx::literal{migraphx::shape::float_type, {0.05f}}); | ||
| auto zp = mm->add_literal(migraphx::literal{migraphx::shape::uint8_type, {0}}); |
Contributor
There was a problem hiding this comment.
[format.py] reported by reviewdog 🐶
Suggested change
| auto scale = mm->add_literal(migraphx::literal{migraphx::shape::float_type, {0.05f}}); | |
| auto zp = mm->add_literal(migraphx::literal{migraphx::shape::uint8_type, {0}}); | |
| auto scale = mm->add_literal(migraphx::literal{migraphx::shape::float_type, {0.05f}}); | |
| auto zp = mm->add_literal(migraphx::literal{migraphx::shape::uint8_type, {0}}); |
| // Rebias to int8 by subtracting 128 through int32 (same IR as rebias_uint8_to_int8). | ||
| auto q_i32 = mm->add_instruction( | ||
| migraphx::make_op("convert", {{"target_type", migraphx::shape::int32_type}}), q); | ||
| auto k128 = mm->add_literal(migraphx::literal{migraphx::shape::int32_type, {128}}); |
Contributor
There was a problem hiding this comment.
[format.py] reported by reviewdog 🐶
Suggested change
| auto k128 = mm->add_literal(migraphx::literal{migraphx::shape::int32_type, {128}}); | |
| auto k128 = mm->add_literal(migraphx::literal{migraphx::shape::int32_type, {128}}); |
pfultz2
reviewed
Jul 17, 2026
| // Stop when crossing a type category boundary (e.g., int or fp8 to float) | ||
| if(not same_category(precision{output->get_shape().type()}, target)) | ||
| continue; | ||
| if(not inputs_match_category(output, target)) |
Collaborator
There was a problem hiding this comment.
Can you add unit tests for these changes?
pfultz2
reviewed
Jul 17, 2026
| TEST_CASE(simplify_concat_dequantizelinear) | ||
| { | ||
| // dequantizelinear must not be pulled back through the concat: that would leave the concat | ||
| // operating on integer values, which some backends (e.g. rocMLIR) cannot fuse. |
Collaborator
There was a problem hiding this comment.
rocMLIR doesnt fuse concat either way. I dont really understand why we arent fusing the dequantizelinear.
Check flagged results 🔆 |
|
This file contains hidden or 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
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.
Motivation
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot ApplicableFollow the LLVM AI Tool Use Policy for contributions using AI.