Tensor IPC
High-performance and Flexible IPC for tensor data with seamless ROS integration for robotics research.
Overview
tensor-ipc provides efficient shared memory communication for tensor data between processes, with built-in support for ROS topics. It enables zero-copy data sharing using POSIX shared memory and integrates with ROS for distributed communication and sim/real transfer.
Key Features
- 🚀 Zero-Copy Shared Memory: POSIX shared memory with per-frame locking for safe concurrent access
- 🤖 ROS Integration: Built-in ROS producers and consumers with automatic type conversion (custom types are supported through ros2_numpy)
- 🧠 Multi-Backend Support: Native support for NumPy arrays and PyTorch tensors (CPU/CUDA)
- 📦 DDS Notifications: Real-time notifications and synchronization using CycloneDDS for efficient polling
- 🛡️ Type Safety: Automatic validation of tensor shapes, dtypes, and devices
- 🔄 History Management: Configurable history buffers with circular indexing
Installation
git clone https://github.com/danielhou315/tensor-ipc.git
cd tensor-ipc
pip install -e .
- For torch/torch CUDA support, you must install
torchin the same Python environment. - For ROS support, you must install ros2_numpy in the same Python environment.
- Otherwise, only
numpybackend will be available.
Quick Start
Refer to examples/ to see basic usage. Documentation is coming soon (hopefully).
CUDA Support
import torch
from tensor_ipc.core.producer import TensorProducer
# CUDA tensors with IPC sharing
if torch.cuda.is_available():
cuda_tensor = torch.zeros(3, 224, 224, device='cuda:0')
producer = TensorProducer.from_sample("cuda_pool", cuda_tensor)
# Publish CUDA tensor directly
gpu_data = torch.randn(3, 224, 224, device='cuda:0')
producer.put(gpu_data)
Callbacks and Notifications
def on_new_data(data):
print(f"Callback triggered with data shape: {data.shape}")
consumer = TensorConsumer(
metadata,
on_new_data_callback=on_new_data
)
# Callback will be triggered when new data arrives
History Management
# Get last 5 frames in chronological order
history = consumer.get(history_len=5, latest_first=False)
# Get last 3 frames with latest first
recent = consumer.get(history_len=3, latest_first=True)
Architecture
- Backends: Pluggable backends for NumPy, PyTorch CPU, and PyTorch CUDA
- Shared Memory: Numpy/PyTorch backend uses POSIX shared memory with memory-mapped arrays. Torch CUDA backend uses CUDA API through PyTorch.
- Locking: Per-frame reader-writer locks for safe concurrent access
- Notifications: CycloneDDS for real-time progress updates
- ROS Bridge: Automatic conversion between ROS messages and tensor data
API Reference
Core Classes
TensorProducer: Creates and publishes to shared memory poolsTensorConsumer: Subscribes to and reads from shared memory poolsPoolMetadata: Describes pool structure and properties
ROS Extensions
ROSTensorProducer: Publishes shared memory data to ROS topicsROSTensorConsumer: Subscribes to ROS topics and creates shared memory pools
Metadata Creation
MetadataCreator.from_numpy_sample(): Create metadata from NumPy arraysMetadataCreator.from_torch_sample(): Create metadata from PyTorch tensorsMetadataCreator.from_torch_cuda_sample(): Create metadata for CUDA tensorsMetadataCreator.from_sample(): Unifies creation of metadata from sample
Requirements
- Python 3.7+
- NumPy
- CycloneDDS (for DDS notifications)
- Optional: PyTorch (for tensor support)
- Optional: ROS 2 + ros2_numpy (for ROS integration)
License
MIT License
GenAI
This library (especially documentation) is partly written by various LLMs.
Metadata
Release files for tensor-ipc 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tensor_ipc-0.1.0.tar.gz | 36.8 kB | Without provenance | Details for tensor_ipc-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tensor_ipc-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tensor_ipc-0.1.0-py3-none-any.whl |
Total release size: 64.9 kB
Release files / tensor_ipc-0.1.0.tar.gz
| Download URL | tensor_ipc-0.1.0.tar.gz |
|---|---|
| Size | 36.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70c8548116c9555aedcbfa00e2057b2d6c52863d8f64c77947bee26fc465f658
|
|
BLAKE2b-256 checksum How to use checksums |
c74a071d8bcddd154bde1e9d54fafdcae570698fbf116ff9f4e3adecf30d45b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / tensor_ipc-0.1.0-py3-none-any.whl
| Download URL | tensor_ipc-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed072c3aa755c5c997ed3b6cfe7ed9c66878ffa14e444b56878bde43a7e695dc
|
|
BLAKE2b-256 checksum How to use checksums |
dff3231948a89a4a49e187d42e46abf4ba72e4fc68f3e57a74b5a73f44a19bce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for tensor-ipc 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.