-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[TOSA] Make validation pass isValidElementType check more strict #119671
Conversation
The validation pass is used to check alignment of the IR against the TOSA specification. This commit updates the `isValidElement` check to more strictly align with the specifications supported element types. Signed-off-by: Luke Hutton <luke.hutton@arm.com> Change-Id: I1261220f8bebb7d64d04d00b5c656383f8329b5e
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-tosa Author: Luke Hutton (lhutton1) ChangesThe validation pass is used to check alignment of the IR against the TOSA specification. This commit updates the Full diff: https://github.com/llvm/llvm-project/pull/119671.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index 93e8cac6b84e9c..893cedefc1ebde 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
@@ -524,18 +524,8 @@ bool TosaValidation::isValidElementType(Type type) {
if (!isEnabledProfile(TosaProfileEnum::MainInference))
return false;
return type.isF32() || type.isF16() || type.isBF16();
- }
- if (auto intTy = dyn_cast<IntegerType>(type)) {
- if (intTy.isUnsigned()) {
- switch (intTy.getWidth()) {
- case 8:
- case 16:
- return true;
- default:
- return false;
- }
- } else {
- // Signless - treated as signed.
+ } else if (auto intTy = dyn_cast<IntegerType>(type)) {
+ if (intTy.isSignless()) {
switch (intTy.getWidth()) {
case 1:
case 4:
@@ -544,13 +534,10 @@ bool TosaValidation::isValidElementType(Type type) {
case 32:
case 48:
return true;
- default:
- return false;
}
}
- return false;
}
- return true;
+ return false;
}
void TosaValidation::runOnOperation() {
diff --git a/mlir/test/Dialect/Tosa/level_check.mlir b/mlir/test/Dialect/Tosa/level_check.mlir
index e851019362958f..529a16ca48c7eb 100644
--- a/mlir/test/Dialect/Tosa/level_check.mlir
+++ b/mlir/test/Dialect/Tosa/level_check.mlir
@@ -143,6 +143,14 @@ func.func @test_const_f64(%arg0 : tensor<1xf64>) {
// -----
+func.func @test_const_ui8(%arg0 : tensor<1xui8>) {
+ // expected-error@+1 {{'tosa.const' op is not profile-aligned: element type 'ui8' is not legal}}
+ %0 = "tosa.const"() {value = dense<0> : tensor<1xui8>} : () -> tensor<1xui8>
+ return
+}
+
+// -----
+
func.func @test_avgpool2d_kernel_y(%arg0: tensor<1x32x32x8xf32>) -> tensor<1x32x32x8xf32> {
// expected-error@+1 {{'tosa.avg_pool2d' op failed level check: kernel <= MAX_KERNEL}}
%0 = "tosa.avg_pool2d"(%arg0) {kernel = array<i64: 8193, 1>, pad = array<i64: 4, 4, 4, 4>, stride = array<i64: 1, 1>, acc_type = f32} :
|
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.
I recall that rescale could return u8
back but this is already fixed from what I see.
This seems to fail on (Found as an error while integrate it into downstream iree-org/iree#19479 ) |
…ict (llvm#119671)" This reverts commit 9472c5f.
Carrying the following reverts - llvm/llvm-project#116470 - llvm/llvm-project#117424 - llvm/llvm-project#119671 First two are carry over from previous integrate. It is being fixed in #19451 . The last one is a new failure. --------- Signed-off-by: MaheshRavishankar <mahesh.ravishankar@gmail.com>
…ict (llvm#119671)" This reverts commit 9472c5f.
Thanks for reporting and for the revert @MaheshRavishankar, apologies I'm only just taking a look now. I took a look at the failures and noticed that the validation pass is being run over mixed dialect IR. Currently the pass seems to run over all operators regardless of the dialect, including operators from arith/tensor/linalg that use the index type which would be considered illegal in tosa. I suspect we'll need to ensure only tosa operators are checked by this pass - I'll work on a patch for this, then resubmit this change |
…ict (llvm#119671)" This reverts commit 9472c5f.
Update LLVM to llvm/llvm-project@3f136f7 (#19479) Carrying the following reverts - llvm/llvm-project#116470 - llvm/llvm-project#117424 - llvm/llvm-project#119671 - llvm/llvm-project#119970 First two are carry over from previous-previous integrate. It is being fixed in #19451 . The last one is a from the previous integrate. The last one is a new error being tracked in #19498 --------- Signed-off-by: Stanley Winata <stanley.winata@amd.com>
…ict (llvm#119671)" This reverts commit 9472c5f.
Update LLVM to llvm/llvm-project@b07e7b76c5d532a6 (llvm/llvm-project#120002) Carrying the following reverts - llvm/llvm-project#116470 - llvm/llvm-project#117424 - llvm/llvm-project#119671 - llvm/llvm-project#119970 First two are carry over from previous-previous integrate. It is being fixed in iree-org#19451 . The last one is a from the previous integrate. The last one is a new error being tracked in iree-org#19498 Signed-off-by: Stanley Winata <stanley.winata@amd.com>
Update LLVM to llvm/llvm-project@b07e7b76c5d532a6 (llvm/llvm-project#120002) Carrying the following reverts - llvm/llvm-project#116470 - llvm/llvm-project#117424 - llvm/llvm-project#119671 - llvm/llvm-project#119970 First two are carry over from previous-previous integrate. It is being fixed in iree-org#19451 . The last one is a from the previous integrate. The last one is a new error being tracked in iree-org#19498 Signed-off-by: Stanley Winata <stanley.winata@amd.com>
…ict (llvm#119671)" This reverts commit 9472c5f.
…ict (llvm#119671)" This reverts commit 9472c5f.
…ict (llvm#119671)" This reverts commit 9472c5f.
Changes in C++ mostly handle changes done in llvm/llvm-project@4b56345 that combines SCFTilingResult and SCFReductionTilingResult. This PR also carries the following reverts - llvm/llvm-project#119671 - llvm/llvm-project#119970 The first one is a from the previous integrate. The last one is a new error being tracked in iree-org#19498. Signed-off-by: Stanley Winata <stanley.winata@amd.com>
Changes in C++ mostly handle changes done in llvm/llvm-project@4b56345 that combines SCFTilingResult and SCFReductionTilingResult. This PR also carries the following reverts - llvm/llvm-project#119671 - llvm/llvm-project#119970 The first one is a from the previous integrate. The last one is a new error being tracked in iree-org#19498. Signed-off-by: Stanley Winata <stanley.winata@amd.com>
I thought this commit had been reverted in LLVM, but it seems I was mistaken and it was reverted in the IREE fork instead. I'm unsure of the official process here, but I wanted to give a quick update. Since #120205 was merged, my hope is that the failures in IREE have been fixed - please let me know if that's not the case so I can investigate further |
Thanks @lhutton1 . @raikonenfnu if you get around to another integrate of LLVM into IREE could you please try dropping the revert in IREEs LLVM fork |
The validation pass is used to check alignment of the IR against the TOSA specification. This commit updates the
isValidElement
check to more strictly align with the specifications supported element types.