Skip to content

Let wrap() preserve metadata for custom TVTensor subclasses#9490

Merged
NicolasHug merged 3 commits into
pytorch:mainfrom
NicolasHug:wrappppp
May 14, 2026
Merged

Let wrap() preserve metadata for custom TVTensor subclasses#9490
NicolasHug merged 3 commits into
pytorch:mainfrom
NicolasHug:wrappppp

Conversation

@NicolasHug
Copy link
Copy Markdown
Member

@NicolasHug NicolasHug commented May 13, 2026

Closes #9398
Closes #9333

This PR lets custom classes passed to tv_tensors.wrap() preserve their metadata by allowing each subclass to define how it wants to be wrapped by defining a .wrap() method.

cc @vfdev-5

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 13, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9490

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the cla signed label May 13, 2026
@NicolasHug NicolasHug merged commit 4d4e406 into pytorch:main May 14, 2026
8 of 21 checks passed
@github-actions
Copy link
Copy Markdown

Hey @NicolasHug!

You merged this PR, but no labels were added.
The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@NicolasHug NicolasHug deleted the wrappppp branch May 14, 2026 08:54
yeetypete added a commit to yeetypete/vision3d that referenced this pull request May 21, 2026
- Move CameraIntrinsics torchvision-op kernels (resize/crop/center_crop/
  pad/resized_crop) from tensors/_camera.py to transforms/functional/
  _camera.py, matching torchvision's layout (kernels next to dispatchers,
  not next to tv_tensor classes). Rename them to public functional names
  (resize_camera_intrinsics, etc.), mirroring torchvision's
  resize_keypoints precedent.
- Add public wrap() classmethods to BoundingBoxes3D and CameraIntrinsics;
  rewrite vision3d.tensors.wrap() to dispatch via
  getattr(type(like), "wrap", None). Matches the dispatch introduced in
  pytorch/vision#9490 (torchvision 0.28). Vision3d's wrap() can collapse
  to a re-export once the pin bumps to torchvision>=0.28.
- Import transforms from vision3d/__init__.py so importing any vision3d
  submodule registers the v2 kernels, matching torchvision/__init__.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom TVTensor types in wrap() function (registration or like-API)

1 participant