[Mlir-commits] [mlir] [mlir][vector] Refine vector.transfer_read hoisting/forwarding (PR #65770)

Andrzej WarzyƄski llvmlistbot at llvm.org
Tue Sep 12 02:14:52 PDT 2023


banach-space wrote:

> Btw, can you perform the hoisting on tensors instead of memrefs? There are no aliasing issues when hoisting before bufferization. 

Tl;Dr Possibly. It looks like in many cases hoisting happens _before_ bufferization, but not always. 

I'm experimenting with some optimisations for Linalg Convs and use IREE to drive this. Looking at 
* [Codegen/LLVMCPU/Passes.cpp](https://github.com/openxla/iree/blob/main/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp) (I only use CPU pipelines), 

[addBufferizePasses](https://github.com/openxla/iree/blob/3343f24363dffa7e4602305d33627302d8c0bd6c/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp#L128-L134) is usually run after e.g. [createHoistRedundantVectorTransfersPass](https://github.com/openxla/iree/blob/3343f24363dffa7e4602305d33627302d8c0bd6c/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp#L569-L570). However, in the case of convolutions, [OptimizeVectorTransferPass](https://github.com/openxla/iree/blob/3343f24363dffa7e4602305d33627302d8c0bd6c/compiler/src/iree/compiler/Codegen/Common/OptimizeVectorTransferPass.cpp#L139-L142) is [created](https://github.com/openxla/iree/blob/3343f24363dffa7e4602305d33627302d8c0bd6c/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp#L579-L583) after bufferization and that pass also [includes](https://github.com/openxla/iree/blob/3343f24363dffa7e4602305d33627302d8c0bd6c/compiler/src/iree/compiler/Codegen/Common/OptimizeVectorTransferPass.cpp#L83) `hoistRedundantVectorTransfers`.

I've only tried few pipelines so far, so might be missing something. Also, I have a few experiments "downstream" on top of this that trigger these aliasing issue. So, on hand, having this fix in-tree helps me focus on other issues, but I might be doing something daft myself. 

I'll add a few TODOs before landing this. Mostly as a reminder that a more generic approach should be implemented instead.

https://github.com/llvm/llvm-project/pull/65770


More information about the Mlir-commits mailing list