[Mlir-commits] [mlir] [mlir][linalg] Introduce transpose semantic to 'linalg.matmul' ops. (PR #104783)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Oct 3 11:23:14 PDT 2024


================
@@ -149,15 +154,41 @@ static void fillStructuredOpRegion(OpBuilder &opBuilder, Region &region,
   // iterator_types is an auto-generated method.
 }
 
+/// Helper to create a typical indexing map for MatmulOp. Returns a list of
+/// AffineMap.
+static SmallVector<AffineMap, 3>
+inferDefaultIndexingMaps(MLIRContext *context) {
+  AffineExpr d0, d1, d2;
+  SmallVector<AffineMap, 3> indexingMaps;
+  bindDims(context, d0, d1, d2);
+  indexingMaps.push_back(AffineMap::get(3, 0, {d0, d2}, context));
+  indexingMaps.push_back(AffineMap::get(3, 0, {d2, d1}, context));
+  indexingMaps.push_back(AffineMap::get(3, 0, {d0, d1}, context));
+  return indexingMaps;
+}
+
+/// Wrapper to return the typical indexing map array attribute for MatmulOp.
+static SmallVector<Attribute, 3>
+getDefaultIndexingMapAttr(MLIRContext *context) {
+  SmallVector<Attribute, 3> indexingMapsAttr;
----------------
MaheshRavishankar wrote:

THis could be just
```
llvm::map_to_vector(getDefaultIndexingMaps(), [](AffineMap map) { return AffineMapAttr::get(map);});
```

https://github.com/llvm/llvm-project/pull/104783


More information about the Mlir-commits mailing list