[Mlir-commits] [mlir] c5bcda9 - [mlir][vector] Document dimension kinds in `vector.contract` (NFC) (#230458)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Oct 14 03:30:43 PDT 2026
Author: Federico Bruzzone
Date: 2026-10-14T12:30:37+02:00
New Revision: c5bcda9c7ba9614217e72b34dc69b92f6a4bdf00
URL: https://github.com/llvm/llvm-project/commit/c5bcda9c7ba9614217e72b34dc69b92f6a4bdf00
DIFF: https://github.com/llvm/llvm-project/commit/c5bcda9c7ba9614217e72b34dc69b92f6a4bdf00.diff
LOG: [mlir][vector] Document dimension kinds in `vector.contract` (NFC) (#230458)
Add a table to the `vector.contract` description summarizing _batch_,
_free_, _contracting_, and _single-operand reduction_ dimensions.
The terminology matches `linalg.contract` and [TensorFlow's einsum
implementation](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/util/einsum_op_util.h#L28-L46),
as suggested by @banach-space.
Related to #230155, issue identified in #228971 (and #229824).
---------
Signed-off-by: Federico Bruzzone <federico.bruzzone.i at gmail.com>
Added:
Modified:
mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index 83fe3165b88540..291b1d5049116f 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -100,6 +100,21 @@ def Vector_ContractionOp :
are unrelated to each other and do not co-iterate, which
should be expressed in their indexing maps.
+ Depending on its iterator type and on the operands it indexes, a dimension
+ is one of the following kinds:
+
+ | Iterator type | In output | In lhs and rhs | Kind |
+ | ------------- | --------- | -------------- | ------------------------ |
+ | "parallel" | yes | both | batch |
+ | "parallel" | yes | lhs only | free (M-like) |
+ | "parallel" | yes | rhs only | free (N-like) |
+ | "reduction" | no | both | contracting |
+ | "reduction" | no | one of them | reduction on one operand |
+
+ The M-like and N-like terms follow
+ [`linalg.contract`](https://mlir.llvm.org/docs/Dialects/Linalg/#linalgcontract-linalgcontractop)
+ terminology.
+
An indexing map attribute list must be specified with an entry for lhs, rhs
and acc arguments. An indexing map attribute specifies a mapping from each
iterator in the iterator type list, to each dimension of an N-D vector.
@@ -215,7 +230,12 @@ def Vector_ContractionOp :
void getIterationIndexMap(
std::vector<DenseMap<int64_t, int64_t>> &iterationIndexMap);
+ // Returns (lhs dim, rhs dim) pairs for the contracting dimensions:
+ // "reduction" iterators that index both lhs and rhs, and not the result.
std::vector<std::pair<int64_t, int64_t>> getContractingDimMap();
+
+ // Returns (lhs dim, rhs dim) pairs for the batch dimensions: "parallel"
+ // iterators that index lhs, rhs, and the result.
std::vector<std::pair<int64_t, int64_t>> getBatchDimMap();
static CombiningKind getDefaultKind() {
More information about the Mlir-commits
mailing list