-
Notifications
You must be signed in to change notification settings - Fork 493
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
base: main
Are you sure you want to change the base?
Added support for bias in optimized linear operation #9527
Conversation
🔗 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 FailuresAs of commit b5b3702 with merge base 20abf34 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Signed-off-by: David Grigoryan <[email protected]>
9c392a9
to
b5b3702
Compare
@pytorchbot label "topic: not user facing" |
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.
thanks for doing this! just some straightforward stuff to improve; the test is the most important of the concerns by far
for (size_t row = 0; row < m; ++row) { | ||
out_ptr[col * m + row] = bias_ptr[row]; | ||
} |
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.
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) { |
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.
use c10::irange. you'll need to include the header and add a buck dep. -- for (const auto col : c10::irange(n)) {
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); |
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.
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.
Summary
#8234
This PR is adding a functionality to use bias in optimized linear operation