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

[XLA:CPU][oneDNN] Alias result to addend when feasible #17637

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

akhilgoe
Copy link
Contributor

@akhilgoe akhilgoe commented Sep 26, 2024

This PR adds a new oneDNN post-op type that will perform in-place addition whenever there is no broadcast overhead. It also includes matmul and convolution tests to verify the functionality.

Copy link
Member

@penpornk penpornk left a 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 PR and sorry for the delay!

Comment on lines 148 to 150
case OneDnnFusionConfig::SUM:
post_ops.append_sum();
break;
Copy link
Member

Choose a reason for hiding this comment

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

CreateMatMulPrimDesc has been refactored to onednn_util.cc in #18527. Please rebase this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -50,6 +50,7 @@ message OneDnnFusionConfig {
ELU = 8;
RELU6 = 9;
SIGMOID = 10;
SUM = 11;
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a comment explaining that this is in-place accumulation? The name alone isn't enough to disambiguate it from BINARY_ADD.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +713 to +715
if (kind == OneDnnFusionConfig::SUM) {
custom_call->set_output_to_operand_aliasing({{{}, {addend_idx, {}}}});
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a comment in the code explaining why we need to set the aliasing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Changes in this file seem self-contained. Can we refactor it to another PR?

Copy link
Contributor Author

@akhilgoe akhilgoe Oct 29, 2024

Choose a reason for hiding this comment

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

Thanks @penpornk, yes you are right. I have created this PR #18688
I will rebase this PR to remove these changes and address your comments. Thanks!

@akhilgoe akhilgoe changed the title [XLA:CPU][oneDNN] Move addend shape checks to the rewriter and alias result to addend when feasible [XLA:CPU][oneDNN] Alias result to addend when feasible Nov 22, 2024
@akhilgoe
Copy link
Contributor Author

Thanks @penpornk for the review! I have added a commit to address your comments and created separate PRs for isolated changes.

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