[Mlir-commits] [mlir] [mlir][vector] Clarify the semantics of BroadcastOp (PR #101928)
Hugo Trachino
llvmlistbot at llvm.org
Mon Aug 5 02:47:45 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:
It got me thinking, what would be the expected behaviour of something like:
```
%0 = vector.broadcast %arg0 : vector<nxf32> to vector<[n]xf32>
```
IMO it should not be supported as physically equivalent to a usecase
```
%1 = vector.broadcast %arg0 : vector<nxf32> to vector<vscale*nxf32>
```
Which is not invalid for fixed dimensions. Do you think this handles the cases ?
```suggestion
(srcDimScalableFlag != dstDimScalableFlag))
```
https://github.com/llvm/llvm-project/pull/101928
More information about the Mlir-commits
mailing list