LaurentMazare/tch-rs
Rust bindings for the C++ api of PyTorch.
What it solves
tch-rs provides Rust bindings for the PyTorch C++ API (libtorch), allowing developers to use PyTorch's powerful tensor operations, automatic differentiation, and neural network modules directly within the Rust programming language. This enables the creation of high-performance AI models and applications while leveraging Rust's safety and concurrency features.
How it works
The project provides thin wrappers around the C++ libtorch library. It allows users to interact with PyTorch tensors and neural network components through a Rust interface that stays close to the original C++ API. The crate can link against a system-wide libtorch installation, a Python PyTorch installation, or download a pre-built binary of libtorch automatically.
Who it’s for
Developers who want to use PyTorch's deep learning capabilities in Rust, whether for training models from scratch, running inference on pre-trained weights (including support for SafeTensors), or deploying models via TorchScript JIT.
Highlights
- PyTorch Integration: Direct bindings to libtorch for tensor operations and automatic differentiation.
- Neural Network API: Tools to build architectures using
nn::seqandnn::VarStorefor parameter management. - Flexible Linking: Supports system-wide, Python-based, or automatic binary downloads of libtorch.
- Weight Loading: Ability to import pre-trained weights from PyTorch using the SafeTensors format.
- Broad Application Examples: Includes implementations for MNIST, ResNet, character-level RNNs, and a simplified GPT.
Related
- Project
- Project
- Project
- Project
- Project