Add support for sensor_msgs/Image in torch_conversions - #17
Open
nvcyc wants to merge 1 commit into
Open
Conversation
nvcyc
marked this pull request as ready for review
August 28, 2026 16:17
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.
Description
Add native
sensor_msgs/msg/Imagesupport totorch_conversionslibrary.This change introduces APIs to:
The conversion path maintains CUDA buffer lifetime and stream-event ordering without introducing device or stream synchronization. It supports packed, byte-oriented encodings and validates encodings,
buffer sizes, row strides, tensor shapes, and data types.
Is this user-facing behavior change?
Yes. Users can now convert native ROS
sensor_msgs/msg/Imagemessages directly to and from PyTorchat::Tensorobjects.Images are represented as HWC tensors. Zero-copy input views are available by passing
clone=false.Did you use Generative AI?
OpenAI Codex (GPT-5) was used to draft the changes in this pull request.
Additional Information
The current implementation supports packed, 8-bit-per-channel encodings, including
mono8,rgb8,bgr8,rgba8, Bayer8, YUV422, and8UC/8SCencodings. Planar and non-byte encodings are rejectedwith descriptive errors.
For zero-copy CPU input views, the source message must remain alive while the tensor is in use. CUDA views retain the appropriate buffer handles and stream-event dependencies for the tensor lifetime.