diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp index 5291f95d37144..cdbcd3013e139 100644 --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -701,9 +701,9 @@ computeTargetSize(PatternRewriter &rewriter, Location loc, IndexPool &indexPool, // Filter operands with dynamic dimension auto operandsWithDynamicDim = - llvm::to_vector(llvm::make_filter_range(operands, [&](Value operand) { + llvm::filter_to_vector(operands, [&](Value operand) { return cast(operand.getType()).isDynamicDim(dim); - })); + }); // If no operand has a dynamic dimension, it means all sizes were 1 if (operandsWithDynamicDim.empty()) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMInterfaces.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMInterfaces.cpp index a59900745d026..ca1277c09323b 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMInterfaces.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMInterfaces.cpp @@ -99,10 +99,9 @@ SmallVector mlir::LLVM::MemsetInlineOp::getAccessedOperands() { } SmallVector mlir::LLVM::CallOp::getAccessedOperands() { - return llvm::to_vector( - llvm::make_filter_range(getArgOperands(), [](Value arg) { - return isa(arg.getType()); - })); + return llvm::filter_to_vector(getArgOperands(), [](Value arg) { + return isa(arg.getType()); + }); } #include "mlir/Dialect/LLVMIR/LLVMInterfaces.cpp.inc" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index 31f37334ce397..61bab2ed67530 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -375,10 +375,8 @@ static void calculateTileOffsetsAndSizes( b.setInsertionPointToStart(forallOp.getBody(0)); SmallVector threadIds = forallOp.getInductionVars(); - SmallVector nonZeroNumThreads = - llvm::to_vector(llvm::make_filter_range(numThreads, [](OpFoldResult ofr) { - return !isConstantIntValue(ofr, 0); - })); + SmallVector nonZeroNumThreads = llvm::filter_to_vector( + numThreads, [](OpFoldResult ofr) { return !isConstantIntValue(ofr, 0); }); int64_t nLoops = loopRanges.size(); tiledOffsets.reserve(nLoops); tiledSizes.reserve(nLoops); @@ -656,10 +654,8 @@ FailureOr linalg::tileReductionUsingForall( Operation *tiledOp = nullptr; - SmallVector nonZeroNumThreads = - llvm::to_vector(llvm::make_filter_range(numThreads, [](OpFoldResult ofr) { - return !isConstantIntValue(ofr, 0); - })); + SmallVector nonZeroNumThreads = llvm::filter_to_vector( + numThreads, [](OpFoldResult ofr) { return !isConstantIntValue(ofr, 0); }); SmallVector materializedNonZeroNumThreads = getValueOrCreateConstantIndexOp(b, loc, nonZeroNumThreads); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp index d92543d726462..e0319b5b38aad 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @@ -1090,8 +1090,8 @@ getPackUnpackNormalizedPerm(int rank, ArrayRef perm) { SmallVector vec(rank, kNonTiledMarker); for (auto [index, value] : llvm::enumerate(perm)) vec[value] = index; - SmallVector normalizedPerm = llvm::to_vector(llvm::make_filter_range( - vec, [&](int64_t v) { return v != kNonTiledMarker; })); + SmallVector normalizedPerm = llvm::filter_to_vector( + vec, [&](int64_t v) { return v != kNonTiledMarker; }); // This inverts the permutation in addition to normalizing so invert back. return invertPermutationVector(normalizedPerm); } diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 8eb8e579954fa..bebfaa8c1ea82 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -695,8 +695,8 @@ struct RemoveEmptyShapeOperandsPattern : public OpRewritePattern { } return true; }; - auto newOperands = llvm::to_vector<8>( - llvm::make_filter_range(op->getOperands(), isPotentiallyNonEmptyShape)); + auto newOperands = llvm::filter_to_vector<8>(op->getOperands(), + isPotentiallyNonEmptyShape); // Reduce op to equivalent without empty shape operands. if (newOperands.size() < op.getNumOperands()) { diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 3272ece65ba53..fe0fee0f8db2c 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -1309,10 +1309,10 @@ LogicalResult OpTrait::impl::verifyNoRegionArguments(Operation *op) { LogicalResult OpTrait::impl::verifyElementwise(Operation *op) { auto isMappableType = llvm::IsaPred; - auto resultMappableTypes = llvm::to_vector<1>( - llvm::make_filter_range(op->getResultTypes(), isMappableType)); - auto operandMappableTypes = llvm::to_vector<2>( - llvm::make_filter_range(op->getOperandTypes(), isMappableType)); + auto resultMappableTypes = + llvm::filter_to_vector<1>(op->getResultTypes(), isMappableType); + auto operandMappableTypes = + llvm::filter_to_vector<2>(op->getOperandTypes(), isMappableType); // If the op only has scalar operand/result types, then we have nothing to // check. diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp index e569d440ca95c..ec646cad841ae 100644 --- a/mlir/lib/IR/TypeUtilities.cpp +++ b/mlir/lib/IR/TypeUtilities.cpp @@ -141,8 +141,8 @@ LogicalResult mlir::verifyCompatibleShapes(TypeRange types) { } // Remove all unranked shapes - auto shapes = llvm::to_vector<8>(llvm::make_filter_range( - shapedTypes, [](auto shapedType) { return shapedType.hasRank(); })); + auto shapes = llvm::filter_to_vector<8>( + shapedTypes, [](auto shapedType) { return shapedType.hasRank(); }); if (shapes.empty()) return success(); diff --git a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp index 9469780129d64..1c661e3beea48 100644 --- a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp +++ b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp @@ -304,11 +304,11 @@ mlir::detail::getDevicePropertyValue(DataLayoutEntryInterface entry) { DataLayoutEntryList mlir::detail::filterEntriesForType(DataLayoutEntryListRef entries, TypeID typeID) { - return llvm::to_vector<4>(llvm::make_filter_range( + return llvm::filter_to_vector<4>( entries, [typeID](DataLayoutEntryInterface entry) { auto type = llvm::dyn_cast_if_present(entry.getKey()); return type && type.getTypeID() == typeID; - })); + }); } DataLayoutEntryInterface @@ -393,9 +393,9 @@ static DataLayoutSpecInterface getCombinedDataLayout(Operation *leaf) { // Create the list of non-null specs (null/missing specs can be safely // ignored) from the outermost to the innermost. - auto nonNullSpecs = llvm::to_vector<2>(llvm::make_filter_range( + auto nonNullSpecs = llvm::filter_to_vector<2>( llvm::reverse(specs), - [](DataLayoutSpecInterface iface) { return iface != nullptr; })); + [](DataLayoutSpecInterface iface) { return iface != nullptr; }); // Combine the specs using the innermost as anchor. if (DataLayoutSpecInterface current = getSpec(leaf)) diff --git a/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp b/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp index d7967c7a77534..da28ca3a7eba9 100644 --- a/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp +++ b/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp @@ -10,6 +10,7 @@ #include "mlir/TableGen/GenInfo.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVectorExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/TableGen/Error.h" @@ -161,13 +162,12 @@ void printParseConditional(mlir::raw_indented_ostream &ios, return formatv("read{0}", capitalize(name)); }; - auto parsedArgs = - llvm::to_vector(make_filter_range(args, [](const Init *const attr) { - const Record *def = cast(attr)->getDef(); - if (def->isSubClassOf("Array")) - return true; - return !def->getValueAsString("cParser").empty(); - })); + auto parsedArgs = llvm::filter_to_vector(args, [](const Init *const attr) { + const Record *def = cast(attr)->getDef(); + if (def->isSubClassOf("Array")) + return true; + return !def->getValueAsString("cParser").empty(); + }); interleave( zip(parsedArgs, argNames), @@ -277,8 +277,8 @@ void Generator::emitParseHelper(StringRef kind, StringRef returnType, printParseConditional(ios, args, argNames); // Compute args to pass to create method. - auto passedArgs = llvm::to_vector(make_filter_range( - argNames, [](StringRef str) { return !str.starts_with("_"); })); + auto passedArgs = llvm::filter_to_vector( + argNames, [](StringRef str) { return !str.starts_with("_"); }); std::string argStr; raw_string_ostream argStream(argStr); interleaveComma(passedArgs, argStream,