Skip to content

Commit 5f4af04

Browse files
kazutakahiratarorth
authored andcommitted
[mlir] Directly call ShapedType::isDynamic without lambdas (NFC) (llvm#142994)
We do not need lambdas in these places.
1 parent ca177a7 commit 5f4af04

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ def Bufferization_AllocTensorOp : Bufferization_Op<"alloc_tensor",
131131
assert(!getCopy() && "no dim sizes specified when copying a tensor");
132132
assert(isDynamicDim(idx) && "expected dynamic size");
133133
ArrayRef<int64_t> shape = getType().getShape();
134-
return std::count_if(
135-
shape.begin(), shape.begin() + idx,
136-
[&](int64_t size) { return ShapedType::isDynamic(size); });
134+
return std::count_if(shape.begin(), shape.begin() + idx,
135+
ShapedType::isDynamic);
137136
}
138137

139138
// Return the Value of the dynamic size of the tensor at dimension

mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,8 @@ class BubbleUpPackOpThroughReshapeOp final
876876
return failure();
877877
}
878878
// Currently only support static inner tile sizes.
879-
if (llvm::any_of(packOp.getStaticTiles(), [](int64_t size) {
880-
return ShapedType::isDynamic(size);
881-
})) {
879+
if (llvm::any_of(packOp.getStaticTiles(), ShapedType::isDynamic))
882880
return failure();
883-
}
884881

885882
// User controlled propagation function.
886883
if (!controlFn(&packOp.getSourceMutable()))
@@ -1002,11 +999,8 @@ class PushDownUnPackOpThroughReshapeOp final
1002999
return failure();
10031000
}
10041001
// Currently only support static inner tile sizes.
1005-
if (llvm::any_of(unPackOp.getStaticTiles(), [](int64_t size) {
1006-
return ShapedType::isDynamic(size);
1007-
})) {
1002+
if (llvm::any_of(unPackOp.getStaticTiles(), ShapedType::isDynamic))
10081003
return failure();
1009-
}
10101004

10111005
Operation *consumerOp = *result.user_begin();
10121006
return TypeSwitch<Operation *, LogicalResult>(consumerOp)

mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ FailureOr<LowerPackResult> linalg::lowerPack(RewriterBase &rewriter,
227227
// 1. Filter out NYI cases.
228228
auto packedTensorType =
229229
cast<RankedTensorType>(packOp->getResultTypes().front());
230-
if (llvm::any_of(packOp.getStaticInnerTiles(),
231-
[](int64_t size) { return ShapedType::isDynamic(size); })) {
230+
if (llvm::any_of(packOp.getStaticInnerTiles(), ShapedType::isDynamic)) {
232231
return rewriter.notifyMatchFailure(
233232
packOp,
234233
"non-static shape NYI, needs a more powerful tensor.expand_shape op");

mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,11 @@ struct BubbleUpExpandThroughParallelCollapse
185185
ArrayRef<int64_t> collapsedStaticShapes = staticSourceSize.slice(
186186
collapseReassociation.front(), collapseReassociation.size());
187187
int64_t numCollapsedDynamic =
188-
llvm::count_if(collapsedStaticShapes,
189-
[](int64_t d) { return ShapedType::isDynamic(d); });
188+
llvm::count_if(collapsedStaticShapes, ShapedType::isDynamic);
190189
ArrayRef<int64_t> expandedStaticShapes = staticResultSize.slice(
191190
expandReassociation.front(), expandReassociation.size());
192191
int64_t numExpandedDynamic =
193-
llvm::count_if(expandedStaticShapes,
194-
[](int64_t d) { return ShapedType::isDynamic(d); });
192+
llvm::count_if(expandedStaticShapes, ShapedType::isDynamic);
195193
if (numCollapsedDynamic > 1 || numExpandedDynamic > 1 ||
196194
collapsedStaticShapes != expandedStaticShapes) {
197195
return failure();

mlir/lib/Interfaces/ViewLikeInterface.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ LogicalResult mlir::verifyListOfOperandsOrIntegers(Operation *op,
2727
return op->emitError("expected ") << numElements << " " << name
2828
<< " values, got " << staticVals.size();
2929
unsigned expectedNumDynamicEntries =
30-
llvm::count_if(staticVals, [](int64_t staticVal) {
31-
return ShapedType::isDynamic(staticVal);
32-
});
30+
llvm::count_if(staticVals, ShapedType::isDynamic);
3331
if (values.size() != expectedNumDynamicEntries)
3432
return op->emitError("expected ")
3533
<< expectedNumDynamicEntries << " dynamic " << name << " values";
@@ -270,5 +268,5 @@ bool mlir::detail::sameOffsetsSizesAndStrides(
270268
unsigned mlir::detail::getNumDynamicEntriesUpToIdx(ArrayRef<int64_t> staticVals,
271269
unsigned idx) {
272270
return std::count_if(staticVals.begin(), staticVals.begin() + idx,
273-
[&](int64_t val) { return ShapedType::isDynamic(val); });
271+
ShapedType::isDynamic);
274272
}

0 commit comments

Comments
 (0)