-
Notifications
You must be signed in to change notification settings - Fork 86
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
Parser changes to handle MatMulIntegerToFloat #3445
base: develop
Are you sure you want to change the base?
Conversation
TODO:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3445 +/- ##
===========================================
- Coverage 92.17% 92.17% -0.01%
===========================================
Files 513 513
Lines 21536 21603 +67
===========================================
+ Hits 19851 19912 +61
- Misses 1685 1691 +6 ☔ View full report in Codecov by Sentry. |
Updated parser to handle bias case as well as bad scale conditions Initial float/half tests bad scale tests bad bias tests
avoid tidy screaming about complexity
74f8ae0
to
cdb307d
Compare
Use dequantizelinear which elminates the need to add in shifts due to int8/uint8 mismatches still needs parser tests
MIGRAPHX_THROW("PARSE_QUANT_DOT_SCALED: Bias have same dim as matrix B column"); | ||
} | ||
|
||
has_valid_scale_bias = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As against invalid
? ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If scale bias doesn't exist there isn't a bias at the end of the matmulintergertofloat added then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was simply wondering if has_scale_bias
isn't what the intent is? :-)
return dequantized_op; | ||
} | ||
|
||
static instruction_ref handle_scaled_output(const onnx_parser::node_info& info, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many parameters. Ideally they should be handled by a struct
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're the same amount of a parameters gathered by the operator. These are all needed for dequantize steps and adding the proper unsqueeze->transpose paths. Order matters here with respect to matrix input A or B
Use the parsed in op name for error messages to help logging should parser errors occur.
Change naming to be agnostic of input index.
42b787d
to
9660e11
Compare
bool a1_has_no_zp = (a1 == zp_a1); | ||
|
||
auto unsq_scale_a0 = info.add_instruction(make_op("unsqueeze", {{"axes", {-1}}}), scale_a0); | ||
if(not a0_has_no_zp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Nit) Style: perhaps two negatives are not required, if there is a variable like a0_has_zp
.
Clean up uint8 handling for quant_dot. Fix tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for following up the comments. Approved.
This build is OK for merge ✅ |
🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From our conversation, need to test/handle higher dimensional matrix contractions (matrix mul). Also transpose with permutation = {0, 1}
probably does nothing.
Changes to MatMul parser to handle the Microsoft Contrib operator MatMulintegarToFloat
Since we have the scale and zero points in our operands we can just perform a multiplied after int8 biases are added and then insert a regular dot on the scaled input values which should give the same output as the input data types.
Able to leverage the existing set of tests for matmul
Needs #3526 as there's a bug with dequantizelinear this has uncovered