Repository navigation
[VectorDistribution] Add scalar support for distributing multi-dim reduction (1/4) - #18784
bangtianliu wants to merge 2 commits into
Conversation
Signed-off-by: Bangtian Liu <[email protected]>
|
Sharing a tip based on my review experience. I've seen people put |
Thanks for your code reviews! I appreciate it very much and will see how to apply all of them. |
Groverkss
left a comment
There was a problem hiding this comment.
LGTM mostly. Once Jakub's comments are addressed we can land this.
Signed-off-by: Bangtian Liu <[email protected]>
| resElemTy = resVector.getType().getElementType(); | ||
| } else { | ||
| resElemTy = resType; | ||
| } |
There was a problem hiding this comment.
use getElementTypeOrSelf
| if (accVector) { | ||
| disAcc = getDistributed(rewriter, accVector, signature[accVector]); | ||
| } else { | ||
| disAcc = multiReduceOp.getAcc(); |
There was a problem hiding this comment.
Add a comment here that scalars are always distributed to all threads already.
| VectorType vecType = VectorType::get(SmallVector<int64_t>{1}, elemTy); | ||
| locallyReduced = rewriter.create<vector::BroadcastOp>( | ||
| loc, vecType, localReduction.getResult()); | ||
| } |
There was a problem hiding this comment.
Add a comment that we broadcast scalar accumulator to vector.
| if (!accVector) { | ||
| disAcc = rewriter.create<vector::BroadcastOp>(loc, shaped, disAcc); | ||
| } |
There was a problem hiding this comment.
Add a comment that we broadcast scalar to vector and why.
…ion with scalars (#18800) Splitting #18519 into four patches. Depends #18784 This is the second one, adding the corresponding layout analysis and especially supporting the case where reduction is performed inside scf.for operation. Also, the relevant tests are added. Since patch 2 includes changes from patch #18784, the necessary updates from the first patch have also been included here. --------- Signed-off-by: Bangtian Liu <[email protected]>
| if (accVector) { | ||
| locallyReduced = dyn_cast<VectorValue>(localReduction.getResult()); | ||
| } else { | ||
| VectorType vecType = VectorType::get(SmallVector<int64_t>{1}, elemTy); |
There was a problem hiding this comment.
You should be able to use ArrayRef here instead of constructing a vector
| replaceOpWithDistributedValues(rewriter, multiReduceOp, accReduced); | ||
| } else { | ||
| Value accReducedVal = rewriter.create<vector::ExtractOp>( | ||
| loc, accReduction, SmallVector<int64_t>{0}); |
|
All the above comments have been applied to #18800, which includes the content from this patch and has already been merged. This PR can now be closed. |
…ion with scalars (#18800) Splitting #18519 into four patches. Depends #18784 This is the second one, adding the corresponding layout analysis and especially supporting the case where reduction is performed inside scf.for operation. Also, the relevant tests are added. Since patch 2 includes changes from patch #18784, the necessary updates from the first patch have also been included here. --------- Signed-off-by: Bangtian Liu <[email protected]> Signed-off-by: Elias Joseph <[email protected]>
…ion with scalars (iree-org#18800) Splitting iree-org#18519 into four patches. Depends iree-org#18784 This is the second one, adding the corresponding layout analysis and especially supporting the case where reduction is performed inside scf.for operation. Also, the relevant tests are added. Since patch 2 includes changes from patch iree-org#18784, the necessary updates from the first patch have also been included here. --------- Signed-off-by: Bangtian Liu <[email protected]> Signed-off-by: Giacomo Serafini <[email protected]>
Splitting #18519 into four patches.
This is the first one, supporting the case where vector.multi_reduction performs reduction along all dimensions and returns a scalar.