Skip to content

Align the bufferization pipeline according to the upstream doc #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

zhczhong
Copy link
Member

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).

bufferization::OneShotBufferizationOptions options;
options.bufferizeFunctionBoundaries = true;
options.setFunctionBoundaryTypeConversion(
bufferization::LayoutMapOption::IdentityLayoutMap);
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
Member 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
Member 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
6 checks passed
@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.

4 participants