[Mlir-commits] [mlir] [MLIR][Linalg] Introduce linalg.contract (PR #123618)

Andrzej Warzyński llvmlistbot at llvm.org
Tue Jan 28 00:06:32 PST 2025


================
@@ -680,6 +680,125 @@ def MatmulOp : LinalgStructuredBase_Op<"matmul", [
     }];
 }
 
+//===----------------------------------------------------------------------===//
+// Contract op.
+//===----------------------------------------------------------------------===//
+
+def ContractOp : LinalgStructuredBase_Op<"contract", [
+               AttrSizedOperandSegments,
+               LinalgContractionOpInterface]> {
+  let summary = [{
+    Perform a contraction on two inputs, accumulating on top of a third.
+  }];
+  let description = [{
+    The semantics of contracting inputs `A` and `B` on top of `C` to produce
+    output `D` is given by
+
+      `D[H] = (SUM_{(I ∪ J) \ H} A[I] * B[J]) + C[H]`
----------------
banach-space wrote:

Thanks for the reference! 

>From what I can see, we didn't really "explore" that thread. In my mental model (and for consistency with `vector.contract`), we should only really control the combining Op.

This is something that we can totally resolve later, but it would be good to document this.

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


More information about the Mlir-commits mailing list