-
Notifications
You must be signed in to change notification settings - Fork 348
[NNPA] An option to report why the operations are not run on NNPA (--opt-report=NNPAUnsupportedOps) #2819
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
Conversation
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
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.
LGTM! It's useful. Thanks for adding this!
void emitLegalityCheckMessage(Operation *op, StringRef message) { | ||
LLVM_DEBUG(llvm::outs() << "[NNPA Legality Check] Warning: " << op->getLoc() | ||
<< " runs on CPU. Reason: " << message << "\n"); | ||
} |
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.
Could you print out the operation name also? Sometime the loc is just a number and it's not easy to know which operation is.
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.
Added operation name and node name. Thanks!
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
bool returnVal = (shapeA[1] == shapeB[0]); | ||
if (!returnVal) | ||
emitLegalityCheckMessage( | ||
op.getOperation(), "Unstacked case, dim A 1 not equal dim B 0."); |
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.
Since we know the dimension size in this case, you can print out shapeA[1]
and shapeB[0]
as well, say Unstacked case, the 2nd dim of A (5) and the 1st dim of B (7) are not the same.
if shapeA[1] =5 and shapeB[0] = 7`. Same for other static-shape cases.
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.
Done. Thanks!
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
} else { | ||
std::string message = "Element type is not F16 or F32."; | ||
emitLegalityCheckMessage(op, StringRef(message)); | ||
return false; |
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 recommend to change emitLegalityCheckMessage
to return false
, e.g bool emitLegalityCheckMessage(Operation *op, StringRef message)
, and then we can write:
return emitLegalityCheckMessage(op, StringRef(message));
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.
Done. Thanks. Also changed the function name.
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
return ((rank > 0) && (rank <= 4)); | ||
if ((rank > 0) && (rank <= 4)) { | ||
return true; | ||
} else { |
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.
Since we have return
in the if
part, the else
is not necessary. For example:
if ((rank > 0) && (rank <= 4))
return true;
std::string message =
"Rank " + std::to_string(rank) +
" is not supported. zAIU only supports rank in range of (0, 4].";
return emitWarningMessageNNPAUnsupported(op, StringRef(message));
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.
Done. Thanks!
Signed-off-by: Haruki Imai <[email protected]>
} | ||
} | ||
return true; | ||
} | ||
|
||
bool emitWarningMessageNNPAUnsupported(Operation *op, StringRef message) { |
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.
Do we really need to use StringRef instead of just const std::string&
? I don't see any operation on message
and passing a pointer looks faster than constructing a StringRef.
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.
Updated. Thanks!
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
return !emitWarningMessageNNPAUnsupported( | ||
op.getOperation(), message); /* true */ | ||
|
||
return false; |
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.
This can be shorten in this way:
return (!sameBatchDims) || emitWarningMessageNNPAUnsupported(op.getOperation(), message);
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.
Updated. Thanks!
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
When it's ready for another round of review, please let me know. Thanks! |
Yes. ready for review. |
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.
Thanks for updating the patch. It's much better. Just some minor comments, but the most important thing is updating the document. And, feel free to merge the patch then.
In your example of roberta, I see this
==NNPA-UNSUPPORTEDOPS-REPORT== onnx.Softmax, /roberta/encoder/layer.0/attention/self/Softmax_176, The rank of input tensor (4) needs to be 2 or 3.
It seemed it was not applied in this model. Do you know what was the reason? Softmax with rank 4 is potentially rewritten to rank 2 by RewriteONNXForZHigh pass. Perhaps axis
was not the last dimension in this model ...
@@ -51,6 +51,10 @@ | |||
|
|||
#define ACCEL_PROFILEIR_CL_ENUM(name) PROFILEIR_CL_ENUM_##name | |||
|
|||
#define ACCEL_OPTREPORT_ENUM(name) OPTREPORT_ENUM_##name | |||
|
|||
#define ACCEL_OPTREPORT_CL_ENUM(name) OPTREPORT_CL_ENUM_##name |
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.
Could you update this document to include the new macro? Thanks!
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.
Done. Thanks!
bool emitWarningMessageNNPAUnsupported( | ||
mlir::Operation *op, const std::string &message); | ||
|
||
bool emitWarningMessageInCompatibility(mlir::Operation *op); |
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.
Would you mind if we change these function names to make it consistent with functions for other --op-report
options? We have onnxToKrnlSimdReport
and onnxToKrnlParallelReport
, so how about onnxToZHighUnsupportedReport
? or feel free to choose another name.
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.
Done. Thanks!
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.
Could you add a ,
after the option identifier, namely transforming
==NNPA-UNSUPPORTEDOPS-REPORT== onnx.Mul, /roberta/embeddings/Mul, Element type is not F16 or F32.
to
==NNPA-UNSUPPORTEDOPS-REPORT==, onnx.Mul, /roberta/embeddings/Mul, Element type is not F16 or F32.
so that is is like all of the other perf measurements; it let you do CSV imports more easily.
Great addition, thanks.
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.
Approving the PR, but please add the missing comma in the printout to be compatible with the other tools.
I confirmed all softmax ops are lowered to zhigh.softmax in ZHighIR. I found this message was generated in |
Signed-off-by: Haruki Imai <[email protected]>
Signed-off-by: Haruki Imai <[email protected]>
Done. Thanks! |
So the printed message was incorrect. I think you would fix that before merging.
Yes, it is in the code, but they are independent calls and used for analysis. The results of each call will be merged later. You can take a look at: https://github.com/onnx/onnx-mlir/blob/main/src/Accelerators/NNPA/Conversion/ONNXToZHigh/DevicePlacement.cpp#L196 |
Signed-off-by: Haruki Imai <[email protected]>
Thanks for the comment!. I updated the PR to enable the reporting only in ONNXToZHighPass and disable it in DevicePlacementPass. This removes reporting about Softmax, as described in updated description of this PR. |
Thank you for the great work! Please merge it at your convenience time. |
@jenkins-droid test this please |
@jenkins-droid test this please |
Signed-off-by: Haruki Imai <[email protected]>
Jenkins Linux s390x Build #14919 [push] [NNPA] Option to report ... started at 18:34 |
Jenkins Linux amd64 Build #14914 [push] [NNPA] Option to report ... started at 17:34 |
Jenkins Linux ppc64le Build #13944 [push] [NNPA] Option to report ... started at 18:45 |
Jenkins Linux amd64 Build #14914 [push] [NNPA] Option to report ... passed after 1 hr 6 min |
Jenkins Linux s390x Build #14919 [push] [NNPA] Option to report ... passed after 1 hr 29 min |
Jenkins Linux ppc64le Build #13944 [push] [NNPA] Option to report ... passed after 1 hr 56 min |
Generate report on why the operations are not run on NNPA.
The report is displayed by using
--opt-report=NNPAUnsupportedOps
. The format is==NNPA-UNSUPPORTEDOPS-REPORT==, <operation name>, <node name>, <reason>
Example of xlm-roberta-base-language-detection-onnx (issue #2813):