Skip to content

Conversation

@zhczhong
Copy link
Contributor

Fix part of issue #288

empty_tensor_elimination could eliminate the copy introduced by bufferization.materialize_in_destination. And adjust the pipeline according to the doc(https://mlir.llvm.org/docs/Bufferization/#overview).

pm.addPass(bufferization::createOneShotBufferizePass(options));
pm.addPass(createCanonicalizerPass());
pm.addPass(createCSEPass());
pm.addPass(createCanonicalizerPass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L101 is already CanonicalizerPass, do we really need to do it again after CSE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the first CanonicalizerPass is mainly used to canonicalize the scf.for and scf.forall to the canonical form in memref, exposing more CSE optimization opportunities. The CSE pass is used to eliminate the common memref.subview so there will be some useless memref.copy memref.copy %a, %a. The last CanonicalizerPass is used to eliminate the useless memref.copy which copies from A to A like memref.copy %a, %a

pm.addPass(bufferization::createDropEquivalentBufferResultsPass());
pm.addNestedPass<func::FuncOp>(
bufferization::createPromoteBuffersToStackPass());
mlir::bufferization::BufferDeallocationPipelineOptions deallocOption;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to add mlir namespace here.
BTW, could you also put a note/link to the upstream bufferization pipeline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the advice! the mlir namespace has been removed and the note has been added

@zhczhong zhczhong merged commit b69c87a into main Aug 28, 2024
@zhczhong zhczhong deleted the zhicong/align_bufferization_pipeline branch August 29, 2024 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants