-
Notifications
You must be signed in to change notification settings - Fork 83
[torchlib] Implement torch.ops.prims.broadcast_in_dim.default #2382
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
Conversation
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
torch.ops.prims.broadcast_in_dim.default
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2382 +/- ##
==========================================
+ Coverage 70.31% 70.33% +0.01%
==========================================
Files 222 222
Lines 26647 26657 +10
Branches 2664 2666 +2
==========================================
+ Hits 18738 18749 +11
+ Misses 6993 6992 -1
Partials 916 916 ☔ View full report in Codecov by Sentry. |
…ions Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
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.
lintrunner found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
… review Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
…in review Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
What does broadcast_in_dim do? |
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
The proposed implementation is equivalent to the decomposition of broadcast_in_dims in pytorch. |
Will find ways to test as a follow up |
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.
Is there a test case?
This comment was marked as resolved.
This comment was marked as resolved.
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Added tests |
This PR implements the missing
torch.ops.prims.broadcast_in_dim.default
operation that appears in BERT_pytorch and other PyTorch models.Overview
The
broadcast_in_dim
operation is a primitive that broadcasts a tensor to a target shape by specifying which dimensions of the output correspond to the input tensor dimensions. This is different from standard broadcasting operations.Implementation Details
Function signature:
Parameters:
a
: Input tensor to broadcastshape
: Target output shapebroadcast_dimensions
: Specifies which dimensions of the output shape correspond to the input tensor dimensionsExample:
Fixes #2218. Fix pytorch/pytorch#135343