@@ -155,19 +155,6 @@ static void fillStructuredOpRegion(OpBuilder &opBuilder, Region ®ion,
155155 // iterator_types is an auto-generated method.
156156}
157157
158- // / Helper to create a typical indexing map for MatmulOp. Returns a list of
159- // / AffineMap.
160- static SmallVector<AffineMap, 3 >
161- getDefaultIndexingMapsForMatmul (MLIRContext *context) {
162- AffineExpr d0, d1, d2;
163- SmallVector<AffineMap, 3 > indexingMaps;
164- bindDims (context, d0, d1, d2);
165- indexingMaps.push_back (AffineMap::get (3 , 0 , {d0, d2}, context));
166- indexingMaps.push_back (AffineMap::get (3 , 0 , {d2, d1}, context));
167- indexingMaps.push_back (AffineMap::get (3 , 0 , {d0, d1}, context));
168- return indexingMaps;
169- }
170-
171158// / Creates a structured operation given `inputs`, `outputs`, and `attributes`.
172159// / The result types are derived automatically if `resultTensorTypes` is none.
173160// / The body of the operation is filled using `regionBuilder`. All ods-gen
@@ -200,21 +187,18 @@ static void buildStructuredOp(OpBuilder &b, OperationState &state,
200187 state.attributes .getAttrs (), regionBuilder);
201188}
202189
203- static void
204- buildMatmulOp (OpBuilder &b, OperationState &state ,
205- std::optional<TypeRange> resultTensorTypes, ValueRange inputs,
206- ValueRange outputs, ArrayRef<NamedAttribute> attributes,
207- RegionBuilderFn regionBuilder,
208- std::optional< ArrayRef<AffineMap>> indexingMaps = std:: nullopt ) {
209- // Initialize indexingMaps, for MatmulOp.
190+ static void buildMatmulOp (OpBuilder &b, OperationState &state,
191+ std::optional<TypeRange> resultTensorTypes ,
192+ ValueRange inputs, ValueRange outputs ,
193+ ArrayRef<NamedAttribute> attributes,
194+ RegionBuilderFn regionBuilder,
195+ ArrayRef<AffineMap> indexingMaps) {
196+ // Initialize indexingMaps attribute , for MatmulOp.
210197 SmallVector<Attribute, 3 > indexingMapsAttrVal;
211- if (indexingMaps.has_value ()) {
212- for (mlir::AffineMap map : *indexingMaps) {
213- // Convert each AffineMap to an AffineMapAttr
214- indexingMapsAttrVal.push_back (AffineMapAttr::get (map));
215- }
216- state.addAttribute (" indexing_maps" , b.getArrayAttr (indexingMapsAttrVal));
217- }
198+ indexingMapsAttrVal = llvm::map_to_vector (
199+ MatmulOp::getDefaultIndexingMaps (b.getContext ()),
200+ [](AffineMap map) -> Attribute { return AffineMapAttr::get (map); });
201+ state.addAttribute (" indexing_maps" , b.getArrayAttr (indexingMapsAttrVal));
218202 return buildStructuredOp (b, state, resultTensorTypes, inputs, outputs,
219203 attributes, regionBuilder);
220204}
0 commit comments