Skip to content

feat(label_tensor): add dim parameter to LabelTensor.stack method - #835

Open
s-chudmunge wants to merge 2 commits into
PINA-org:masterfrom
s-chudmunge:feat/labeltensor-stack-dim
Open

feat(label_tensor): add dim parameter to LabelTensor.stack method#835
s-chudmunge wants to merge 2 commits into
PINA-org:masterfrom
s-chudmunge:feat/labeltensor-stack-dim

Conversation

@s-chudmunge

Copy link
Copy Markdown

Resolves #770

Summary

Exposes the dim parameter in LabelTensor.stack(tensors, dim=0) to align with torch.stack.

Key Changes

  • Added dim=0 argument to LabelTensor.stack with support for positive and negative dimension indices.
  • Validates bounds [-(ndim + 1), ndim] matching torch.stack.
  • Dynamically updates _labels dimension indices by shifting indices at or after dim by +1.
  • Validates consistency of input tensors and their stored labels.
  • Added comprehensive unit tests in tests/test_label_tensor/test_label_tensor.py covering dim=0, dim=1, and negative indexing.

@s-chudmunge
s-chudmunge requested a review from ndem0 as a code owner September 10, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dim parameter to LabelTensor.stack method

1 participant