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

Added support for bias in optimized linear operation #9527

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DavitGrigoryan132
Copy link

Summary

#8234

This PR is adding a functionality to use bias in optimized linear operation

Copy link

pytorch-bot bot commented Mar 23, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/9527

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit b5b3702 with merge base 20abf34 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

Hi @DavitGrigoryan132!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@DavitGrigoryan132 DavitGrigoryan132 force-pushed the optimized_linear_op_bias branch from 9c392a9 to b5b3702 Compare March 23, 2025 14:49
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 23, 2025
@DavitGrigoryan132
Copy link
Author

@pytorchbot label "topic: not user facing"

Copy link
Contributor

@swolchok swolchok left a comment

Choose a reason for hiding this comment

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

thanks for doing this! just some straightforward stuff to improve; the test is the most important of the concerns by far

Comment on lines +62 to +64
for (size_t row = 0; row < m; ++row) {
out_ptr[col * m + row] = bias_ptr[row];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this inner loop should probably be memcpy

auto bias_ptr = bias_value.const_data_ptr<CTYPE>();
CTYPE* out_ptr = out.mutable_data_ptr<CTYPE>();
// Broadcast the bias to every column of the output.
for (size_t col = 0; col < n; ++col) {
Copy link
Contributor

Choose a reason for hiding this comment

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

use c10::irange. you'll need to include the header and add a buck dep. -- for (const auto col : c10::irange(n)) {

Comment on lines -53 to 59
op_linear_out(x, y, out);
op_linear_out(x, y, bias, out);

Tensor expected = tf.full({3, 5}, 192);
Tensor expected = tf.full({3, 5}, 193);

EXPECT_TENSOR_EQ(out, expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

please add bias checking as a second op_linear_out call in this function rather than replacing the existing one; as written, the empty-bias path is now untested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants