[torchlib] Implement torch.ops.prims.broadcast_in_dim.default#2382
Merged
justinchuby merged 14 commits intomainfrom Sep 12, 2025
Merged
[torchlib] Implement torch.ops.prims.broadcast_in_dim.default#2382justinchuby merged 14 commits intomainfrom
justinchuby merged 14 commits intomainfrom
Conversation
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [torchlib] Implement
[torchlib] Implement torch.ops.prims.broadcast_in_dim.default
Jun 14, 2025
torch.ops.prims.broadcast_in_dim.default
justinchuby
reviewed
Jun 14, 2025
justinchuby
reviewed
Jun 14, 2025
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>
justinchuby
reviewed
Jun 14, 2025
justinchuby
reviewed
Jun 14, 2025
Contributor
There was a problem hiding this comment.
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>
Collaborator
|
What does broadcast_in_dim do? |
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
xadupre
approved these changes
Sep 11, 2025
Member
|
The proposed implementation is equivalent to the decomposition of broadcast_in_dims in pytorch. |
Collaborator
Collaborator
|
Will find ways to test as a follow up |
justinchuby
approved these changes
Sep 11, 2025
titaiwangms
reviewed
Sep 11, 2025
Contributor
titaiwangms
left a comment
There was a problem hiding this comment.
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>
Collaborator
|
Added tests |
xadupre
approved these changes
Sep 12, 2025
xadupre
approved these changes
Sep 12, 2025
Copilot AI
added a commit
that referenced
this pull request
Apr 7, 2026
…ght initializers Add a check in _FuseBatchNormBase.check() to verify that the inbound Conv/ConvTranspose/Gemm node's weight and bias initializers are not shared with other nodes outside the matched pattern. When two Conv+BatchNorm pairs share the same weight initializer, fusing the first pair overwrites the shared initializer in the graph with fused values, leaving the second Conv node with an invalid (unregistered) weight reference, producing an invalid ONNX model. Fixes #2382 Agent-Logs-Url: https://github.com/microsoft/onnxscript/sessions/10e4a5fd-e010-48dc-8a29-991b7b0a6ca7 Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the missing
torch.ops.prims.broadcast_in_dim.defaultoperation that appears in BERT_pytorch and other PyTorch models.Overview
The
broadcast_in_dimoperation 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