Skip to content

Commit abc2c3a

Browse files
[mlir] Use llvm::is_contained instead of llvm::all_of (NFC) (#145845)
llvm::is_contained is shorter than llvm::all_of plus a lambda.
1 parent 3d5903c commit abc2c3a

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,7 @@ static bool isLoopInvariantIdx(LinalgOp &linalgOp, Value &val,
922922
// TODO: We could try analysing the corresponding affine map here.
923923
auto *block = linalgOp.getBlock();
924924
if (isa<BlockArgument>(val))
925-
return llvm::all_of(block->getArguments(),
926-
[&val](Value v) { return (v != val); });
925+
return !llvm::is_contained(block->getArguments(), val);
927926

928927
Operation *defOp = val.getDefiningOp();
929928
assert(defOp && "This is neither a block argument nor an operation result");
@@ -982,8 +981,7 @@ static bool isContiguousLoadIdx(LinalgOp &linalgOp, Value &val,
982981
// TODO: We could try analysing the corresponding affine map here.
983982
auto *block = linalgOp.getBlock();
984983
if (isa<BlockArgument>(val))
985-
return llvm::all_of(block->getArguments(),
986-
[&val](Value v) { return (v != val); });
984+
return !llvm::is_contained(block->getArguments(), val);
987985

988986
Operation *defOp = val.getDefiningOp();
989987
assert(defOp && "This is neither a block argument nor an operation result");

mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ std::pair<Operation *, Value> sparse_tensor::genCoIteration(
929929
ivs.push_back(uniIdx);
930930

931931
// Ensures all operands are valid.
932-
assert(llvm::all_of(ivs, [](Value v) { return v != nullptr; }));
932+
assert(!llvm::is_contained(ivs, nullptr));
933933
TypeRange types = ValueRange(ivs).getTypes();
934934
auto whileOp = builder.create<scf::WhileOp>(loc, types, ivs);
935935

mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ Value vector::createReadOrMaskedRead(OpBuilder &builder, Location loc,
321321
ArrayRef<int64_t> inputVectorSizes,
322322
Value padValue,
323323
bool useInBoundsInsteadOfMasking) {
324-
assert(llvm::none_of(inputVectorSizes,
325-
[](int64_t s) { return s == ShapedType::kDynamic; }) &&
324+
assert(!llvm::is_contained(inputVectorSizes, ShapedType::kDynamic) &&
326325
"invalid input vector sizes");
327326
auto sourceShapedType = cast<ShapedType>(source.getType());
328327
auto sourceShape = sourceShapedType.getShape();

mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,8 @@ void DefGen::createParentWithTraits() {
253253
// method.
254254
std::string opAsmInterfaceTraitName =
255255
strfmt("::mlir::OpAsm{0}Interface::Trait", defType);
256-
if (def.genMnemonicAlias() && llvm::none_of(traitNames, [&](auto &traitName) {
257-
return traitName == opAsmInterfaceTraitName;
258-
})) {
256+
if (def.genMnemonicAlias() &&
257+
!llvm::is_contained(traitNames, opAsmInterfaceTraitName)) {
259258
defParent.addTemplateParam(opAsmInterfaceTraitName);
260259
}
261260
defCls.addParent(std::move(defParent));

0 commit comments

Comments
 (0)