[Mlir-commits] [mlir] [mlir][vector] Add support for multi-dim reduction vector distribution (PR #71193)

Kunwar Grover llvmlistbot at llvm.org
Tue Nov 7 21:48:01 PST 2023


================
@@ -425,23 +425,48 @@ static vector::TransferWriteOp cloneWriteOp(RewriterBase &rewriter,
 /// Return the distributed vector type based on the original type and the
 /// distribution map. The map is expected to have a dimension equal to the
 /// original type rank and should be a projection where the results are the
-/// distributed dimensions. The number of results should be equal to the number
-/// of warp sizes which is currently limited to 1.
-/// Example: For a vector<16x32x64> distributed with a map(d0, d1, d2) -> (d1)
-/// and a warp size of 16 would distribute the second dimension (associated to
-/// d1) and return vector<16x2x64>
+/// distributed dimensions. The vector should be completely distributably, i.e.
+/// the linearized shape should be a multiple of the warp size.
+/// Example (single-dim): For a vector<16x32x64> distributed with
+/// a map(d0, d1, d2) -> (d1) and a warp size of 16 would distribute the second
+/// dimension (associated to d1) and return vector<16x2x64>.
+/// Example (multi-dim): For a vector<16x32x64> distributed with a
+/// map(d0, d1, d2) -> (d1, d2), and a warp size of 128 would distribute first
----------------
Groverkss wrote:

I think there are some things here that are decisions and not contracts. The contract distribution map specifies is the order of indexing for distribution of the vector. getDistributedType takes this map, and uses the decision that we should distribute the leading dimensions of the final vector first, so as to get contigious chunks.

I think we should document the api contract in the documentation of DistributeMapFn, and we should document the decision in getDistributedType. What do you think?

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


More information about the Mlir-commits mailing list