[Mlir-commits] [mlir] [MLIR][Vector]Add constraints to vector.shape_cast(constant) -> constant (PR #147691)
Mengmeng Sun
llvmlistbot at llvm.org
Mon Jul 14 01:21:46 PDT 2025
MengmSun wrote:
> > > %0 = llvm.mlir.constant(dense<0.000000e+00> : vector<12xf8E4M3FN>) : vector<12xi8>
> >
> >
> > The following question is unrelated but I've seen this popping up multiple times lately: why `llvm.mlir.constant` allows the attribute and the return type to mismatch?
>
> I think this is actually central to the PR!
After investigation this is probably caused by the lowering process of arith constrained vector in the `ConvertToLLVMPass`. It lastly called [LLVM::detail::vectorOneToOneRewrite()](https://github.com/llvm/llvm-project/blob/040e7ad8281dcb52507070fbeec59421af78c5ca/mlir/include/mlir/Conversion/LLVMCommon/VectorPattern.h#L104C2-L107C41) to lower `%cst = arith.constant dense<0.000000e+00> : vector<192xf8E4M3FN>` and the value of the attribute parameter is returned by `attrConvert.getAttrs()` which is the attributes of the source op. And in the lowering process, the `typeConverter` convert `f8E4M3FN` to `i8`. So after this pass,
```bash
%cst = arith.constant dense<0.000000e+00> : vector<192xf8E4M3FN>
```
will be
```bash
%4 = llvm.mlir.constant(dense<0.000000e+00> : vector<192xf8E4M3FN>) : vector<192xi8>
```
>From our perspective, if the logic of lowering constrained vector needs to be re-considered it must be a big change and will not last in a short term. We hope to just fix our current problem in this PR.
https://github.com/llvm/llvm-project/pull/147691
More information about the Mlir-commits
mailing list