-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir] Use llvm::is_contained instead of llvm::all_of (NFC) #145845
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
[mlir] Use llvm::is_contained instead of llvm::all_of (NFC) #145845
Conversation
llvm::is_contained is shorter than llvm::all_of plus a lambda.
@llvm/pr-subscribers-mlir-sparse @llvm/pr-subscribers-mlir-linalg Author: Kazu Hirata (kazutakahirata) Changesllvm::is_contained is shorter than llvm::all_of plus a lambda. Full diff: https://github.com/llvm/llvm-project/pull/145845.diff 4 Files Affected:
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index e6a19fb5f57be..830ae5414c6bd 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -922,8 +922,7 @@ static bool isLoopInvariantIdx(LinalgOp &linalgOp, Value &val,
// TODO: We could try analysing the corresponding affine map here.
auto *block = linalgOp.getBlock();
if (isa<BlockArgument>(val))
- return llvm::all_of(block->getArguments(),
- [&val](Value v) { return (v != val); });
+ return !llvm::is_contained(block->getArguments(), val);
Operation *defOp = val.getDefiningOp();
assert(defOp && "This is neither a block argument nor an operation result");
@@ -982,8 +981,7 @@ static bool isContiguousLoadIdx(LinalgOp &linalgOp, Value &val,
// TODO: We could try analysing the corresponding affine map here.
auto *block = linalgOp.getBlock();
if (isa<BlockArgument>(val))
- return llvm::all_of(block->getArguments(),
- [&val](Value v) { return (v != val); });
+ return !llvm::is_contained(block->getArguments(), val);
Operation *defOp = val.getDefiningOp();
assert(defOp && "This is neither a block argument nor an operation result");
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
index 84129edee3753..9e41c8ec19bcd 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
@@ -929,7 +929,7 @@ std::pair<Operation *, Value> sparse_tensor::genCoIteration(
ivs.push_back(uniIdx);
// Ensures all operands are valid.
- assert(llvm::all_of(ivs, [](Value v) { return v != nullptr; }));
+ assert(!llvm::is_contained(ivs, nullptr));
TypeRange types = ValueRange(ivs).getTypes();
auto whileOp = builder.create<scf::WhileOp>(loc, types, ivs);
diff --git a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
index 0c7cfc13f87da..674a93d7c520e 100644
--- a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
+++ b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
@@ -321,8 +321,7 @@ Value vector::createReadOrMaskedRead(OpBuilder &builder, Location loc,
ArrayRef<int64_t> inputVectorSizes,
Value padValue,
bool useInBoundsInsteadOfMasking) {
- assert(llvm::none_of(inputVectorSizes,
- [](int64_t s) { return s == ShapedType::kDynamic; }) &&
+ assert(!llvm::is_contained(inputVectorSizes, ShapedType::kDynamic) &&
"invalid input vector sizes");
auto sourceShapedType = cast<ShapedType>(source.getType());
auto sourceShape = sourceShapedType.getShape();
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index defd1fa12ca1a..728a9819ca0d1 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -253,9 +253,8 @@ void DefGen::createParentWithTraits() {
// method.
std::string opAsmInterfaceTraitName =
strfmt("::mlir::OpAsm{0}Interface::Trait", defType);
- if (def.genMnemonicAlias() && llvm::none_of(traitNames, [&](auto &traitName) {
- return traitName == opAsmInterfaceTraitName;
- })) {
+ if (def.genMnemonicAlias() &&
+ !llvm::is_contained(traitNames, opAsmInterfaceTraitName)) {
defParent.addTemplateParam(opAsmInterfaceTraitName);
}
defCls.addParent(std::move(defParent));
|
@llvm/pr-subscribers-mlir-vector Author: Kazu Hirata (kazutakahirata) Changesllvm::is_contained is shorter than llvm::all_of plus a lambda. Full diff: https://github.com/llvm/llvm-project/pull/145845.diff 4 Files Affected:
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index e6a19fb5f57be..830ae5414c6bd 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -922,8 +922,7 @@ static bool isLoopInvariantIdx(LinalgOp &linalgOp, Value &val,
// TODO: We could try analysing the corresponding affine map here.
auto *block = linalgOp.getBlock();
if (isa<BlockArgument>(val))
- return llvm::all_of(block->getArguments(),
- [&val](Value v) { return (v != val); });
+ return !llvm::is_contained(block->getArguments(), val);
Operation *defOp = val.getDefiningOp();
assert(defOp && "This is neither a block argument nor an operation result");
@@ -982,8 +981,7 @@ static bool isContiguousLoadIdx(LinalgOp &linalgOp, Value &val,
// TODO: We could try analysing the corresponding affine map here.
auto *block = linalgOp.getBlock();
if (isa<BlockArgument>(val))
- return llvm::all_of(block->getArguments(),
- [&val](Value v) { return (v != val); });
+ return !llvm::is_contained(block->getArguments(), val);
Operation *defOp = val.getDefiningOp();
assert(defOp && "This is neither a block argument nor an operation result");
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
index 84129edee3753..9e41c8ec19bcd 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp
@@ -929,7 +929,7 @@ std::pair<Operation *, Value> sparse_tensor::genCoIteration(
ivs.push_back(uniIdx);
// Ensures all operands are valid.
- assert(llvm::all_of(ivs, [](Value v) { return v != nullptr; }));
+ assert(!llvm::is_contained(ivs, nullptr));
TypeRange types = ValueRange(ivs).getTypes();
auto whileOp = builder.create<scf::WhileOp>(loc, types, ivs);
diff --git a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
index 0c7cfc13f87da..674a93d7c520e 100644
--- a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
+++ b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
@@ -321,8 +321,7 @@ Value vector::createReadOrMaskedRead(OpBuilder &builder, Location loc,
ArrayRef<int64_t> inputVectorSizes,
Value padValue,
bool useInBoundsInsteadOfMasking) {
- assert(llvm::none_of(inputVectorSizes,
- [](int64_t s) { return s == ShapedType::kDynamic; }) &&
+ assert(!llvm::is_contained(inputVectorSizes, ShapedType::kDynamic) &&
"invalid input vector sizes");
auto sourceShapedType = cast<ShapedType>(source.getType());
auto sourceShape = sourceShapedType.getShape();
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index defd1fa12ca1a..728a9819ca0d1 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -253,9 +253,8 @@ void DefGen::createParentWithTraits() {
// method.
std::string opAsmInterfaceTraitName =
strfmt("::mlir::OpAsm{0}Interface::Trait", defType);
- if (def.genMnemonicAlias() && llvm::none_of(traitNames, [&](auto &traitName) {
- return traitName == opAsmInterfaceTraitName;
- })) {
+ if (def.genMnemonicAlias() &&
+ !llvm::is_contained(traitNames, opAsmInterfaceTraitName)) {
defParent.addTemplateParam(opAsmInterfaceTraitName);
}
defCls.addParent(std::move(defParent));
|
llvm::is_contained is shorter than llvm::all_of plus a lambda.