diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -2064,9 +2064,10 @@ // 1) all operands involved are of shaped type and // 2) the indices are not out of range. class TCopVTEtAreSameAt indices> : CPred< - "llvm::is_splat(mlir::functional::map(" - "[this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); }, " - "llvm::ArrayRef({" # StrJoinInt.result # "})))">; + "llvm::is_splat(llvm::map_range(" + "llvm::ArrayRef({" # StrJoinInt.result # "}), " + "[this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); " + "}))">; //===----------------------------------------------------------------------===// // Pattern definitions diff --git a/mlir/include/mlir/Support/Functional.h b/mlir/include/mlir/Support/Functional.h deleted file mode 100644 --- a/mlir/include/mlir/Support/Functional.h +++ /dev/null @@ -1,113 +0,0 @@ -//===- Functional.h - Helpers for functional-style Combinators --*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef MLIR_SUPPORT_FUNCTIONAL_H_ -#define MLIR_SUPPORT_FUNCTIONAL_H_ - -#include "mlir/Support/LLVM.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/Casting.h" - -/// This file provides some simple template functional-style sugar to operate -/// on **value** types. Make sure when using that the stored type is cheap to -/// copy! -/// -/// TODO(ntv): add some static_assert but we need proper traits for this. - -namespace mlir { -namespace functional { - -/// Map with iterators. -template -auto map(Fn fun, IterType begin, IterType end) - -> SmallVector::type, 8> { - using R = typename std::result_of::type; - SmallVector res; - // auto i works with both pointer types and value types with an operator*. - // auto *i only works for pointer types. - for (auto i = begin; i != end; ++i) { - res.push_back(fun(*i)); - } - return res; -} - -/// Map with templated container. -template -auto map(Fn fun, ContainerType input) - -> decltype(map(fun, std::begin(input), std::end(input))) { - return map(fun, std::begin(input), std::end(input)); -} - -/// Zip map with 2 templated container, iterates to the min of the sizes of -/// the 2 containers. -/// TODO(ntv): make variadic when needed. -template -auto zipMap(Fn fun, ContainerType1 input1, ContainerType2 input2) - -> SmallVector::type, - 8> { - using R = typename std::result_of::type; - SmallVector res; - auto zipIter = llvm::zip(input1, input2); - for (auto it : zipIter) { - res.push_back(fun(std::get<0>(it), std::get<1>(it))); - } - return res; -} - -/// Apply with iterators. -template -void apply(Fn fun, IterType begin, IterType end) { - // auto i works with both pointer types and value types with an operator*. - // auto *i only works for pointer types. - for (auto i = begin; i != end; ++i) { - fun(*i); - } -} - -/// Apply with templated container. -template -void apply(Fn fun, ContainerType input) { - return apply(fun, std::begin(input), std::end(input)); -} - -/// Zip apply with 2 templated container, iterates to the min of the sizes of -/// the 2 containers. -/// TODO(ntv): make variadic when needed. -template -void zipApply(Fn fun, ContainerType1 input1, ContainerType2 input2) { - auto zipIter = llvm::zip(input1, input2); - for (auto it : zipIter) { - fun(std::get<0>(it), std::get<1>(it)); - } -} - -/// Unwraps a pointer type to another type (possibly the same). -/// Used in particular to allow easier compositions of -/// Operation::operand_range types. -template -inline std::function makePtrDynCaster() { - return [](T *val) { return dyn_cast(val); }; -} - -/// Simple ScopeGuard. -struct ScopeGuard { - explicit ScopeGuard(std::function destruct) - : destruct(destruct) {} - ~ScopeGuard() { destruct(); } - -private: - std::function destruct; -}; - -} // namespace functional -} // namespace mlir - -#endif // MLIR_SUPPORT_FUNCTIONAL_H_ diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp --- a/mlir/lib/Analysis/SliceAnalysis.cpp +++ b/mlir/lib/Analysis/SliceAnalysis.cpp @@ -15,7 +15,6 @@ #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/IR/Function.h" #include "mlir/IR/Operation.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -23,7 +23,6 @@ #include "mlir/IR/IntegerSet.h" #include "mlir/IR/MLIRContext.h" #include "mlir/Pass/Pass.h" -#include "mlir/Support/Functional.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/Passes.h" @@ -222,13 +221,13 @@ AffineMap affineMap, ValueRange operands) { auto numDims = affineMap.getNumDims(); - auto expanded = functional::map( - [numDims, &builder, loc, operands](AffineExpr expr) { - return expandAffineExpr(builder, loc, expr, - operands.take_front(numDims), - operands.drop_front(numDims)); - }, - affineMap.getResults()); + auto expanded = llvm::to_vector<8>( + llvm::map_range(affineMap.getResults(), + [numDims, &builder, loc, operands](AffineExpr expr) { + return expandAffineExpr(builder, loc, expr, + operands.take_front(numDims), + operands.drop_front(numDims)); + })); if (llvm::all_of(expanded, [](Value v) { return v; })) return expanded; return None; diff --git a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp --- a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp +++ b/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp @@ -20,7 +20,6 @@ #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Module.h" #include "mlir/IR/PatternMatch.h" -#include "mlir/Support/Functional.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/Passes.h" #include "mlir/Transforms/Utils.h" diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -23,7 +23,6 @@ #include "mlir/IR/Module.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp --- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp @@ -25,7 +25,6 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/Location.h" #include "mlir/IR/Types.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Transforms/FoldUtils.h" @@ -525,8 +524,6 @@ #define DEBUG_TYPE "early-vect" -using functional::makePtrDynCaster; -using functional::map; using llvm::dbgs; using llvm::SetVector; @@ -812,7 +809,6 @@ /// operations into the appropriate vector.transfer. static LogicalResult vectorizeAffineForOp(AffineForOp loop, int64_t step, VectorizationState *state) { - using namespace functional; loop.setStep(step); FilterFunctionType notVectorizedThisPattern = [state](Operation &op) { diff --git a/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp b/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp --- a/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/MemoryPromotion.cpp @@ -16,7 +16,6 @@ #include "mlir/Dialect/LoopOps/EDSC/Builders.h" #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/Pass/Pass.h" -#include "mlir/Support/Functional.h" #include "mlir/Transforms/LoopUtils.h" using namespace mlir; diff --git a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp --- a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp @@ -13,7 +13,6 @@ #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h" #include "mlir/Dialect/Utils/StructuredOpsUtils.h" #include "mlir/IR/AffineExpr.h" -#include "mlir/Support/Functional.h" using namespace mlir; using namespace mlir::edsc; @@ -164,7 +163,8 @@ std::copy_if(outputs.begin(), outputs.end(), std::back_inserter(types), [](StructuredIndexed s) { return !s.hasValue(); }); - auto iteratorStrTypes = functional::map(toString, iteratorTypes); + auto iteratorStrTypes = + llvm::to_vector<8>(llvm::map_range(iteratorTypes, toString)); // clang-format off auto *op = edsc::ScopedContext::getBuilder() diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -21,7 +21,6 @@ #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" @@ -500,8 +499,8 @@ /// TODO(rridle,ntv) this should be evolved into a generic /// `getRangeOfType(ArrayAttr attrs)` that does not copy. static SmallVector getAffineMaps(ArrayAttr attrs) { - return functional::map( - [](Attribute a) { return a.cast().getValue(); }, attrs); + return llvm::to_vector<8>(llvm::map_range( + attrs, [](Attribute a) { return a.cast().getValue(); })); } template diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -19,7 +19,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineMap.h" #include "mlir/IR/BlockAndValueMapping.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" #include "mlir/Transforms/DialectConversion.h" @@ -113,8 +112,8 @@ auto &b = ScopedContext::getBuilder(); auto loc = ScopedContext::getLocation(); auto mapsRange = op.indexing_maps().template getAsRange(); - auto maps = - functional::map([](AffineMapAttr a) { return a.getValue(); }, mapsRange); + auto maps = llvm::to_vector<8>( + llvm::map_range(mapsRange, [](AffineMapAttr a) { return a.getValue(); })); SmallVector iIdx( makeCanonicalAffineApplies(b, loc, maps[0], allIvs)); SmallVector oIdx( @@ -273,8 +272,8 @@ auto b = ScopedContext::getBuilder(); auto loc = ScopedContext::getLocation(); auto mapsRange = convOp.indexing_maps().getAsRange(); - auto maps = functional::map([](AffineMapAttr a) { return a.getValue(); }, - mapsRange); + auto maps = llvm::to_vector<8>(llvm::map_range( + mapsRange, [](AffineMapAttr a) { return a.getValue(); })); SmallVector fIdx( makeCanonicalAffineApplies(b, loc, maps[0], allIvs)); SmallVector imIdx( @@ -650,8 +649,8 @@ auto nLoops = nPar + nRed + nWin; auto mapsRange = linalgOp.indexing_maps().template getAsRange(); - auto maps = - functional::map([](AffineMapAttr a) { return a.getValue(); }, mapsRange); + auto maps = llvm::to_vector<8>( + llvm::map_range(mapsRange, [](AffineMapAttr a) { return a.getValue(); })); AffineMap invertedMap = inversePermutation(concatAffineMaps(maps)); if (invertedMap.isEmpty()) { LinalgScopedEmitter::emitScalarImplementation( diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -21,7 +21,6 @@ #include "mlir/IR/AffineExpr.h" #include "mlir/IR/AffineExprVisitor.h" #include "mlir/IR/AffineMap.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/STLExtras.h" #include "mlir/Transforms/FoldUtils.h" @@ -359,8 +358,8 @@ // The flattened loopToOperandRangesMaps is expected to be an invertible // permutation map (asserted in the inverse calculation). auto mapsRange = op.indexing_maps().getAsRange(); - auto maps = - functional::map([](AffineMapAttr a) { return a.getValue(); }, mapsRange); + auto maps = llvm::to_vector<8>( + llvm::map_range(mapsRange, [](AffineMapAttr a) { return a.getValue(); })); auto viewSizesToLoopsMap = inversePermutation(concatAffineMaps(maps)); assert(viewSizesToLoopsMap && "expected invertible map"); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp @@ -17,7 +17,6 @@ #include "mlir/Dialect/SPIRV/SPIRVTypes.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/PatternMatch.h" -#include "mlir/Support/Functional.h" using namespace mlir; @@ -131,11 +130,10 @@ OpFoldResult spirv::CompositeExtractOp::fold(ArrayRef operands) { assert(operands.size() == 1 && "spv.CompositeExtract expects one operand"); - auto indexVector = functional::map( - [](Attribute attr) { + auto indexVector = + llvm::to_vector<8>(llvm::map_range(indices(), [](Attribute attr) { return static_cast(attr.cast().getInt()); - }, - indices()); + })); return extractCompositeElement(operands[0], indexVector); } diff --git a/mlir/lib/Dialect/Vector/EDSC/Builders.cpp b/mlir/lib/Dialect/Vector/EDSC/Builders.cpp --- a/mlir/lib/Dialect/Vector/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Vector/EDSC/Builders.cpp @@ -13,7 +13,6 @@ #include "mlir/EDSC/Intrinsics.h" #include "mlir/IR/AffineExpr.h" #include "mlir/IR/Builders.h" -#include "mlir/Support/Functional.h" using namespace mlir; using namespace mlir::edsc; @@ -27,7 +26,8 @@ return vector_contract( A.getValue(), B.getValue(), C.getValue(), IndexingExprs{A.getExprs(), B.getExprs(), C.getExprs()}, - ArrayRef{functional::map(toString, iteratorTypes)}); + ArrayRef{ + llvm::to_vector<8>(llvm::map_range(iteratorTypes, toString))}); } Value mlir::edsc::ops::vector_contraction_matmul(Value A, Value B, Value C) { diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -21,7 +21,6 @@ #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/MathExtras.h" #include "mlir/Support/STLExtras.h" @@ -893,12 +892,10 @@ static ArrayAttr makeI64ArrayAttr(ArrayRef values, MLIRContext *context) { - auto attrs = functional::map( - [context](int64_t v) -> Attribute { - return IntegerAttr::get(IntegerType::get(64, context), APInt(64, v)); - }, - values); - return ArrayAttr::get(attrs, context); + auto attrs = llvm::map_range(values, [context](int64_t v) -> Attribute { + return IntegerAttr::get(IntegerType::get(64, context), APInt(64, v)); + }); + return ArrayAttr::get(llvm::to_vector<8>(attrs), context); } static LogicalResult verify(InsertStridedSliceOp op) { diff --git a/mlir/lib/Dialect/Vector/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/VectorTransforms.cpp --- a/mlir/lib/Dialect/Vector/VectorTransforms.cpp +++ b/mlir/lib/Dialect/Vector/VectorTransforms.cpp @@ -29,7 +29,6 @@ #include "mlir/IR/OperationSupport.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/Types.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/STLExtras.h" #include "llvm/Support/CommandLine.h" @@ -40,7 +39,6 @@ using namespace mlir; using llvm::dbgs; -using mlir::functional::zipMap; /// Given a shape with sizes greater than 0 along all dimensions, /// returns the distance, in number of elements, between a slice in a dimension @@ -774,19 +772,15 @@ int i = sourceVectorRank - 1; int j = resultVectorRank - 1; - // Check that source/result vector shape prefixes match while - // updating 'newOffsets'. - bool canShapeCastFold = true; + // Check that source/result vector shape prefixes match while updating + // 'newOffsets'. SmallVector newOffsets(sourceVectorRank, 0); - - auto apply = [&](int64_t sourceSize, int64_t resultSize) { - canShapeCastFold = sourceSize == resultSize; + for (auto it : llvm::zip(llvm::reverse(sourceVectorShape), + llvm::reverse(resultVectorShape))) { + if (std::get<0>(it) != std::get<1>(it)) + return nullptr; newOffsets[i--] = offsets[j--]; - }; - functional::zipApply(apply, llvm::reverse(sourceVectorShape), - llvm::reverse(resultVectorShape)); - if (!canShapeCastFold) - return nullptr; + } // Check that remaining prefix of source/result vector shapes are all 1s. // Currently we only support producer/consumer tracking through trivial diff --git a/mlir/lib/Dialect/Vector/VectorUtils.cpp b/mlir/lib/Dialect/Vector/VectorUtils.cpp --- a/mlir/lib/Dialect/Vector/VectorUtils.cpp +++ b/mlir/lib/Dialect/Vector/VectorUtils.cpp @@ -18,7 +18,6 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/IntegerSet.h" #include "mlir/IR/Operation.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LLVM.h" #include "mlir/Support/MathExtras.h" #include "mlir/Support/STLExtras.h" @@ -67,8 +66,10 @@ SmallVector mlir::computeElementOffsetsFromVectorSliceOffsets( ArrayRef sizes, ArrayRef vectorOffsets) { - return functional::zipMap([](int64_t v1, int64_t v2) { return v1 * v2; }, - vectorOffsets, sizes); + SmallVector result; + for (auto it : llvm::zip(vectorOffsets, sizes)) + result.push_back(std::get<0>(it) * std::get<1>(it)); + return result; } SmallVector @@ -88,23 +89,19 @@ } // Starting from the end, compute the integer divisors. - // Set the boolean `divides` if integral division is not possible. std::vector result; result.reserve(superShape.size()); - bool divides = true; - auto divide = [÷s, &result](int superSize, int subSize) { + int64_t superSize = 0, subSize = 0; + for (auto it : + llvm::zip(llvm::reverse(superShape), llvm::reverse(subShape))) { + std::tie(superSize, subSize) = it; assert(superSize > 0 && "superSize must be > 0"); assert(subSize > 0 && "subSize must be > 0"); - divides &= (superSize % subSize == 0); - result.push_back(superSize / subSize); - }; - functional::zipApply( - divide, SmallVector{superShape.rbegin(), superShape.rend()}, - SmallVector{subShape.rbegin(), subShape.rend()}); - // If integral division does not occur, return and let the caller decide. - if (!divides) { - return None; + // If integral division does not occur, return and let the caller decide. + if (superSize % subSize != 0) + return None; + result.push_back(superSize / subSize); } // At this point we computed the ratio (in reverse) for the common @@ -157,8 +154,6 @@ return AffineMap(); MLIRContext *context = enclosingLoopToVectorDim.begin()->getFirst()->getContext(); - using functional::makePtrDynCaster; - using functional::map; SmallVector perm(enclosingLoopToVectorDim.size(), getAffineConstantExpr(0, context)); diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -10,7 +10,6 @@ #include "AffineMapDetail.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Support/MathExtras.h" #include "llvm/ADT/StringRef.h" diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -14,7 +14,6 @@ #include "mlir/IR/Matchers.h" #include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" -#include "mlir/Support/Functional.h" #include "llvm/Support/raw_ostream.h" using namespace mlir; @@ -204,47 +203,46 @@ } ArrayAttr Builder::getI32ArrayAttr(ArrayRef values) { - auto attrs = functional::map( - [this](int32_t v) -> Attribute { return getI32IntegerAttr(v); }, values); + auto attrs = llvm::to_vector<8>(llvm::map_range( + values, [this](int32_t v) -> Attribute { return getI32IntegerAttr(v); })); return getArrayAttr(attrs); } ArrayAttr Builder::getI64ArrayAttr(ArrayRef values) { - auto attrs = functional::map( - [this](int64_t v) -> Attribute { return getI64IntegerAttr(v); }, values); + auto attrs = llvm::to_vector<8>(llvm::map_range( + values, [this](int64_t v) -> Attribute { return getI64IntegerAttr(v); })); return getArrayAttr(attrs); } ArrayAttr Builder::getIndexArrayAttr(ArrayRef values) { - auto attrs = functional::map( - [this](int64_t v) -> Attribute { + auto attrs = llvm::to_vector<8>( + llvm::map_range(values, [this](int64_t v) -> Attribute { return getIntegerAttr(IndexType::get(getContext()), v); - }, - values); + })); return getArrayAttr(attrs); } ArrayAttr Builder::getF32ArrayAttr(ArrayRef values) { - auto attrs = functional::map( - [this](float v) -> Attribute { return getF32FloatAttr(v); }, values); + auto attrs = llvm::to_vector<8>(llvm::map_range( + values, [this](float v) -> Attribute { return getF32FloatAttr(v); })); return getArrayAttr(attrs); } ArrayAttr Builder::getF64ArrayAttr(ArrayRef values) { - auto attrs = functional::map( - [this](double v) -> Attribute { return getF64FloatAttr(v); }, values); + auto attrs = llvm::to_vector<8>(llvm::map_range( + values, [this](double v) -> Attribute { return getF64FloatAttr(v); })); return getArrayAttr(attrs); } ArrayAttr Builder::getStrArrayAttr(ArrayRef values) { - auto attrs = functional::map( - [this](StringRef v) -> Attribute { return getStringAttr(v); }, values); + auto attrs = llvm::to_vector<8>(llvm::map_range( + values, [this](StringRef v) -> Attribute { return getStringAttr(v); })); return getArrayAttr(attrs); } ArrayAttr Builder::getAffineMapArrayAttr(ArrayRef values) { - auto attrs = functional::map( - [](AffineMap v) -> Attribute { return AffineMapAttr::get(v); }, values); + auto attrs = llvm::to_vector<8>(llvm::map_range( + values, [](AffineMap v) -> Attribute { return AffineMapAttr::get(v); })); return getArrayAttr(attrs); } diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -24,7 +24,6 @@ #include "mlir/IR/Types.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" -#include "mlir/Support/Functional.h" #include "mlir/Transforms/LoopUtils.h" #include "mlir/Transforms/Passes.h" diff --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp --- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp @@ -19,7 +19,6 @@ #include "mlir/IR/Diagnostics.h" #include "mlir/IR/StandardTypes.h" #include "mlir/Pass/Pass.h" -#include "mlir/Support/Functional.h" #include "mlir/Support/STLExtras.h" #include "mlir/Transforms/Passes.h" @@ -33,8 +32,6 @@ using llvm::SetVector; -using functional::map; - static llvm::cl::OptionCategory clOptionsCategory(DEBUG_TYPE " options"); static llvm::cl::list clTestVectorShapeRatio( @@ -129,7 +126,6 @@ } static NestedPattern patternTestSlicingOps() { - using functional::map; using matcher::Op; // Match all operations with the kTestSlicingOpName name. auto filter = [](Operation &op) { diff --git a/mlir/test/mlir-tblgen/predicate.td b/mlir/test/mlir-tblgen/predicate.td --- a/mlir/test/mlir-tblgen/predicate.td +++ b/mlir/test/mlir-tblgen/predicate.td @@ -81,9 +81,9 @@ } // CHECK-LABEL: OpJ::verify() -// CHECK: llvm::is_splat(mlir::functional::map( -// CHECK-SAME: [this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); }, -// CHECK-SAME: llvm::ArrayRef({0, 2, 3}))) +// CHECK: llvm::is_splat(llvm::map_range( +// CHECK-SAME: llvm::ArrayRef({0, 2, 3}), +// CHECK-SAME: [this](unsigned i) { return getElementTypeOrSelf(this->getOperand(i)); })) // CHECK: return emitOpError("failed to verify that operands indexed at 0, 2, 3 should all have the same type"); def OpK : NS_Op<"op_for_AnyTensorOf", []> {