@@ -168,14 +168,6 @@ getDefaultIndexingMapsForMatmul(MLIRContext *context) {
168
168
return indexingMaps;
169
169
}
170
170
171
- // / Wrapper to return the typical indexing map array attribute for MatmulOp.
172
- static SmallVector<Attribute>
173
- getDefaultMatmulIndexingMapAttr (MLIRContext *context) {
174
- return llvm::map_to_vector (
175
- getDefaultIndexingMapsForMatmul (context),
176
- [](AffineMap map) -> Attribute { return AffineMapAttr::get (map); });
177
- }
178
-
179
171
// / Creates a structured operation given `inputs`, `outputs`, and `attributes`.
180
172
// / The result types are derived automatically if `resultTensorTypes` is none.
181
173
// / The body of the operation is filled using `regionBuilder`. All ods-gen
@@ -222,9 +214,6 @@ buildMatmulOp(OpBuilder &b, OperationState &state,
222
214
indexingMapsAttrVal.push_back (AffineMapAttr::get (map));
223
215
}
224
216
state.addAttribute (" indexing_maps" , b.getArrayAttr (indexingMapsAttrVal));
225
- } else {
226
- indexingMapsAttrVal = getDefaultMatmulIndexingMapAttr (b.getContext ());
227
- state.addAttribute (" indexing_maps" , b.getArrayAttr (indexingMapsAttrVal));
228
217
}
229
218
return buildStructuredOp (b, state, resultTensorTypes, inputs, outputs,
230
219
attributes, regionBuilder);
@@ -3457,7 +3446,7 @@ static LogicalResult verifyExtendedMatmulSemantic(MatmulOp matmulOp,
3457
3446
unsigned opIndex) {
3458
3447
SmallVector<AffineMap, 3 > opIndexingMaps = matmulOp.getIndexingMapsArray ();
3459
3448
SmallVector<AffineMap, 3 > defaultIndexingMaps =
3460
- matmulOp.getDefaultIndexingMaps ();
3449
+ matmulOp.getDefaultIndexingMaps (matmulOp-> getContext () );
3461
3450
3462
3451
auto opIndexingMap = opIndexingMaps[opIndex];
3463
3452
auto defaultIndexingMap = defaultIndexingMaps[opIndex];
@@ -3501,7 +3490,8 @@ bool MatmulOp::hasDynamicIndexingMaps() { return true; }
3501
3490
// / Check if the op has broadcast and/or transpose semantic. Returns true if
3502
3491
// / the user defined indexing maps are not equal to default map.
3503
3492
bool MatmulOp::hasUserDefinedMaps () {
3504
- SmallVector<AffineMap, 3 > defaultMaps = getDefaultIndexingMaps ();
3493
+ SmallVector<AffineMap, 3 > defaultMaps =
3494
+ getDefaultIndexingMaps (this ->getContext ());
3505
3495
SmallVector<AffineMap, 3 > explicitMaps = getIndexingMapsArray ();
3506
3496
return defaultMaps != explicitMaps;
3507
3497
}
@@ -3535,13 +3525,6 @@ void MatmulOp::regionBuilder(ImplicitLocOpBuilder &b, Block &block,
3535
3525
helper.yieldOutputs (yields);
3536
3526
}
3537
3527
3538
- // / Returns a list of AffineMap with the typical matmul indexing
3539
- // / charactristic.
3540
- SmallVector<AffineMap> MatmulOp::getDefaultIndexingMaps () {
3541
- MLIRContext *context = this ->getContext ();
3542
- return getDefaultIndexingMapsForMatmul (context);
3543
- }
3544
-
3545
3528
// / Returns true if the given broadcast map \p bcastMap is valid for this op.
3546
3529
bool MatmulOp::isValidLhsRhsBroadcastMap (AffineMap bcastMap) {
3547
3530
assert (bcastMap.getNumResults () == 1 && " Expected single result dim expr." );
@@ -3578,7 +3561,9 @@ ParseResult MatmulOp::parse(OpAsmParser &parser, OperationState &result) {
3578
3561
}
3579
3562
// Initialize indexingMaps, if not supplied explicitly.
3580
3563
if (indexingMapsAttr.empty ()) {
3581
- indexingMapsAttr = getDefaultMatmulIndexingMapAttr (result.getContext ());
3564
+ indexingMapsAttr = llvm::map_to_vector (
3565
+ MatmulOp::getDefaultIndexingMaps (parser.getContext ()),
3566
+ [](AffineMap map) -> Attribute { return AffineMapAttr::get (map); });
3582
3567
}
3583
3568
result.addAttribute (" indexing_maps" ,
3584
3569
parser.getBuilder ().getArrayAttr (indexingMapsAttr));
@@ -3592,8 +3577,9 @@ void MatmulOp::print(OpAsmPrinter &p) {
3592
3577
printNamedStructuredOp (p, getOperation (), getInputs (), getOutputs (),
3593
3578
elidedAttrs);
3594
3579
3595
- SmallVector<Attribute, 3 > indexingMaps =
3596
- getDefaultMatmulIndexingMapAttr (getContext ());
3580
+ SmallVector<Attribute, 3 > indexingMaps = llvm::map_to_vector (
3581
+ MatmulOp::getDefaultIndexingMaps (getContext ()),
3582
+ [](AffineMap map) -> Attribute { return AffineMapAttr::get (map); });
3597
3583
if (!llvm::equal (getIndexingMaps (), indexingMaps)) {
3598
3584
p << " indexing_maps = [" ;
3599
3585
llvm::interleaveComma (getIndexingMaps (), p,
0 commit comments