[Mlir-commits] [mlir] [mlir][vector] Clarify the semantics of BroadcastOp (PR #101928)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Mon Aug 5 03:32:25 PDT 2024
================
@@ -2391,12 +2391,28 @@ mlir::vector::isBroadcastableTo(Type srcType, VectorType dstVectorType,
// (all leading dimensions are simply duplicated).
int64_t lead = dstRank - srcRank;
for (int64_t r = 0; r < srcRank; ++r) {
+ bool mismatch = false;
+
+ // Check fixed-width dims
int64_t srcDim = srcVectorType.getDimSize(r);
int64_t dstDim = dstVectorType.getDimSize(lead + r);
- if (srcDim != 1 && srcDim != dstDim) {
+ if ((srcDim != 1 && srcDim != dstDim))
+ mismatch = true;
+
+ // Check scalable flags
+ bool srcDimScalableFlag = srcVectorType.getScalableDims()[r];
+ bool dstDimScalableFlag = dstVectorType.getScalableDims()[lead + r];
+ if ((srcDim == 1 && srcDimScalableFlag && dstDim != 1) ||
+ (srcDimScalableFlag && !dstDimScalableFlag))
----------------
banach-space wrote:
If you have e.g. `[2]` and `[4]` (i.e. `vscale * 2` and `vscale * 4`), then that's already "rejected" as "mismatching dims":
* https://github.com/llvm/llvm-project/blob/0dcada94bb1ae79f0edd91013038098c62a96b3b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp#L2396
Is that the case you had in mind?
https://github.com/llvm/llvm-project/pull/101928
More information about the Mlir-commits
mailing list