[Mlir-commits] [mlir] 6b265f9 - [mlir][linalg] Cleanup LinalgOp usage in loop lowering.
Tobias Gysi
llvmlistbot at llvm.org
Thu Jun 3 06:30:34 PDT 2021
Author: Tobias Gysi
Date: 2021-06-03T13:29:52Z
New Revision: 6b265f949f6a5e92075eff018fa0f924bcc5da48
URL: https://github.com/llvm/llvm-project/commit/6b265f949f6a5e92075eff018fa0f924bcc5da48
DIFF: https://github.com/llvm/llvm-project/commit/6b265f949f6a5e92075eff018fa0f924bcc5da48.diff
LOG: [mlir][linalg] Cleanup LinalgOp usage in loop lowering.
Replace the uses of deprecated Structured Op Interface methods in Loops.cpp. This patch is based on https://reviews.llvm.org/D103394.
Differential Revision: https://reviews.llvm.org/D103453
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
index 5d8ddb5bb421..530c02466fc1 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -119,28 +119,26 @@ static void emitScalarImplementation(OpBuilder &b, Location loc,
LinalgOp linalgOp) {
assert(linalgOp.hasBufferSemantics() &&
"expected linalg op with buffer semantics");
- unsigned nInputs = linalgOp.getNumInputs();
- unsigned nOutputs = linalgOp.getNumOutputs();
SmallVector<Value> indexedValues;
- indexedValues.reserve(nInputs + nOutputs);
+ indexedValues.reserve(linalgOp.getNumInputsAndOutputs());
auto allIvsPlusDims = SmallVector<Value>(allIvs.begin(), allIvs.end());
// TODO: Avoid the loads if the corresponding argument of the
// region has no uses.
// 1.a. Emit load from input views.
- for (unsigned i = 0; i < nInputs; ++i) {
+ for (OpOperand *inputOperand : linalgOp.getInputOperands()) {
auto indexing = makeCanonicalAffineApplies(
- b, loc, linalgOp.getInputIndexingMap(i), allIvsPlusDims);
+ b, loc, linalgOp.getTiedIndexingMap(inputOperand), allIvsPlusDims);
indexedValues.push_back(
- b.create<LoadOpTy>(loc, linalgOp.getInput(i), indexing));
+ b.create<LoadOpTy>(loc, inputOperand->get(), indexing));
}
// 1.b. Emit load from output views.
- for (unsigned i = 0; i < nOutputs; ++i) {
- auto indexing = makeCanonicalAffineApplies(
- b, loc, linalgOp.getOutputIndexingMap(i), allIvsPlusDims);
+ for (OpOperand *outputOperand : linalgOp.getOutputOperands()) {
+ SmallVector<Value> indexing = makeCanonicalAffineApplies(
+ b, loc, linalgOp.getTiedIndexingMap(outputOperand), allIvsPlusDims);
indexedValues.push_back(
- b.create<LoadOpTy>(loc, linalgOp.getOutputBuffer(i), indexing));
+ b.create<LoadOpTy>(loc, outputOperand->get(), indexing));
}
// TODO: When a region inliner exists, use it.
@@ -148,10 +146,10 @@ static void emitScalarImplementation(OpBuilder &b, Location loc,
// 3. Emit store.
SmallVector<SmallVector<Value>, 8> indexing;
SmallVector<Value> outputBuffers;
- for (unsigned i = 0; i < nOutputs; ++i) {
+ for (OpOperand *outputOperand : linalgOp.getOutputBufferOperands()) {
indexing.push_back(makeCanonicalAffineApplies(
- b, loc, linalgOp.getOutputIndexingMap(i), allIvsPlusDims));
- outputBuffers.push_back(linalgOp.getOutputBuffer(i));
+ b, loc, linalgOp.getTiedIndexingMap(outputOperand), allIvsPlusDims));
+ outputBuffers.push_back(outputOperand->get());
}
inlineRegionAndEmitStore<LoadOpTy, StoreOpTy>(b, loc, linalgOp, indexedValues,
indexing, outputBuffers);
More information about the Mlir-commits
mailing list