zml/tensor: respect tags in broad#643
Open
ousamabenyounes wants to merge 1 commit into
Open
Conversation
Contributor
|
thanks, this is big change since it can break existing code. I'll try to re-prioritize this. |
ousamabenyounes
force-pushed
the
fix/issue-68-tagged-broad
branch
from
July 11, 2026 08:00
6cf3f26 to
3f7d618
Compare
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.
Summary
Make
Tensor.broadrespect tags when both input and output shapes are fully tagged, and makeShape.canBroadcastToreject fully tagged positional matches that do not map by tag.Issues
Fix #68
Why
The issue case
.{ .a = 8, .l = 1, .k = 16 }.broad(.{ .a = 8, .k = 16, .v = 16 })was accepted by positional broadcasting even though the tags do not describe the same axes. Fully tagged shapes should match and broadcast by tag, not by position.The implementation keeps the integer scalar broadcast compatibility hook ahead of tagged broadcasting and excludes rank-0 shapes from the tagged branch so backend compatibility behavior is preserved.
Test verification (RED -> GREEN)
Command:
./bazel.sh test //zml:testRED with the production fix reverted while keeping the new tests:
GREEN on the final branch: