-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Pass to eliminate redundant branch and overcompute #17170
Pass to eliminate redundant branch and overcompute #17170
Conversation
@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
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. |
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, Thanks.
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 :