Steps of migrating to one-shot bufferization

Hi all,

We are trying to migrate our custom conversion-based bufferization to the one-shot one. In the documentation (Bufferization - MLIR), there is a preprocessing step for destination passing style before the bufferization. When migrating to one-shot bufferization, should we handle destination passing style preprocessing first? Or can we handle it later after we make our newly converted one-shot bufferization work?

To our understanding, destination passing style aims to improve memory footprint. So we think the step could be optional. We are wondering if it is practical to transform the conversion-based passes first, handle the deallocation pipeline, and then go back to destination passing style.

Thanks in advance!

That’s correct. The preprocessing steps are optional. One-Shot Bufferize was designed for ops that are in DPS (destination-passing style). Ops that are not in DPS can still be bufferized, but a new buffer will be allocated for every tensor result. That’s functionally correct but inefficient.

I’m not sure whether it’s better to first migrate to the new bufferization, then turn the ops into DPS ops, or do it the other way around. One benefit of implementing the bufferization first is that it’s a smaller step that you can already run end-to-end. And you can think of the DPS of a performance improvement on top of it.

Thank you for your confirmation. We will explore the option of handling the bufferization first to see how everything goes on.