[Mlir-commits] [mlir] 69c8319 - [mlir][Transform] Fix isDefiniteFailure helper
Nicolas Vasilache
llvmlistbot at llvm.org
Fri Jul 8 00:41:23 PDT 2022
Author: Nicolas Vasilache
Date: 2022-07-08T00:39:42-07:00
New Revision: 69c8319e76307423ce960570ab6e0dd3768d2a45
URL: https://github.com/llvm/llvm-project/commit/69c8319e76307423ce960570ab6e0dd3768d2a45
DIFF: https://github.com/llvm/llvm-project/commit/69c8319e76307423ce960570ab6e0dd3768d2a45.diff
LOG: [mlir][Transform] Fix isDefiniteFailure helper
This newly added helper was returning definiteFailure even in the case of silenceableFailure.
Differential Revision: https://reviews.llvm.org/D129347
Added:
Modified:
mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
mlir/test/Dialect/Linalg/transform-op-pad.mlir
mlir/test/Dialect/Transform/test-interpreter.mlir
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
index 89be5ba7ce50b..5589d937e2ac0 100644
--- a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
+++ b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
@@ -82,17 +82,19 @@ class LLVM_NODISCARD DiagnosedSilenceableFailure {
return result;
}
- /// Returns `true` if this is a silenceable failure.
- bool isDefiniteFailure() const { return result.failed(); }
-
- /// Returns `true` if this is a silenceable failure.
- bool isSilenceableFailure() const { return !diagnostics.empty(); }
-
/// Returns `true` if this is a success.
bool succeeded() const {
- return diagnostics.empty() && ::mlir::succeeded(result);
+ return ::mlir::succeeded(result) && diagnostics.empty();
}
+ /// Returns `true` if this is a definite failure.
+ bool isDefiniteFailure() const {
+ return ::mlir::failed(result) && diagnostics.empty();
+ }
+
+ /// Returns `true` if this is a silenceable failure.
+ bool isSilenceableFailure() const { return !diagnostics.empty(); }
+
/// Returns the diagnostic message without emitting it. Expects this object
/// to be a silenceable failure.
std::string getMessage() const {
diff --git a/mlir/test/Dialect/Linalg/transform-op-pad.mlir b/mlir/test/Dialect/Linalg/transform-op-pad.mlir
index 153a9f42f32fa..68664de97dd58 100644
--- a/mlir/test/Dialect/Linalg/transform-op-pad.mlir
+++ b/mlir/test/Dialect/Linalg/transform-op-pad.mlir
@@ -109,7 +109,8 @@ transform.with_pdl_patterns {
func.func @pad(%arg0: tensor<24x12xf32>,
%arg1: tensor<12x25xf32>,
%arg2: tensor<24x25xf32>) -> tensor<24x25xf32> {
- // expected-note @below {{when applied to this op}}
+ // This is attached to an error that is silenceable and is not reported by this transform
+ // {{when applied to this op}}
%0 = linalg.matmul ins(%arg0, %arg1 : tensor<24x12xf32>, tensor<12x25xf32>) outs(%arg2 : tensor<24x25xf32>) -> tensor<24x25xf32>
func.return %0 : tensor<24x25xf32>
}
@@ -127,7 +128,8 @@ transform.with_pdl_patterns {
transform.sequence %arg0 {
^bb1(%arg1: !pdl.operation):
%0 = pdl_match @pdl_target in %arg1
- // expected-error @below {{transform.structured.pad failed to apply}}
+ // This error is silenceable and is not reported by this transform
+ // {{transform.structured.pad failed to apply}}
%1 = transform.structured.pad %0 {padding_values=[0.0 : f32, 0.0 : f32, 0.0 : f32], padding_dimensions=[0, 1, 2], pack_paddings=[1, 1, 0]}
}
}
diff --git a/mlir/test/Dialect/Transform/test-interpreter.mlir b/mlir/test/Dialect/Transform/test-interpreter.mlir
index 9d48cede2d963..a47021396e1a6 100644
--- a/mlir/test/Dialect/Transform/test-interpreter.mlir
+++ b/mlir/test/Dialect/Transform/test-interpreter.mlir
@@ -545,3 +545,27 @@ transform.with_pdl_patterns {
test_print_remark_at_operand %2, "matched"
}
}
+
+// -----
+
+func.func @foo() {
+ "op" () { target_me } : () -> ()
+ "op" () : () -> ()
+ return
+}
+
+transform.with_pdl_patterns {
+^bb0(%arg0: !pdl.operation):
+ pdl.pattern @some : benefit(1) {
+ %0 = pdl.operands
+ %1 = pdl.types
+ %2 = pdl.operation "op"(%0 : !pdl.range<value>) -> (%1 : !pdl.range<type>)
+ pdl.rewrite %2 with "transform.dialect"
+ }
+
+ transform.sequence %arg0 {
+ ^bb0(%arg1: !pdl.operation):
+ %0 = pdl_match @some in %arg1
+ transform.test_mixed_sucess_and_silenceable %0
+ }
+}
diff --git a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
index 1332b13a22476..7930f3904b78b 100644
--- a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
+++ b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
@@ -266,6 +266,15 @@ mlir::test::TestMixedNullAndNonNullResultsOp::applyToOne(
return DiagnosedSilenceableFailure::success();
}
+DiagnosedSilenceableFailure
+mlir::test::TestMixedSuccessAndSilenceableOp::applyToOne(
+ Operation *target, SmallVectorImpl<Operation *> &results,
+ transform::TransformState &state) {
+ if (target->hasAttr("target_me"))
+ return DiagnosedSilenceableFailure::success();
+ return emitDefaultSilenceableFailure(target);
+}
+
namespace {
/// Test extension of the Transform dialect. Registers additional ops and
/// declares PDL as dependent dialect since the additional ops are using PDL
diff --git a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td
index 08149a25ba3d1..4c144e7be9455 100644
--- a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td
+++ b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.td
@@ -196,4 +196,20 @@ def TestMixedNullAndNonNullResultsOp
}];
}
+def TestMixedSuccessAndSilenceableOp
+ : Op<Transform_Dialect, "test_mixed_sucess_and_silenceable",
+ [FunctionalStyleTransformOpTrait, MemoryEffectsOpInterface,
+ TransformEachOpTrait, TransformOpInterface]> {
+ let arguments = (ins PDL_Operation:$target);
+ let results = (outs);
+ let assemblyFormat = "$target attr-dict";
+ let cppNamespace = "::mlir::test";
+ let extraClassDeclaration = [{
+ ::mlir::DiagnosedSilenceableFailure applyToOne(
+ ::mlir::Operation * target,
+ ::llvm::SmallVectorImpl<::mlir::Operation *> &results,
+ ::mlir::transform::TransformState &state);
+ }];
+}
+
#endif // MLIR_TESTTRANSFORMDIALECTEXTENSION_TD
More information about the Mlir-commits
mailing list