Skip to content

Commit 411dd47

Browse files
[mlir][Linalg] Make HoistRedundantTensorSubsetsOp not a FunctionalStyleTransformOpTrait
Differential Revision: https://reviews.llvm.org/D148350
1 parent 3163f7a commit 411dd47

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,9 @@ def ConvertConv2DToImg2ColOp : Op<Transform_Dialect,
19571957

19581958
def HoistRedundantTensorSubsetsOp :
19591959
Op<Transform_Dialect, "structured.hoist_redundant_tensor_subsets",
1960-
[FunctionalStyleTransformOpTrait, MemoryEffectsOpInterface,
1961-
TransformEachOpTrait, TransformOpInterface]> {
1960+
[DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
1961+
TransformEachOpTrait,
1962+
TransformOpInterface]> {
19621963
let description = [{
19631964
Hoists supported tensor subset extract/insert operation pairs out of
19641965
immediately enclosing loop iteratively, if the following conditions
@@ -1978,18 +1979,18 @@ def HoistRedundantTensorSubsetsOp :
19781979

19791980
#### Return modes:
19801981

1981-
The operation always succeeds and returns a handle to the transformed
1982-
function op.
1982+
The operation always succeeds and returns nothing.
19831983
}];
19841984

19851985
let arguments = (ins TransformHandleTypeInterface:$target);
1986-
let results = (outs TransformHandleTypeInterface:$transformed);
1986+
let results = (outs);
19871987

1988-
let assemblyFormat = "$target attr-dict `:` functional-type(operands, results) ";
1988+
let assemblyFormat = [{
1989+
$target
1990+
attr-dict
1991+
`:` functional-type(operands, results)
1992+
}];
19891993

1990-
let builders = [
1991-
OpBuilder<(ins "Value":$target)>,
1992-
];
19931994
let extraClassDeclaration = [{
19941995
::mlir::DiagnosedSilenceableFailure applyToOne(
19951996
::mlir::Operation *target,

mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,12 +3194,11 @@ DiagnosedSilenceableFailure
31943194
transform::HoistRedundantTensorSubsetsOp::applyToOne(
31953195
Operation *target, transform::ApplyToEachResultList &results,
31963196
transform::TransformState &state) {
3197-
IRRewriter rewriter(target->getContext());
3197+
TrackingListener listener(state, *this);
3198+
IRRewriter rewriter(target->getContext(), &listener);
31983199
auto forOp = dyn_cast<scf::ForOp>(target);
31993200
if (forOp) {
3200-
scf::ForOp newForOp =
3201-
linalg::hoistRedundantSubsetExtractInsert(rewriter, forOp);
3202-
results.push_back(newForOp);
3201+
linalg::hoistRedundantSubsetExtractInsert(rewriter, forOp);
32033202
return DiagnosedSilenceableFailure::success();
32043203
}
32053204

@@ -3208,10 +3207,15 @@ transform::HoistRedundantTensorSubsetsOp::applyToOne(
32083207
target->walk([&](scf::ForOp forOp) {
32093208
hoistRedundantSubsetExtractInsert(rewriter, forOp);
32103209
});
3211-
results.push_back(target);
32123210
return DiagnosedSilenceableFailure::success();
32133211
}
32143212

3213+
void transform::HoistRedundantTensorSubsetsOp::getEffects(
3214+
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
3215+
transform::onlyReadsHandle(getTarget(), effects);
3216+
transform::modifiesPayload(effects);
3217+
}
3218+
32153219
//===----------------------------------------------------------------------===//
32163220
// InsertSliceToCopyOp
32173221
//===----------------------------------------------------------------------===//

mlir/test/Dialect/Linalg/hoisting.mlir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ transform.sequence failures(propagate) {
302302
%0 = transform.structured.match ops{["func.func"]} in %arg1
303303
: (!pdl.operation) -> !pdl.operation
304304
transform.structured.hoist_redundant_tensor_subsets %0
305-
: (!pdl.operation) -> !pdl.operation
305+
: (!pdl.operation) -> ()
306306
}
307307

308308
// -----
@@ -397,7 +397,7 @@ transform.sequence failures(propagate) {
397397
%0 = transform.structured.match ops{["func.func"]} in %arg1
398398
: (!pdl.operation) -> !pdl.operation
399399
transform.structured.hoist_redundant_tensor_subsets %0
400-
: (!pdl.operation) -> !pdl.operation
400+
: (!pdl.operation) -> ()
401401
}
402402

403403
// -----
@@ -514,7 +514,7 @@ transform.sequence failures(propagate) {
514514
%0 = transform.structured.match ops{["func.func"]} in %arg1
515515
: (!pdl.operation) -> !pdl.operation
516516
transform.structured.hoist_redundant_tensor_subsets %0
517-
: (!pdl.operation) -> !pdl.operation
517+
: (!pdl.operation) -> ()
518518
}
519519

520520
// -----
@@ -561,7 +561,7 @@ transform.sequence failures(propagate) {
561561
%0 = transform.structured.match ops{["func.func"]} in %arg1
562562
: (!pdl.operation) -> !pdl.operation
563563
transform.structured.hoist_redundant_tensor_subsets %0
564-
: (!pdl.operation) -> !pdl.operation
564+
: (!pdl.operation) -> ()
565565
}
566566

567567
// -----
@@ -674,7 +674,7 @@ transform.sequence failures(propagate) {
674674
%0 = transform.structured.match ops{["func.func"]} in %arg1
675675
: (!pdl.operation) -> !pdl.operation
676676
transform.structured.hoist_redundant_tensor_subsets %0
677-
: (!pdl.operation) -> !pdl.operation
677+
: (!pdl.operation) -> ()
678678
}
679679

680680
// -----

0 commit comments

Comments
 (0)