@@ -58,31 +58,17 @@ static SmallVector<Value, 4> permuteIvs(ArrayRef<Value> ivs,
58
58
: SmallVector<Value, 4 >(ivs.begin (), ivs.end ());
59
59
}
60
60
61
- // Creates a number of ranges equal to the number of results in `map`.
62
- // The returned ranges correspond to the loop ranges, in the proper order, for
63
- // which new loops will be created.
64
- static SmallVector<SubViewOp::Range, 4 >
65
- emitLoopRanges (OpBuilder &b, Location loc, AffineMap map,
66
- ArrayRef<Value> allViewSizes) {
67
- // Apply `map` to get view sizes in loop order.
68
- auto sizes = applyMapToValues (b, loc, map, allViewSizes);
69
- // Create a new range with the applied tile sizes.
70
- ScopedContext scope (b, loc);
71
- SmallVector<SubViewOp::Range, 4 > res;
72
- for (unsigned idx = 0 , e = map.getNumResults (); idx < e; ++idx) {
73
- res.push_back (SubViewOp::Range{std_constant_index (0 ), sizes[idx],
74
- std_constant_index (1 )});
75
- }
76
- return res;
77
- }
78
-
79
61
// / Creates a number of ranges equal to the number of dimensions in the `map`.
80
- // / The function supports for now only limited number of expressions inside
81
- // / map results. It expects a non-inverted, concatenated map and last values in
82
- // / viewSizes will be applied to the symbols in the map.
83
- static SmallVector<SubViewOp::Range, 4 >
84
- emitLoopRangesWithSymbols (OpBuilder &b, Location loc, AffineMap map,
85
- ValueRange viewSizes) {
62
+ // / The returned ranges correspond to the loop ranges, in the proper order, for
63
+ // / which new loops will be created.
64
+ // / The function supports only maps that are invertible and have results of type
65
+ // / DimExpr or (DimExpr + DimExpr - SymbolExpr floordiv ConstExpr).
66
+ // / It expects a non-inverted, concatenated map and last values in
67
+ // / allViewSizes will be applied to the symbols in the map if it contains any.
68
+ static SmallVector<SubViewOp::Range, 4 > emitLoopRanges (OpBuilder &b,
69
+ Location loc,
70
+ AffineMap map,
71
+ ValueRange viewSizes) {
86
72
unsigned numDims = map.getNumDims (), numRes = map.getNumResults ();
87
73
unsigned numSym = map.getNumSymbols ();
88
74
assert (viewSizes.size () == numRes + numSym &&
@@ -537,23 +523,8 @@ Optional<LinalgLoops> linalgOpToLoopsImpl(Operation *op, OpBuilder &builder) {
537
523
llvm::map_range (mapsRange, [](AffineMapAttr a) { return a.getValue (); }));
538
524
SmallVector<Value, 8 > sizes = getViewSizes (builder, linalgOp);
539
525
AffineMap map = concatAffineMaps (maps);
540
- SmallVector<SubViewOp::Range, 4 > loopRanges;
541
-
542
- if (map.getNumSymbols ()) {
543
- loopRanges = emitLoopRangesWithSymbols (scope.getBuilderRef (),
544
- scope.getLocation (), map, sizes);
545
- } else {
546
- AffineMap invertedMap = inversePermutation (map);
547
- if (!invertedMap)
548
- return {};
549
- if (invertedMap.isEmpty ()) {
550
- emitScalarImplementation<IndexedValueTy>({}, linalgOp);
551
- return LinalgLoops ();
552
- }
553
-
554
- loopRanges = emitLoopRanges (scope.getBuilderRef (), scope.getLocation (),
555
- invertedMap, sizes);
556
- }
526
+ auto loopRanges = emitLoopRanges (scope.getBuilderRef (), scope.getLocation (),
527
+ map, getViewSizes (builder, linalgOp));
557
528
SmallVector<Value, 4 > allIvs;
558
529
GenerateLoopNest<LoopTy>::doit (
559
530
loopRanges, linalgOp.iterator_types ().getValue (), [&](ValueRange ivs) {
0 commit comments