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

Md Asghar Ahmad Shahid llvmlistbot at llvm.org
Sun Oct 6 23:10:13 PDT 2024


================
@@ -1139,9 +1145,76 @@ int64_t LinalgOp::getIndexingMapIndex(OpOperand *opOperand) {
          operandNumber - start;
 }
 
+/// Returns true if the result AffineExpr of the \p explicitMap is same as \p
+/// defaultMap.
+static bool isValidResultDimExprs(AffineMap explictMap, AffineMap defaultMap) {
+  auto explicitRange = explictMap.getResults();
+  auto defaultRange = defaultMap.getResults();
+  DenseSet<AffineExpr> explicitSet(explicitRange.begin(), explicitRange.end());
+  DenseSet<AffineExpr> defaultSet(defaultRange.begin(), defaultRange.end());
+  llvm::set_union(explicitSet, defaultSet);
+  DenseSet<AffineExpr> resSet(explicitSet.begin(), explicitSet.end());
+  return explicitSet == defaultSet;
+}
+
+/// Verifies the broadcast and transpose semantic sepecified by the explicit
+/// indexing map for the MatmulOp \p op for each operand specified by \p
+/// opIndex.
+static LogicalResult verifyExtendedSemantic(Operation *op, unsigned opIndex) {
----------------
shahidact wrote:

Renamed accordingly. However allowing it to take a linalg op to avoid any specific casting in `verifyStructuredOpInterface`. Instead added an assert for MatmulOp inside `verifyExtendedMatmuSemantic`.
Now the identification of extended semantic is done through a new interface in `hasUserDefinedMaps()` in LinalgInterfaces.td.

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


More information about the Mlir-commits mailing list