Skip to content
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

Lowering Through LLVM #26

Merged
merged 26 commits into from
Nov 1, 2023
Merged

Lowering Through LLVM #26

merged 26 commits into from
Nov 1, 2023

Conversation

j2kun
Copy link
Owner

@j2kun j2kun commented Oct 27, 2023

No description provided.

@j2kun j2kun changed the title Compile to LLVM Lowering Through LLVM Oct 27, 2023
@j2kun j2kun merged commit 7a94ad8 into main Nov 1, 2023
2 checks passed
@@ -46,6 +46,12 @@ void polyToLLVMPipelineBuilder(mlir::OpPassManager &manager) {
manager.addPass(mlir::createConvertFuncToLLVMPass());
manager.addPass(mlir::createFinalizeMemRefToLLVMConversionPass());
manager.addPass(mlir::createReconcileUnrealizedCastsPass());

// Cleanup
manager.addPass(mlir::createCanonicalizerPass());

Choose a reason for hiding this comment

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

Is there a particular reason for adding mlir::createCanonicalizerPass() two times? There's one on the top which I think was for the passes we had created and there's this one which to my understanding should be dealing with the canonicalization of the other upstream passes we added to this pipeline.

I tried to remove the first one and just keep this last one here and the binary still works correctly (just that there is some difference in the instructions being generated in the end).

Copy link
Owner Author

Choose a reason for hiding this comment

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

In general canonicalization must not change the behavior of the program (or else it would be buggy). It will only make things more efficient. Canonicalization patterns apply to particular ops in particular dialects, and higher-level canonicalization patterns tend to remove more unnecessary work than applying lower-level canonicalization patterns, since they capture a larger breadth of the overall program. Running canonicalization after every pass would be even better. But the reason we don't is because we expect it to do nothing, and it adds to the total runtime.

@Sir-NoChill
Copy link

I wanted to add for anyone having the same problem I had while following the tutorial on your website (brilliant job by the way) that in the current version of MLIR, you may have to add the

  pm.addPass(mlir::bufferization::createBufferResultsToOutParamsPass());

Pass to the lowering pipeline in order to eliminate all of the bufferization operations. I'm not 100% clear as to why, but it is an issue that I had when lowering my tensors.

Thank you for the amazing tutorial!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants