Open
Conversation
Author
Collaborator
|
I've added @tanyokwok - the author of the code - as reviewer. I'm not personally familiar with the StableHLO pathway code. |
Author
|
Seems @tanyokwok is no longer active:) Do you know any one I can ask for review? Thanks |
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.
Fix empty indices for
gatherop (torch.embeddingzero-dimension crash)Problem
torch.embedding(weight, indices)should support indices tensors of any shape, including those with a zero-sized dimension. Given:weight.shape = [vocab_size, embedding_dim]indices.shape = [d1, d2, ..., dn]The expected output shape is
[d1, d2, ..., dn, embedding_dim], and this should hold even when anydi = 0(producing an empty output tensor).Previously, the lowering of
torch.embeddingto thegatherop would fail or produce incorrect results when any dimension ofindiceswas zero. This is a valid and common case in practice — for example, when batching sequences of variable length that are filtered down to an empty set.Fix
Handle the empty-indices edge case in the
gatherop lowering so that whenindicescontains a zero-sized dimension, the op correctly produces an output tensor of the expected shape with zero elements, rather than crashing or emitting incorrect IR.Testing
Added a test case covering
torch.embeddingwith zero-sized indices to verify correct shape inference and lowering behavior.