diff options
Diffstat (limited to 'mlir/lib')
23 files changed, 71 insertions, 177 deletions
diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp index ffb1dd28836..f6c044159ee 100644 --- a/mlir/lib/AffineOps/AffineOps.cpp +++ b/mlir/lib/AffineOps/AffineOps.cpp @@ -407,7 +407,6 @@ AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map, ArrayRef<Value *> operands) : AffineApplyNormalizer() { static_assert(kMaxAffineApplyDepth > 0, "kMaxAffineApplyDepth must be > 0"); - assert(map.getRangeSizes().empty() && "Unbounded map expected"); assert(map.getNumInputs() == operands.size() && "number of operands does not match the number of map inputs"); @@ -497,7 +496,7 @@ AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map, "Unexpected number of concatenated symbols"); auto numDims = dimValueToPosition.size(); auto numSymbols = concatenatedSymbols.size() - map.getNumSymbols(); - auto auxiliaryMap = AffineMap::get(numDims, numSymbols, auxiliaryExprs, {}); + auto auxiliaryMap = AffineMap::get(numDims, numSymbols, auxiliaryExprs); LLVM_DEBUG(map.print(dbgs() << "\nCompose map: ")); LLVM_DEBUG(auxiliaryMap.print(dbgs() << "\nWith map: ")); diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index 9a821a0266d..41f8e075813 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -157,21 +157,16 @@ MutableAffineMap::MutableAffineMap(AffineMap map) context(map.getResult(0).getContext()) { for (auto result : map.getResults()) results.push_back(result); - for (auto rangeSize : map.getRangeSizes()) - results.push_back(rangeSize); } void MutableAffineMap::reset(AffineMap map) { results.clear(); - rangeSizes.clear(); numDims = map.getNumDims(); numSymbols = map.getNumSymbols(); // A map always has at least 1 result by construction context = map.getResult(0).getContext(); for (auto result : map.getResults()) results.push_back(result); - for (auto rangeSize : map.getRangeSizes()) - results.push_back(rangeSize); } bool MutableAffineMap::isMultipleOf(unsigned idx, int64_t factor) const { @@ -194,7 +189,7 @@ void MutableAffineMap::simplify() { } AffineMap MutableAffineMap::getAffineMap() const { - return AffineMap::get(numDims, numSymbols, results, rangeSizes); + return AffineMap::get(numDims, numSymbols, results); } MutableIntegerSet::MutableIntegerSet(IntegerSet set, MLIRContext *context) @@ -1454,8 +1449,8 @@ std::pair<AffineMap, AffineMap> FlatAffineConstraints::getLowerAndUpperBound( auto expr = mlir::toAffineExpr(lb, dimCount, symCount, localExprs, context); exprs.push_back(expr); } - auto lbMap = exprs.empty() ? AffineMap() - : AffineMap::get(dimCount, symCount, exprs, {}); + auto lbMap = + exprs.empty() ? AffineMap() : AffineMap::get(dimCount, symCount, exprs); exprs.clear(); exprs.reserve(ubIndices.size()); @@ -1468,8 +1463,8 @@ std::pair<AffineMap, AffineMap> FlatAffineConstraints::getLowerAndUpperBound( // Upper bound is exclusive. exprs.push_back(expr + 1); } - auto ubMap = exprs.empty() ? AffineMap() - : AffineMap::get(dimCount, symCount, exprs, {}); + auto ubMap = + exprs.empty() ? AffineMap() : AffineMap::get(dimCount, symCount, exprs); return {lbMap, ubMap}; } @@ -1591,8 +1586,8 @@ void FlatAffineConstraints::getSliceBounds(unsigned num, MLIRContext *context, AffineMap &ubMap = (*ubMaps)[pos]; if (expr) { - lbMap = AffineMap::get(numMapDims, numMapSymbols, expr, {}); - ubMap = AffineMap::get(numMapDims, numMapSymbols, expr + 1, {}); + lbMap = AffineMap::get(numMapDims, numMapSymbols, expr); + ubMap = AffineMap::get(numMapDims, numMapSymbols, expr + 1); } else { // TODO(bondhugula): Whenever there are local identifiers in the // dependence constraints, we'll conservatively over-approximate, since we @@ -1621,7 +1616,7 @@ void FlatAffineConstraints::getSliceBounds(unsigned num, MLIRContext *context, if (lbConst.hasValue()) { lbMap = AffineMap::get( numMapDims, numMapSymbols, - getAffineConstantExpr(lbConst.getValue(), context), {}); + getAffineConstantExpr(lbConst.getValue(), context)); } } if (!ubMap || ubMap.getNumResults() > 1) { @@ -1631,7 +1626,7 @@ void FlatAffineConstraints::getSliceBounds(unsigned num, MLIRContext *context, if (ubConst.hasValue()) { (ubMap) = AffineMap::get( numMapDims, numMapSymbols, - getAffineConstantExpr(ubConst.getValue() + 1, context), {}); + getAffineConstantExpr(ubConst.getValue() + 1, context)); } } } diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 97c2a87a10d..117cf6e109e 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -80,7 +80,7 @@ void mlir::buildTripCountMapAndOperands( for (auto ubExpr : ubMap.getResults()) ubs.push_back(b.create<AffineApplyOp>( forOp.getLoc(), - b.getAffineMap(ubMap.getNumDims(), ubMap.getNumSymbols(), {ubExpr}, {}), + b.getAffineMap(ubMap.getNumDims(), ubMap.getNumSymbols(), {ubExpr}), ubOperands)); tripCountOperands->clear(); @@ -92,7 +92,7 @@ void mlir::buildTripCountMapAndOperands( for (unsigned i = 0, e = ubs.size(); i < e; i++) tripCountExprs[i] = (b.getAffineDimExpr(1 + i) - b.getAffineDimExpr(0)).ceilDiv(step); - *map = b.getAffineMap(1 + ubs.size(), 0, tripCountExprs, {}); + *map = b.getAffineMap(1 + ubs.size(), 0, tripCountExprs); fullyComposeAffineMapAndOperands(map, tripCountOperands); *map = simplifyAffineMap(*map); diff --git a/mlir/lib/Analysis/VectorAnalysis.cpp b/mlir/lib/Analysis/VectorAnalysis.cpp index e1d31ad1d2b..0d1e2c0f416 100644 --- a/mlir/lib/Analysis/VectorAnalysis.cpp +++ b/mlir/lib/Analysis/VectorAnalysis.cpp @@ -140,7 +140,7 @@ static AffineMap makePermutationMap( "Vectorization prerequisite violated: at most 1 index may be " "invariant wrt a vectorized loop"); } - return AffineMap::get(indices.size(), 0, perm, {}); + return AffineMap::get(indices.size(), 0, perm); } /// Implementation detail that walks up the parents and records the ones with diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp index d0fd3e97291..5c17454fb49 100644 --- a/mlir/lib/EDSC/Builders.cpp +++ b/mlir/lib/EDSC/Builders.cpp @@ -311,7 +311,7 @@ static ValueHandle createBinaryIndexHandle( if (v1) { operands.push_back(v1); } - auto map = AffineMap::get(numDims, numSymbols, {affCombiner(d0, d1)}, {}); + auto map = AffineMap::get(numDims, numSymbols, {affCombiner(d0, d1)}); // TODO: createOrFold when available. return ValueHandle::createComposedAffineApply(map, operands); } diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index 8039a38627a..e313c6fda9f 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -102,7 +102,7 @@ private: /// Returns a single constant result affine map. AffineMap AffineMap::getConstantMap(int64_t val, MLIRContext *context) { return get(/*dimCount=*/0, /*symbolCount=*/0, - {getAffineConstantExpr(val, context)}, {}); + {getAffineConstantExpr(val, context)}); } AffineMap AffineMap::getMultiDimIdentityMap(unsigned numDims, @@ -111,16 +111,11 @@ AffineMap AffineMap::getMultiDimIdentityMap(unsigned numDims, dimExprs.reserve(numDims); for (unsigned i = 0; i < numDims; ++i) dimExprs.push_back(mlir::getAffineDimExpr(i, context)); - return get(/*dimCount=*/numDims, /*symbolCount=*/0, dimExprs, {}); + return get(/*dimCount=*/numDims, /*symbolCount=*/0, dimExprs); } MLIRContext *AffineMap::getContext() const { return getResult(0).getContext(); } -bool AffineMap::isBounded() const { - assert(map && "uninitialized AffineMap"); - return !map->rangeSizes.empty(); -} - bool AffineMap::isIdentity() const { if (getNumDims() != getNumResults()) return false; @@ -167,10 +162,6 @@ AffineExpr AffineMap::getResult(unsigned idx) const { assert(map && "uninitialized map storage"); return map->results[idx]; } -ArrayRef<AffineExpr> AffineMap::getRangeSizes() const { - assert(map && "uninitialized map storage"); - return map->rangeSizes; -} /// Folds the results of the application of an affine map on the provided /// operands to a constant if possible. Returns false if the folding happens, @@ -196,15 +187,11 @@ AffineMap::constantFold(ArrayRef<Attribute> operandConstants, return success(); } -/// Walk all of the AffineExpr's in this mapping. The results are visited -/// first, and then the range sizes (if present). Each node in an expression +/// Walk all of the AffineExpr's in this mapping. Each node in an expression /// tree is visited in postorder. void AffineMap::walkExprs(std::function<void(AffineExpr)> callback) const { for (auto expr : getResults()) expr.walk(callback); - - for (auto expr : getRangeSizes()) - expr.walk(callback); } /// This method substitutes any uses of dimensions and symbols (e.g. @@ -222,19 +209,11 @@ AffineMap AffineMap::replaceDimsAndSymbols(ArrayRef<AffineExpr> dimReplacements, results.push_back( expr.replaceDimsAndSymbols(dimReplacements, symReplacements)); - SmallVector<AffineExpr, 8> resultRanges; - resultRanges.reserve(getRangeSizes().size()); - for (auto expr : getRangeSizes()) - resultRanges.push_back( - expr.replaceDimsAndSymbols(dimReplacements, symReplacements)); - - return get(numResultDims, numResultSyms, results, resultRanges); + return get(numResultDims, numResultSyms, results); } AffineMap AffineMap::compose(AffineMap map) { assert(getNumDims() == map.getNumResults() && "Number of results mismatch"); - assert(getRangeSizes().empty() && "TODO: support bounded AffineMap"); - assert(map.getRangeSizes().empty() && "TODO: support bounded AffineMap"); // Prepare `map` by concatenating the symbols and rewriting its exprs. unsigned numDims = map.getNumDims(); unsigned numSymbolsThisMap = getNumSymbols(); @@ -254,25 +233,20 @@ AffineMap AffineMap::compose(AffineMap map) { exprs.reserve(getResults().size()); for (auto expr : getResults()) exprs.push_back(expr.compose(newMap)); - return AffineMap::get(numDims, numSymbols, exprs, {}); + return AffineMap::get(numDims, numSymbols, exprs); } AffineMap mlir::simplifyAffineMap(AffineMap map) { - SmallVector<AffineExpr, 8> exprs, sizes; + SmallVector<AffineExpr, 8> exprs; for (auto e : map.getResults()) { exprs.push_back( simplifyAffineExpr(e, map.getNumDims(), map.getNumSymbols())); } - for (auto e : map.getRangeSizes()) { - sizes.push_back( - simplifyAffineExpr(e, map.getNumDims(), map.getNumSymbols())); - } - return AffineMap::get(map.getNumDims(), map.getNumSymbols(), exprs, sizes); + return AffineMap::get(map.getNumDims(), map.getNumSymbols(), exprs); } AffineMap mlir::inversePermutation(AffineMap map) { assert(map.getNumSymbols() == 0 && "expected map without symbols"); - assert(map.getRangeSizes().empty() && "expected map without range sizes"); SmallVector<AffineExpr, 4> exprs(map.getNumDims()); for (auto en : llvm::enumerate(map.getResults())) { auto expr = en.value(); @@ -287,7 +261,7 @@ AffineMap mlir::inversePermutation(AffineMap map) { if (expr) seenExprs.push_back(expr); assert(seenExprs.size() == map.getNumInputs() && "map is not full rank"); - return AffineMap::get(map.getNumResults(), 0, seenExprs, {}); + return AffineMap::get(map.getNumResults(), 0, seenExprs); } AffineMap mlir::concatAffineMaps(ArrayRef<AffineMap> maps) { @@ -301,9 +275,8 @@ AffineMap mlir::concatAffineMaps(ArrayRef<AffineMap> maps) { if (!m) continue; assert(m.getNumSymbols() == 0 && "expected map without symbols"); - assert(m.getRangeSizes().empty() && "expected map without range sizes"); results.append(m.getResults().begin(), m.getResults().end()); numDims = std::max(m.getNumDims(), numDims); } - return AffineMap::get(numDims, 0, results, {}); + return AffineMap::get(numDims, 0, results); } diff --git a/mlir/lib/IR/AffineMapDetail.h b/mlir/lib/IR/AffineMapDetail.h index edbc714f00b..af1d89cd239 100644 --- a/mlir/lib/IR/AffineMapDetail.h +++ b/mlir/lib/IR/AffineMapDetail.h @@ -36,10 +36,6 @@ struct AffineMapStorage { /// The affine expressions for this (multi-dimensional) map. /// TODO: use trailing objects for this. ArrayRef<AffineExpr> results; - - /// The extents along each of the range dimensions if the map is bounded, - /// nullptr otherwise. - ArrayRef<AffineExpr> rangeSizes; }; } // end namespace detail diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 20770252b2d..4c056a1ca9d 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1059,16 +1059,6 @@ void ModulePrinter::printAffineMap(AffineMap map) { interleaveComma(map.getResults(), [&](AffineExpr expr) { printAffineExpr(expr); }); os << ')'; - - if (!map.isBounded()) { - return; - } - - // Print range sizes for bounded affine maps. - os << " size ("; - interleaveComma(map.getRangeSizes(), - [&](AffineExpr expr) { printAffineExpr(expr); }); - os << ')'; } void ModulePrinter::printIntegerSet(IntegerSet set) { diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 65129cb926e..c6e84ff4858 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -267,9 +267,8 @@ Attribute Builder::getZeroAttr(Type type) { //===----------------------------------------------------------------------===// AffineMap Builder::getAffineMap(unsigned dimCount, unsigned symbolCount, - ArrayRef<AffineExpr> results, - ArrayRef<AffineExpr> rangeSizes) { - return AffineMap::get(dimCount, symbolCount, results, rangeSizes); + ArrayRef<AffineExpr> results) { + return AffineMap::get(dimCount, symbolCount, results); } AffineExpr Builder::getAffineDimExpr(unsigned position) { @@ -292,12 +291,12 @@ IntegerSet Builder::getIntegerSet(unsigned dimCount, unsigned symbolCount, AffineMap Builder::getConstantAffineMap(int64_t val) { return AffineMap::get(/*dimCount=*/0, /*symbolCount=*/0, - {getAffineConstantExpr(val)}, {}); + {getAffineConstantExpr(val)}); } AffineMap Builder::getDimIdentityMap() { return AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0, - {getAffineDimExpr(0)}, {}); + {getAffineDimExpr(0)}); } AffineMap Builder::getMultiDimIdentityMap(unsigned rank) { @@ -305,18 +304,18 @@ AffineMap Builder::getMultiDimIdentityMap(unsigned rank) { dimExprs.reserve(rank); for (unsigned i = 0; i < rank; ++i) dimExprs.push_back(getAffineDimExpr(i)); - return AffineMap::get(/*dimCount=*/rank, /*symbolCount=*/0, dimExprs, {}); + return AffineMap::get(/*dimCount=*/rank, /*symbolCount=*/0, dimExprs); } AffineMap Builder::getSymbolIdentityMap() { return AffineMap::get(/*dimCount=*/0, /*symbolCount=*/1, - {getAffineSymbolExpr(0)}, {}); + {getAffineSymbolExpr(0)}); } AffineMap Builder::getSingleDimShiftAffineMap(int64_t shift) { // expr = d0 + shift. auto expr = getAffineDimExpr(0) + shift; - return AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0, {expr}, {}); + return AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0, {expr}); } AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) { @@ -325,8 +324,7 @@ AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) { for (auto resultExpr : map.getResults()) { shiftedResults.push_back(resultExpr + shift); } - return AffineMap::get(map.getNumDims(), map.getNumSymbols(), shiftedResults, - map.getRangeSizes()); + return AffineMap::get(map.getNumDims(), map.getNumSymbols(), shiftedResults); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index c353fd5ec3d..1f7aca8ec00 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -149,27 +149,25 @@ struct BuiltinDialect : public Dialect { struct AffineMapKeyInfo : DenseMapInfo<AffineMap> { // Affine maps are uniqued based on their dim/symbol counts and affine // expressions. - using KeyTy = std::tuple<unsigned, unsigned, ArrayRef<AffineExpr>, - ArrayRef<AffineExpr>>; + using KeyTy = std::tuple<unsigned, unsigned, ArrayRef<AffineExpr>>; using DenseMapInfo<AffineMap>::isEqual; static unsigned getHashValue(const AffineMap &key) { - return getHashValue(KeyTy(key.getNumDims(), key.getNumSymbols(), - key.getResults(), key.getRangeSizes())); + return getHashValue( + KeyTy(key.getNumDims(), key.getNumSymbols(), key.getResults())); } static unsigned getHashValue(KeyTy key) { return hash_combine( std::get<0>(key), std::get<1>(key), - hash_combine_range(std::get<2>(key).begin(), std::get<2>(key).end()), - hash_combine_range(std::get<3>(key).begin(), std::get<3>(key).end())); + hash_combine_range(std::get<2>(key).begin(), std::get<2>(key).end())); } static bool isEqual(const KeyTy &lhs, AffineMap rhs) { if (rhs == getEmptyKey() || rhs == getTombstoneKey()) return false; return lhs == std::make_tuple(rhs.getNumDims(), rhs.getNumSymbols(), - rhs.getResults(), rhs.getRangeSizes()); + rhs.getResults()); } }; @@ -797,27 +795,22 @@ StorageUniquer &MLIRContext::getAffineUniquer() { } AffineMap AffineMap::get(unsigned dimCount, unsigned symbolCount, - ArrayRef<AffineExpr> results, - ArrayRef<AffineExpr> rangeSizes) { + ArrayRef<AffineExpr> results) { // The number of results can't be zero. assert(!results.empty()); - assert(rangeSizes.empty() || results.size() == rangeSizes.size()); - auto &impl = results[0].getContext()->getImpl(); - auto key = std::make_tuple(dimCount, symbolCount, results, rangeSizes); + auto key = std::make_tuple(dimCount, symbolCount, results); // Safely get or create an AffineMap instance. return safeGetOrCreate(impl.affineMaps, key, impl.affineMutex, [&] { auto *res = impl.affineAllocator.Allocate<detail::AffineMapStorage>(); - // Copy the results and range sizes into the bump pointer. + // Copy the results into the bump pointer. results = copyArrayRefInto(impl.affineAllocator, results); - rangeSizes = copyArrayRefInto(impl.affineAllocator, rangeSizes); // Initialize the memory using placement new. - new (res) - detail::AffineMapStorage{dimCount, symbolCount, results, rangeSizes}; + new (res) detail::AffineMapStorage{dimCount, symbolCount, results}; return AffineMap(res); }); } diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp index 03bce65aa2f..6c0d74010bf 100644 --- a/mlir/lib/IR/StandardTypes.cpp +++ b/mlir/lib/IR/StandardTypes.cpp @@ -329,12 +329,12 @@ MemRefType MemRefType::getImpl(ArrayRef<int64_t> shape, Type elementType, ++i; } - // Drop the unbounded identity maps from the composition. + // Drop identity maps from the composition. // This may lead to the composition becoming empty, which is interpreted as an // implicit identity. llvm::SmallVector<AffineMap, 2> cleanedAffineMapComposition; for (const auto &map : affineMapComposition) { - if (map.isIdentity() && !map.isBounded()) + if (map.isIdentity()) continue; cleanedAffineMapComposition.push_back(map); } diff --git a/mlir/lib/Linalg/IR/LinalgOps.cpp b/mlir/lib/Linalg/IR/LinalgOps.cpp index dd32d5c4504..55a791a6d63 100644 --- a/mlir/lib/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Linalg/IR/LinalgOps.cpp @@ -741,19 +741,18 @@ SmallVector<AffineMap, 4> mlir::linalg::loopToOperandRangesMaps(Operation *op) { auto k = getAffineDimExpr(2, context); if (isa<DotOp>(op)) // A(r_i) * B(r_i) -> C() - return SmallVector<AffineMap, 4>{AffineMap::get(1, 0, {i}, {}), - AffineMap::get(1, 0, {i}, {}), - AffineMap()}; + return SmallVector<AffineMap, 4>{AffineMap::get(1, 0, {i}), + AffineMap::get(1, 0, {i}), AffineMap()}; if (isa<MatvecOp>(op)) // A(i, r_j) * B(r_j) -> C(i) - return SmallVector<AffineMap, 4>{AffineMap::get(2, 0, {i, j}, {}), - AffineMap::get(2, 0, {j}, {}), - AffineMap::get(2, 0, {i}, {})}; + return SmallVector<AffineMap, 4>{AffineMap::get(2, 0, {i, j}), + AffineMap::get(2, 0, {j}), + AffineMap::get(2, 0, {i})}; if (isa<MatmulOp>(op)) // A(i, r_k) * B(r_k, j) -> C(i, j) - return SmallVector<AffineMap, 4>{AffineMap::get(3, 0, {i, k}, {}), - AffineMap::get(3, 0, {k, j}, {}), - AffineMap::get(3, 0, {i, j}, {})}; + return SmallVector<AffineMap, 4>{AffineMap::get(3, 0, {i, k}), + AffineMap::get(3, 0, {k, j}), + AffineMap::get(3, 0, {i, j})}; llvm_unreachable("Missing loopToOperandRangesMaps for op"); } diff --git a/mlir/lib/Linalg/Utils/Utils.cpp b/mlir/lib/Linalg/Utils/Utils.cpp index c3fea9b227c..f19e61c5531 100644 --- a/mlir/lib/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Linalg/Utils/Utils.cpp @@ -131,7 +131,7 @@ mlir::linalg::applyMapToValues(FuncBuilder *b, Location loc, AffineMap map, // ranges. If the resulting application can be folded into a Value*, the // folding occurs eagerly. Otherwise, an affine.apply operation is emitted. for (auto expr : map.getResults()) { - AffineMap map = AffineMap::get(numDims, 0, expr, {}); + AffineMap map = AffineMap::get(numDims, 0, expr); res.push_back(emitOrFoldComposedAffineApply(b, loc, map, values, state)); } return res; diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 553aa926696..f1a6601f8dd 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -2115,8 +2115,6 @@ ParseResult AffineParser::parseAffineMapOrIntegerSetInline(AffineMap &map, /// Parse the range and sizes affine map definition inline. /// /// affine-map ::= dim-and-symbol-id-lists `->` multi-dim-affine-expr -/// (`size` `(` dim-size (`,` dim-size)* `)`)? -/// dim-size ::= affine-expr | `min` `(` affine-expr ( `,` affine-expr)+ `)` /// /// multi-dim-affine-expr ::= `(` affine-expr (`,` affine-expr)* `) AffineMap AffineParser::parseAffineMapRange(unsigned numDims, @@ -2137,44 +2135,8 @@ AffineMap AffineParser::parseAffineMapRange(unsigned numDims, if (parseCommaSeparatedListUntil(Token::r_paren, parseElt, false)) return AffineMap(); - // Parse optional range sizes. - // range-sizes ::= (`size` `(` dim-size (`,` dim-size)* `)`)? - // dim-size ::= affine-expr | `min` `(` affine-expr (`,` affine-expr)+ `)` - // TODO(bondhugula): support for min of several affine expressions. - // TODO: check if sizes are non-negative whenever they are constant. - SmallVector<AffineExpr, 4> rangeSizes; - if (consumeIf(Token::kw_size)) { - // Location of the l_paren token (if it exists) for error reporting later. - auto loc = getToken().getLoc(); - if (parseToken(Token::l_paren, "expected '(' at start of affine map range")) - return AffineMap(); - - auto parseRangeSize = [&]() -> ParseResult { - auto loc = getToken().getLoc(); - auto elt = parseAffineExpr(); - if (!elt) - return failure(); - - if (!elt.isSymbolicOrConstant()) - return emitError(loc, - "size expressions cannot refer to dimension values"); - - rangeSizes.push_back(elt); - return success(); - }; - - if (parseCommaSeparatedListUntil(Token::r_paren, parseRangeSize, false)) - return AffineMap(); - if (exprs.size() > rangeSizes.size()) - return (emitError(loc, "fewer range sizes than range expressions"), - AffineMap()); - if (exprs.size() < rangeSizes.size()) - return (emitError(loc, "more range sizes than range expressions"), - AffineMap()); - } - // Parsed a valid affine map. - return builder.getAffineMap(numDims, numSymbols, exprs, rangeSizes); + return builder.getAffineMap(numDims, numSymbols, exprs); } /// Parse an ambiguous reference to either and affine map or an integer set. diff --git a/mlir/lib/Transforms/DmaGeneration.cpp b/mlir/lib/Transforms/DmaGeneration.cpp index 6452346a6d1..143662763ae 100644 --- a/mlir/lib/Transforms/DmaGeneration.cpp +++ b/mlir/lib/Transforms/DmaGeneration.cpp @@ -326,7 +326,7 @@ bool DmaGeneration::generateDma(const MemRefRegion ®ion, Block *block, // The coordinate for the start location is just the lower bound along the // corresponding dimension on the memory region (stored in 'offset'). auto map = top.getAffineMap( - cst->getNumDimIds() + cst->getNumSymbolIds() - rank, 0, offset, {}); + cst->getNumDimIds() + cst->getNumSymbolIds() - rank, 0, offset); memIndices.push_back(b->create<AffineApplyOp>(loc, map, regionSymbols)); } // The fast buffer is DMAed into at location zero; addressing is relative. @@ -438,8 +438,7 @@ bool DmaGeneration::generateDma(const MemRefRegion ®ion, Block *block, auto dimExpr = b->getAffineDimExpr(regionSymbols.size() + i); remapExprs.push_back(dimExpr - offsets[i]); } - auto indexRemap = - b->getAffineMap(regionSymbols.size() + rank, 0, remapExprs, {}); + auto indexRemap = b->getAffineMap(regionSymbols.size() + rank, 0, remapExprs); // Record the begin since it may be invalidated by memref replacement. Block::iterator prev; diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 7eb2c7289c0..b7b69fa54fe 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -1096,10 +1096,9 @@ static Value *createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst, simplifyAffineExpr(dimExpr - offsets[i], outerIVs.size() + rank, 0); remapExprs.push_back(remapExpr); } - auto indexRemap = - zeroOffsetCount == rank - ? AffineMap() - : b.getAffineMap(outerIVs.size() + rank, 0, remapExprs, {}); + auto indexRemap = zeroOffsetCount == rank + ? AffineMap() + : b.getAffineMap(outerIVs.size() + rank, 0, remapExprs); // Replace all users of 'oldMemRef' with 'newMemRef'. bool ret = replaceAllMemRefUsesWith(oldMemRef, newMemRef, {}, indexRemap, diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 28e13d89ada..5233081b5f1 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -168,12 +168,12 @@ constructTiledIndexSetHyperRect(MutableArrayRef<AffineForOp> origLoops, boundExprs.append(origUbMap.getResults().begin(), origUbMap.getResults().end()); auto ubMap = b.getAffineMap(origUbMap.getNumDims() + 1, - origUbMap.getNumSymbols(), boundExprs, {}); + origUbMap.getNumSymbols(), boundExprs); newLoops[width + i].setUpperBound(/*operands=*/ubOperands, ubMap); } else { // No need of the min expression. auto dim = b.getAffineDimExpr(0); - auto ubMap = b.getAffineMap(1, 0, dim + tileSizes[i], {}); + auto ubMap = b.getAffineMap(1, 0, dim + tileSizes[i]); newLoops[width + i].setUpperBound(newLoops[i].getInductionVar(), ubMap); } } diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index 609b42455f5..731464bd7c1 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -223,7 +223,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp, if (!forOpIV->use_empty()) { // iv' = iv + i, i = 1 to unrollJamFactor-1. auto d0 = builder.getAffineDimExpr(0); - auto bumpMap = builder.getAffineMap(1, 0, {d0 + i * step}, {}); + auto bumpMap = builder.getAffineMap(1, 0, {d0 + i * step}); auto ivUnroll = builder.create<AffineApplyOp>(forInst->getLoc(), bumpMap, forOpIV); operandMapping.map(forOpIV, ivUnroll); diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index 8094ff2f986..80e080f8fa6 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -373,7 +373,7 @@ reindexAffineIndices(FuncBuilder *b, VectorType hwVectorType, SmallVector<mlir::Value *, 8> res; res.reserve(affineExprs.size()); for (auto expr : affineExprs) { - auto map = AffineMap::get(numIndices, 0, expr, {}); + auto map = AffineMap::get(numIndices, 0, expr); res.push_back(makeComposedAffineApply(b, b->getInsertionPoint()->getLoc(), map, memrefIndices)); } @@ -470,7 +470,7 @@ static AffineMap projectedPermutationMap(VectorTransferOpTy transfer, if (keep.empty()) { return permutationMap; } - auto projectionMap = AffineMap::get(optionalRatio->size(), 0, keep, {}); + auto projectionMap = AffineMap::get(optionalRatio->size(), 0, keep); LLVM_DEBUG(projectionMap.print(dbgs() << "\nprojectionMap: ")); return simplifyAffineMap(projectionMap.compose(permutationMap)); } diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index c9e1dcefcf6..de8038c931c 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -112,7 +112,7 @@ static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) { auto d0 = bInner.getAffineDimExpr(0); int64_t step = forOp.getStep(); auto modTwoMap = bInner.getAffineMap(/*dimCount=*/1, /*symbolCount=*/0, - {d0.floorDiv(step) % 2}, {}); + {d0.floorDiv(step) % 2}); auto ivModTwoOp = bInner.create<AffineApplyOp>(forOp.getLoc(), modTwoMap, forOp.getInductionVar()); diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 47ee626f811..d5bdcea2c55 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -80,9 +80,8 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, for (unsigned i = 0, e = tripCountMap.getNumResults(); i < e; i++) { auto tripCountExpr = tripCountMap.getResult(i); bumpExprs[i] = (tripCountExpr - tripCountExpr % unrollFactor) * step; - auto bumpMap = - b->getAffineMap(tripCountMap.getNumDims(), tripCountMap.getNumSymbols(), - bumpExprs[i], {}); + auto bumpMap = b->getAffineMap(tripCountMap.getNumDims(), + tripCountMap.getNumSymbols(), bumpExprs[i]); bumpValues[i] = b->create<AffineApplyOp>(forOp.getLoc(), bumpMap, tripCountOperands); } @@ -94,7 +93,7 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor, operands->clear(); operands->push_back(lb); operands->append(bumpValues.begin(), bumpValues.end()); - *map = b->getAffineMap(1 + tripCountMap.getNumResults(), 0, newUbExprs, {}); + *map = b->getAffineMap(1 + tripCountMap.getNumResults(), 0, newUbExprs); // Simplify the map + operands. fullyComposeAffineMapAndOperands(map, operands); *map = simplifyAffineMap(*map); @@ -465,7 +464,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp, if (!forOpIV->use_empty()) { // iv' = iv + 1/2/3...unrollFactor-1; auto d0 = builder.getAffineDimExpr(0); - auto bumpMap = builder.getAffineMap(1, 0, {d0 + i * step}, {}); + auto bumpMap = builder.getAffineMap(1, 0, {d0 + i * step}); auto ivUnroll = builder.create<AffineApplyOp>(forOp.getLoc(), bumpMap, forOpIV); operandMap.map(forOpIV, ivUnroll); @@ -654,8 +653,7 @@ static void augmentMapAndBounds(FuncBuilder *b, Value *iv, AffineMap *map, auto bounds = llvm::to_vector<4>(map->getResults()); bounds.push_back(b->getAffineDimExpr(map->getNumDims()) + offset); operands->insert(operands->begin() + map->getNumDims(), iv); - *map = - b->getAffineMap(map->getNumDims() + 1, map->getNumSymbols(), bounds, {}); + *map = b->getAffineMap(map->getNumDims() + 1, map->getNumSymbols(), bounds); canonicalizeMapAndOperands(map, operands); } diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index e6ecd8e45fa..13e5b2f2f08 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -146,9 +146,8 @@ bool mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, // Remapped indices. for (auto resultExpr : indexRemap.getResults()) { - auto singleResMap = - builder.getAffineMap(indexRemap.getNumDims(), - indexRemap.getNumSymbols(), resultExpr, {}); + auto singleResMap = builder.getAffineMap( + indexRemap.getNumDims(), indexRemap.getNumSymbols(), resultExpr); auto afOp = builder.create<AffineApplyOp>(opInst->getLoc(), singleResMap, remapOperands); state.operands.push_back(afOp); @@ -259,7 +258,7 @@ void mlir::createAffineComputationSlice( sliceOps->reserve(composedMap.getNumResults()); for (auto resultExpr : composedMap.getResults()) { auto singleResMap = builder.getAffineMap( - composedMap.getNumDims(), composedMap.getNumSymbols(), resultExpr, {}); + composedMap.getNumDims(), composedMap.getNumSymbols(), resultExpr); sliceOps->push_back(builder.create<AffineApplyOp>( opInst->getLoc(), singleResMap, composedOpOperands)); } diff --git a/mlir/lib/VectorOps/VectorOps.cpp b/mlir/lib/VectorOps/VectorOps.cpp index 05af0293989..b40a1d9ee39 100644 --- a/mlir/lib/VectorOps/VectorOps.cpp +++ b/mlir/lib/VectorOps/VectorOps.cpp @@ -231,9 +231,6 @@ LogicalResult VectorTransferReadOp::verify() { return emitOpError("requires an AffineMapAttr named 'permutation_map'"); } auto permutationMap = getPermutationMap(); - if (!permutationMap.getRangeSizes().empty()) { - return emitOpError("requires an unbounded permutation_map"); - } if (permutationMap.getNumSymbols() != 0) { return emitOpError("requires a permutation_map without symbols"); } @@ -364,9 +361,6 @@ LogicalResult VectorTransferWriteOp::verify() { return emitOpError("requires an AffineMapAttr named 'permutation_map'"); } auto permutationMap = getPermutationMap(); - if (!permutationMap.getRangeSizes().empty()) { - return emitOpError("requires an unbounded permutation_map"); - } if (permutationMap.getNumSymbols() != 0) { return emitOpError("requires a permutation_map without symbols"); } |

