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

Andrzej Warzyński llvmlistbot at llvm.org
Mon Jan 27 05:58:49 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:

This is hard-coding the actual operation kind as summation, i.e. `+`. Apologies if I missed this somewhere, but shouldn't this be an arbitrary operation? Or is this PR meant to be limited to one kind?

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


More information about the Mlir-commits mailing list