-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[mlir][inliner] Return early if the inliningThreshold is 0U or -1U. #86287
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
Conversation
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-core Author: Fabian Tschopp (naibaf7) ChangesComputing the inlinling profitability can be costly due to walking the graph when counting the number of operations. This PR addresses that by returning early if the threshold is set to never or always inline. Full diff: https://github.com/llvm/llvm-project/pull/86287.diff 1 Files Affected:
diff --git a/mlir/lib/Transforms/InlinerPass.cpp b/mlir/lib/Transforms/InlinerPass.cpp
index 08d8dbf73a6a1d..8be7868b576721 100644
--- a/mlir/lib/Transforms/InlinerPass.cpp
+++ b/mlir/lib/Transforms/InlinerPass.cpp
@@ -93,12 +93,17 @@ InlinerPass::InlinerPass(std::function<void(OpPassManager &)> defaultPipeline,
// Return true if the inlining ratio does not exceed the threshold.
static bool isProfitableToInline(const Inliner::ResolvedCall &resolvedCall,
unsigned inliningThreshold) {
+ if (inliningThreshold == 0U)
+ return false;
+ if (inliningThreshold == -1U)
+ return true;
+
Region *callerRegion = resolvedCall.sourceNode->getCallableRegion();
Region *calleeRegion = resolvedCall.targetNode->getCallableRegion();
// We should not get external nodes here, but just return true
// for now to preserve the original behavior of the inliner pass.
- if (!calleeRegion || !calleeRegion)
+ if (!callerRegion || !calleeRegion)
return true;
auto countOps = [](Region *region) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
✅ With the latest revision this PR passed the C/C++ code formatter. |
Computing the inlinling profitability can be costly due to walking the graph when counting the number of operations. This PR addresses that by returning early if the threshold is set to never or always inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix!
And I thought I had checked for this on the original revision…. Apparently not, thanks for the fix! |
Computing the inlinling profitability can be costly due to walking the graph when counting the number of operations.
This PR addresses that by returning early if the threshold is set to never or always inline.