Add ONNX Runtime tensor conversions

Open
#14 0 comments 0 reactions 2 assignees View on GitHub

@yuanknv is already working on this.

Since Aug 28, 2026.

Assessment

This issue has not been assessed yet.

Description

enhancement
Description

Add an ONNX Runtime conversion package, analogous to torch_conversions, for converting tensor_msgs/msg/ExperimentalTensor to ONNX Runtime Ort::Value tensors.

Motivation

The repository currently provides torch_conversions, which bridges ExperimentalTensor and at::Tensor. Supporting ONNX Runtime would enable the same underlying buffer infrastructure to be used for inference deployments that do not want to depend on PyTorch or LibTorch.

The Special Interest Group for Physical AI is interested in running inference with ONNX as part of our demos in addition to pytorch based inference.

Design / Implementation Considerations

A target pipeline would look like:

ROS publisher
    |
ExperimentalTensor
    |
rosidl::Buffer
    |
ONNX Runtime conversion
    |
Ort::Value
    |
ONNX Runtime session

The package could expose APIs similar in spirit to torch_conversions, for example:

Ort::Value from_input_tensor_msg(
  const tensor_msgs::msg::ExperimentalTensor & msg,
  const Ort::MemoryInfo & memory_info);

Ort::Value from_output_tensor_msg(
  tensor_msgs::msg::ExperimentalTensor & msg,
  const Ort::MemoryInfo & memory_info);

Additional helpers could allocate an appropriately sized ExperimentalTensor for a given ONNX element type and shape.

Additional Information

ExperimentalTensor can represent DLPack-style shape, stride, and byte-offset metadata. ONNX Runtime's tensor API generally represents dense tensor storage and does not provide an equivalent arbitrary-strided tensor view.

For an initial implementation, rejecting unsupported layouts may be preferable to introducing hidden copies.

Dominant language
C++
Stars
27
Forks
13
Avg merge
21d 23h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ros2/rosidl_buffer_backends

All issues in ros2/rosidl_buffer_backends

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.