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

[Hexagon] Simplify Mul->Sub->Conv to Conv->Add when possible #15367

Merged
merged 2 commits into from
Jul 21, 2023

Conversation

arangasa
Copy link
Contributor

When one of the inputs to Mul and Sub are constant scalars, we have the following algebraic identity:
Let res[p,q,r,s] denote the result of Mul(a, c1)->Sub(c2)->Conv(W) pattern
res[p,q,r,s] = Conv(ac1 - c2, W)
= SUM{i=[0,c-1], j=[0,kh-1], k=[0,kw-1]}
{(a[p,i,r+j,s+k] * c1 - c2) * W[q,i,j,k]}
= SUM{i=[0,c-1], j=[0,kh-1], k=[0,kw-1]}
{a[p,i,r+j,s+k] * c1 * W[q,i,j,k]} - c2 * W[q,i,j,k]}
= Conv(a, W
c1) + Conv(0-c2, W)
Since Conv(0-c2,W) and W*c1 are constant terms, they could be computed during compile time.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jul 20, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@arangasa
Copy link
Contributor Author

@arangasa arangasa changed the title [Relay] Simplify Mul->Sub->Conv to Conv->Add when possible [Hexagon] Simplify Mul->Sub->Conv to Conv->Add when possible Jul 20, 2023
@quic-sanirudh quic-sanirudh self-assigned this Jul 21, 2023
@quic-sanirudh quic-sanirudh self-requested a review July 21, 2023 13:04
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.

@quic-sanirudh quic-sanirudh merged commit d8c0676 into apache:main Jul 21, 2023
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