[mlir][Vector] Improve support for 0-d vectors in vector dialect lowerings
#112,913 建立於 2024年10月18日
倉庫指標
- Star
- (26,378 star)
- PR 合併指標
- (平均合併 1天 2小時) (30 天內合併 1,000 個 PR)
描述
A number of patterns in vector dialect lowerings predate 0-d vector support and side step from 0-d vectors by converting them to scalars and then broadcasting them. An example patch fixing this: https://github.com/llvm/llvm-project/pull/112907
Some example issues:
- https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/Vector/Transforms/LowerVectorTransfer.cpp has patterns that convert vector.load/vector.store on 0-d vectors to memref.load/memref.store on scalars: https://github.com/llvm/llvm-project/blob/0a3347dc638594bef802d8148a77052c198ec27b/mlir/lib/Dialect/Vector/Transforms/LowerVectorTransfer.cpp#L524 .
I have tested removing these, and the llvm ir generated from llvm.store with 0-d vectors is correct. (Good first issue)
-
vector.multi_reduction (https://mlir.llvm.org/docs/Dialects/Vector/#vectormulti_reduction-vectormultidimreductionop) requires the result to be a scalar when all dimensions are reduced. This causes additional corner case handling for scalars in vector.multi_reduction patterns. A better solution would be to allow 0-d vectors as result of vector.multi_reduction. (Not a good first issue, requires more understanding of vector dialect)
-
Merge AnyVector and AnyVectorOfAnyRank type constraints https://github.com/llvm/llvm-project/blob/721b796809eca6e67dcefe45a3498764dda3117d/mlir/include/mlir/IR/CommonTypeConstraints.td#L661 (needs work before this can be done)