[Mlir-commits] [mlir] [MLIR][Linalg] Introduce linalg.contract (PR #123618)
Rolf Morel
llvmlistbot at llvm.org
Wed Jan 29 07:45:33 PST 2025
================
@@ -680,6 +680,128 @@ def MatmulOp : LinalgStructuredBase_Op<"matmul", [
}];
}
+//===----------------------------------------------------------------------===//
+// Contract op.
+//===----------------------------------------------------------------------===//
+
+def ContractOp : LinalgStructuredBase_Op<"contract", [
+ AttrSizedOperandSegments,
+ LinalgContractionOpInterface]> {
+ let summary = [{
+ Perform a contraction on two inputs, accumulating into the 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]`
+
+ where `I`, `J`, and `H` are multi-indices, i.e. sequences/ordered sets of
+ dimension identifiers (meant to range over valid indices), corresponding to
----------------
rolfmorel wrote:
Also on this, good call! I have gone over the docs and the comments and scrubbed out the (confusing usage of) indices and co-domains and made sure that usage is consistent and clear. I think this is about as good as I am going to get it. If not, we can do doc fix-up PRs later.
> Now, given that there might be permutations, would these always be "ordered"?
The dim identifiers are ordered in the sense of tuples being ordered (so not an ordering on the underlying set but on the structure that holds multiple elements). I have just used the word tuple (with a parenthical remark that the contained dims are pairwise distinct, which guarantees the (projected) permutation property).
https://github.com/llvm/llvm-project/pull/123618
More information about the Mlir-commits
mailing list