Pass to eliminate redundant branch and overcompute#17170
Merged
quic-sanirudh merged 9 commits intoJul 25, 2024
Merged
Conversation
Contributor
Author
|
@jverma-quic and @quic-sanirudh can you please review the PR? |
…or padding and overcompute, this creates more opportunities to vectorize the code
…_assume_to_reduce_branches.cc
b9be8ce to
d7c7e22
Compare
… running into some other issue because of which build was failing
Contributor
Author
|
After making changes in the way we identify the elementwise op (i.e from the op pattern), I have tested the pass with the test cases only. In resent50 the op_pattern value for elementwise ops is set to 8 (i.e kOpaque), because of which when we check for an op to be elementwise op using op_pattern it may not give correct results. Hence, there is slight change in downstream where we identify an op by the path op_attrs -> op_name -> op_kind. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This C++ pass iterates through the primfunc and finds if there is an if_then_else branch related to layout specific padding where we can leverage from assume statement, remove the extra branch and over-compute.
This pass works if the branch has the buffer present in its then_clause or else_clause for which buffer assumption exists. If there are intermediate buffers, then we need to inline the code to use the pass. This pass first parses the assume statement and then uses the information to simplify the expression in the then_clause and else_clause in then_condition_context and else_condition_context. It then decides to eliminate the branch if then_clause and else_clause evaluates to same value in then_condition_context (since then_clause will be true in this context and if else_clause is also evaluating to true then we can directly replace it with else_clause), it returns the then_clause if we are in the else_condition_context and then_clause and else_clause evaluates to same value.
Please find the image for reference :

