Skip to content

Conversation

@sdalvi-quic
Copy link
Contributor

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 :
image
image

@sdalvi-quic
Copy link
Contributor Author

@jverma-quic and @quic-sanirudh can you please review the PR?

@sdalvi-quic sdalvi-quic force-pushed the sdalvi/eliminate_pad_branch_and_overcompute branch from b9be8ce to d7c7e22 Compare July 23, 2024 01:33
… running into some other issue because of which build was failing
@sdalvi-quic
Copy link
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.

Copy link
Contributor

@quic-sanirudh quic-sanirudh left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks.

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.

2 participants