[Mlir-commits] [mlir] 411dd47 - [mlir][Linalg] Make HoistRedundantTensorSubsetsOp not a FunctionalStyleTransformOpTrait
Nicolas Vasilache
llvmlistbot at llvm.org
Fri Apr 14 09:47:41 PDT 2023
Author: Nicolas Vasilache
Date: 2023-04-14T09:47:36-07:00
New Revision: 411dd47dbf80ebac347051136a4026c5549bce90
URL: https://github.com/llvm/llvm-project/commit/411dd47dbf80ebac347051136a4026c5549bce90
DIFF: https://github.com/llvm/llvm-project/commit/411dd47dbf80ebac347051136a4026c5549bce90.diff
LOG: [mlir][Linalg] Make HoistRedundantTensorSubsetsOp not a FunctionalStyleTransformOpTrait
Differential Revision: https://reviews.llvm.org/D148350
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/test/Dialect/Linalg/hoisting.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 9366ce7a241b4..6af12109c92ab 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -1957,8 +1957,9 @@ def ConvertConv2DToImg2ColOp : Op<Transform_Dialect,
def HoistRedundantTensorSubsetsOp :
Op<Transform_Dialect, "structured.hoist_redundant_tensor_subsets",
- [FunctionalStyleTransformOpTrait, MemoryEffectsOpInterface,
- TransformEachOpTrait, TransformOpInterface]> {
+ [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
+ TransformEachOpTrait,
+ TransformOpInterface]> {
let description = [{
Hoists supported tensor subset extract/insert operation pairs out of
immediately enclosing loop iteratively, if the following conditions
@@ -1978,18 +1979,18 @@ def HoistRedundantTensorSubsetsOp :
#### Return modes:
- The operation always succeeds and returns a handle to the transformed
- function op.
+ The operation always succeeds and returns nothing.
}];
let arguments = (ins TransformHandleTypeInterface:$target);
- let results = (outs TransformHandleTypeInterface:$transformed);
+ let results = (outs);
- let assemblyFormat = "$target attr-dict `:` functional-type(operands, results) ";
+ let assemblyFormat = [{
+ $target
+ attr-dict
+ `:` functional-type(operands, results)
+ }];
- let builders = [
- OpBuilder<(ins "Value":$target)>,
- ];
let extraClassDeclaration = [{
::mlir::DiagnosedSilenceableFailure applyToOne(
::mlir::Operation *target,
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 8e667022966d0..1abbe16993821 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -3194,12 +3194,11 @@ DiagnosedSilenceableFailure
transform::HoistRedundantTensorSubsetsOp::applyToOne(
Operation *target, transform::ApplyToEachResultList &results,
transform::TransformState &state) {
- IRRewriter rewriter(target->getContext());
+ TrackingListener listener(state, *this);
+ IRRewriter rewriter(target->getContext(), &listener);
auto forOp = dyn_cast<scf::ForOp>(target);
if (forOp) {
- scf::ForOp newForOp =
- linalg::hoistRedundantSubsetExtractInsert(rewriter, forOp);
- results.push_back(newForOp);
+ linalg::hoistRedundantSubsetExtractInsert(rewriter, forOp);
return DiagnosedSilenceableFailure::success();
}
@@ -3208,10 +3207,15 @@ transform::HoistRedundantTensorSubsetsOp::applyToOne(
target->walk([&](scf::ForOp forOp) {
hoistRedundantSubsetExtractInsert(rewriter, forOp);
});
- results.push_back(target);
return DiagnosedSilenceableFailure::success();
}
+void transform::HoistRedundantTensorSubsetsOp::getEffects(
+ SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
+ transform::onlyReadsHandle(getTarget(), effects);
+ transform::modifiesPayload(effects);
+}
+
//===----------------------------------------------------------------------===//
// InsertSliceToCopyOp
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/Dialect/Linalg/hoisting.mlir b/mlir/test/Dialect/Linalg/hoisting.mlir
index d64b15ffdf8ad..02b03eeacc30a 100644
--- a/mlir/test/Dialect/Linalg/hoisting.mlir
+++ b/mlir/test/Dialect/Linalg/hoisting.mlir
@@ -302,7 +302,7 @@ transform.sequence failures(propagate) {
%0 = transform.structured.match ops{["func.func"]} in %arg1
: (!pdl.operation) -> !pdl.operation
transform.structured.hoist_redundant_tensor_subsets %0
- : (!pdl.operation) -> !pdl.operation
+ : (!pdl.operation) -> ()
}
// -----
@@ -397,7 +397,7 @@ transform.sequence failures(propagate) {
%0 = transform.structured.match ops{["func.func"]} in %arg1
: (!pdl.operation) -> !pdl.operation
transform.structured.hoist_redundant_tensor_subsets %0
- : (!pdl.operation) -> !pdl.operation
+ : (!pdl.operation) -> ()
}
// -----
@@ -514,7 +514,7 @@ transform.sequence failures(propagate) {
%0 = transform.structured.match ops{["func.func"]} in %arg1
: (!pdl.operation) -> !pdl.operation
transform.structured.hoist_redundant_tensor_subsets %0
- : (!pdl.operation) -> !pdl.operation
+ : (!pdl.operation) -> ()
}
// -----
@@ -561,7 +561,7 @@ transform.sequence failures(propagate) {
%0 = transform.structured.match ops{["func.func"]} in %arg1
: (!pdl.operation) -> !pdl.operation
transform.structured.hoist_redundant_tensor_subsets %0
- : (!pdl.operation) -> !pdl.operation
+ : (!pdl.operation) -> ()
}
// -----
@@ -674,7 +674,7 @@ transform.sequence failures(propagate) {
%0 = transform.structured.match ops{["func.func"]} in %arg1
: (!pdl.operation) -> !pdl.operation
transform.structured.hoist_redundant_tensor_subsets %0
- : (!pdl.operation) -> !pdl.operation
+ : (!pdl.operation) -> ()
}
// -----
More information about the Mlir-commits
mailing list