@@ -26,12 +26,6 @@ using namespace mlir::linalg;
26
26
static SmallVector<Type, 4 > extractOperandTypes (Operation *op) {
27
27
SmallVector<Type, 4 > result;
28
28
result.reserve (op->getNumOperands ());
29
- if (auto indexedGenericOp = dyn_cast<IndexedGenericOp>(op)) {
30
- auto *ctx = op->getContext ();
31
- auto numLoops = indexedGenericOp.getNumLoops ();
32
- result.reserve (op->getNumOperands () + numLoops);
33
- result.assign (numLoops, IndexType::get (ctx));
34
- }
35
29
for (auto type : op->getOperandTypes ()) {
36
30
// The underlying descriptor type (e.g. LLVM) does not have layout
37
31
// information. Canonicalizing the type at the level of std when going into
@@ -103,7 +97,11 @@ createTypeCanonicalizedMemRefOperands(OpBuilder &b, Location loc,
103
97
LogicalResult mlir::linalg::LinalgOpToLibraryCallRewrite::matchAndRewrite (
104
98
LinalgOp op, PatternRewriter &rewriter) const {
105
99
// Only LinalgOp for which there is no specialized pattern go through this.
106
- if (isa<CopyOp>(op) || isa<IndexedGenericOp>(op))
100
+ if (isa<CopyOp>(op))
101
+ return failure ();
102
+
103
+ // Canonicalize indexed generic operations before library call conversion.
104
+ if (isa<IndexedGenericOp>(op))
107
105
return failure ();
108
106
109
107
auto libraryCallName = getLibraryCallSymbolRef (op, rewriter);
@@ -167,31 +165,6 @@ LogicalResult mlir::linalg::CopyTransposeRewrite::matchAndRewrite(
167
165
return success ();
168
166
}
169
167
170
- LogicalResult
171
- mlir::linalg::IndexedGenericOpToLibraryCallRewrite::matchAndRewrite (
172
- IndexedGenericOp op, PatternRewriter &rewriter) const {
173
- auto libraryCallName = getLibraryCallSymbolRef (op, rewriter);
174
- if (!libraryCallName)
175
- return failure ();
176
-
177
- // TODO: Use induction variables values instead of zeros, when
178
- // IndexedGenericOp is tiled.
179
- auto zero = rewriter.create <mlir::ConstantOp>(
180
- op.getLoc (), rewriter.getIntegerAttr (rewriter.getIndexType (), 0 ));
181
- auto indexedGenericOp = cast<IndexedGenericOp>(op);
182
- auto numLoops = indexedGenericOp.getNumLoops ();
183
- SmallVector<Value, 4 > operands;
184
- operands.reserve (numLoops + op.getNumOperands ());
185
- for (unsigned i = 0 ; i < numLoops; ++i)
186
- operands.push_back (zero);
187
- for (auto operand : op.getOperands ())
188
- operands.push_back (operand);
189
- rewriter.replaceOpWithNewOp <mlir::CallOp>(
190
- op, libraryCallName.getValue (), TypeRange (),
191
- createTypeCanonicalizedMemRefOperands (rewriter, op.getLoc (), operands));
192
- return success ();
193
- }
194
-
195
168
// / Populate the given list with patterns that convert from Linalg to Standard.
196
169
void mlir::linalg::populateLinalgToStandardConversionPatterns (
197
170
RewritePatternSet &patterns) {
@@ -201,7 +174,6 @@ void mlir::linalg::populateLinalgToStandardConversionPatterns(
201
174
patterns.add <
202
175
CopyOpToLibraryCallRewrite,
203
176
CopyTransposeRewrite,
204
- IndexedGenericOpToLibraryCallRewrite,
205
177
LinalgOpToLibraryCallRewrite>(patterns.getContext ());
206
178
// clang-format on
207
179
}
0 commit comments