[Mlir-commits] [mlir] [mlir][vector] Clarify the semantics of BroadcastOp (PR #101928)
Hugo Trachino
llvmlistbot at llvm.org
Mon Aug 5 03:38:18 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))
----------------
nujaa wrote:
The case I pointed out was more src = `2` and dest = `[2]`. srcDim == dstDim, so no mismatch on line 2399. and we have `!srcDimScalableFlag` so no mismatch on line 2406. Whereas I think this is wrong.
```
%0 = vector.broadcast %arg0 : vector<2xf32> to vector<[2]xf32>
```
https://github.com/llvm/llvm-project/pull/101928
More information about the Mlir-commits
mailing list