Skip to content

[mlir] Directly call ShapedType::isDynamic without lambdas (NFC) #142994

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ def Bufferization_AllocTensorOp : Bufferization_Op<"alloc_tensor",
assert(!getCopy() && "no dim sizes specified when copying a tensor");
assert(isDynamicDim(idx) && "expected dynamic size");
ArrayRef<int64_t> shape = getType().getShape();
return std::count_if(
shape.begin(), shape.begin() + idx,
[&](int64_t size) { return ShapedType::isDynamic(size); });
return std::count_if(shape.begin(), shape.begin() + idx,
ShapedType::isDynamic);
}

// Return the Value of the dynamic size of the tensor at dimension
Expand Down
10 changes: 2 additions & 8 deletions mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,8 @@ class BubbleUpPackOpThroughReshapeOp final
return failure();
}
// Currently only support static inner tile sizes.
if (llvm::any_of(packOp.getStaticTiles(), [](int64_t size) {
return ShapedType::isDynamic(size);
})) {
if (llvm::any_of(packOp.getStaticTiles(), ShapedType::isDynamic))
return failure();
}

// User controlled propagation function.
if (!controlFn(&packOp.getSourceMutable()))
Expand Down Expand Up @@ -1002,11 +999,8 @@ class PushDownUnPackOpThroughReshapeOp final
return failure();
}
// Currently only support static inner tile sizes.
if (llvm::any_of(unPackOp.getStaticTiles(), [](int64_t size) {
return ShapedType::isDynamic(size);
})) {
if (llvm::any_of(unPackOp.getStaticTiles(), ShapedType::isDynamic))
return failure();
}

Operation *consumerOp = *result.user_begin();
return TypeSwitch<Operation *, LogicalResult>(consumerOp)
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ FailureOr<LowerPackResult> linalg::lowerPack(RewriterBase &rewriter,
// 1. Filter out NYI cases.
auto packedTensorType =
cast<RankedTensorType>(packOp->getResultTypes().front());
if (llvm::any_of(packOp.getStaticInnerTiles(),
[](int64_t size) { return ShapedType::isDynamic(size); })) {
if (llvm::any_of(packOp.getStaticInnerTiles(), ShapedType::isDynamic)) {
return rewriter.notifyMatchFailure(
packOp,
"non-static shape NYI, needs a more powerful tensor.expand_shape op");
Expand Down
6 changes: 2 additions & 4 deletions mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,11 @@ struct BubbleUpExpandThroughParallelCollapse
ArrayRef<int64_t> collapsedStaticShapes = staticSourceSize.slice(
collapseReassociation.front(), collapseReassociation.size());
int64_t numCollapsedDynamic =
llvm::count_if(collapsedStaticShapes,
[](int64_t d) { return ShapedType::isDynamic(d); });
llvm::count_if(collapsedStaticShapes, ShapedType::isDynamic);
ArrayRef<int64_t> expandedStaticShapes = staticResultSize.slice(
expandReassociation.front(), expandReassociation.size());
int64_t numExpandedDynamic =
llvm::count_if(expandedStaticShapes,
[](int64_t d) { return ShapedType::isDynamic(d); });
llvm::count_if(expandedStaticShapes, ShapedType::isDynamic);
if (numCollapsedDynamic > 1 || numExpandedDynamic > 1 ||
collapsedStaticShapes != expandedStaticShapes) {
return failure();
Expand Down
6 changes: 2 additions & 4 deletions mlir/lib/Interfaces/ViewLikeInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ LogicalResult mlir::verifyListOfOperandsOrIntegers(Operation *op,
return op->emitError("expected ") << numElements << " " << name
<< " values, got " << staticVals.size();
unsigned expectedNumDynamicEntries =
llvm::count_if(staticVals, [](int64_t staticVal) {
return ShapedType::isDynamic(staticVal);
});
llvm::count_if(staticVals, ShapedType::isDynamic);
if (values.size() != expectedNumDynamicEntries)
return op->emitError("expected ")
<< expectedNumDynamicEntries << " dynamic " << name << " values";
Expand Down Expand Up @@ -270,5 +268,5 @@ bool mlir::detail::sameOffsetsSizesAndStrides(
unsigned mlir::detail::getNumDynamicEntriesUpToIdx(ArrayRef<int64_t> staticVals,
unsigned idx) {
return std::count_if(staticVals.begin(), staticVals.begin() + idx,
[&](int64_t val) { return ShapedType::isDynamic(val); });
ShapedType::isDynamic);
}
Loading