@@ -119,39 +119,37 @@ static void emitScalarImplementation(OpBuilder &b, Location loc,
119
119
LinalgOp linalgOp) {
120
120
assert (linalgOp.hasBufferSemantics () &&
121
121
" expected linalg op with buffer semantics" );
122
- unsigned nInputs = linalgOp.getNumInputs ();
123
- unsigned nOutputs = linalgOp.getNumOutputs ();
124
122
SmallVector<Value> indexedValues;
125
- indexedValues.reserve (nInputs + nOutputs );
123
+ indexedValues.reserve (linalgOp. getNumInputsAndOutputs () );
126
124
127
125
auto allIvsPlusDims = SmallVector<Value>(allIvs.begin (), allIvs.end ());
128
126
129
127
// TODO: Avoid the loads if the corresponding argument of the
130
128
// region has no uses.
131
129
// 1.a. Emit load from input views.
132
- for (unsigned i = 0 ; i < nInputs; ++i ) {
130
+ for (OpOperand *inputOperand : linalgOp. getInputOperands () ) {
133
131
auto indexing = makeCanonicalAffineApplies (
134
- b, loc, linalgOp.getInputIndexingMap (i ), allIvsPlusDims);
132
+ b, loc, linalgOp.getTiedIndexingMap (inputOperand ), allIvsPlusDims);
135
133
indexedValues.push_back (
136
- b.create <LoadOpTy>(loc, linalgOp. getInput (i ), indexing));
134
+ b.create <LoadOpTy>(loc, inputOperand-> get ( ), indexing));
137
135
}
138
136
// 1.b. Emit load from output views.
139
- for (unsigned i = 0 ; i < nOutputs; ++i ) {
140
- auto indexing = makeCanonicalAffineApplies (
141
- b, loc, linalgOp.getOutputIndexingMap (i ), allIvsPlusDims);
137
+ for (OpOperand *outputOperand : linalgOp. getOutputOperands () ) {
138
+ SmallVector<Value> indexing = makeCanonicalAffineApplies (
139
+ b, loc, linalgOp.getTiedIndexingMap (outputOperand ), allIvsPlusDims);
142
140
indexedValues.push_back (
143
- b.create <LoadOpTy>(loc, linalgOp. getOutputBuffer (i ), indexing));
141
+ b.create <LoadOpTy>(loc, outputOperand-> get ( ), indexing));
144
142
}
145
143
146
144
// TODO: When a region inliner exists, use it.
147
145
// 2. Inline region, currently only works for a single basic block.
148
146
// 3. Emit store.
149
147
SmallVector<SmallVector<Value>, 8 > indexing;
150
148
SmallVector<Value> outputBuffers;
151
- for (unsigned i = 0 ; i < nOutputs; ++i ) {
149
+ for (OpOperand *outputOperand : linalgOp. getOutputBufferOperands () ) {
152
150
indexing.push_back (makeCanonicalAffineApplies (
153
- b, loc, linalgOp.getOutputIndexingMap (i ), allIvsPlusDims));
154
- outputBuffers.push_back (linalgOp. getOutputBuffer (i ));
151
+ b, loc, linalgOp.getTiedIndexingMap (outputOperand ), allIvsPlusDims));
152
+ outputBuffers.push_back (outputOperand-> get ( ));
155
153
}
156
154
inlineRegionAndEmitStore<LoadOpTy, StoreOpTy>(b, loc, linalgOp, indexedValues,
157
155
indexing, outputBuffers);
0 commit comments