# laurentmazare/tch-rs

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/laurentmazare-tch-rs).**

5,287 stars · 416 forks · Rust · apache-2.0

## Links

- GitHub: https://github.com/LaurentMazare/tch-rs
- awesome-repositories: https://awesome-repositories.com/repository/laurentmazare-tch-rs.md

## Topics

`deep-learning` `machine-learning` `neural-network` `pytorch` `rust`

## Description

This project is a Rust interface for the PyTorch C++ library, serving as a deep learning framework and tensor computing library. It functions as a C++ API wrapper that enables the manipulation of multi-dimensional arrays and the execution of neural network architectures across CPU and GPU hardware accelerators.

The library provides a TorchScript inference engine to load and execute just-in-time compiled models. It also supports Rust and Python interoperability, allowing for the creation of Python extensions that share tensor data through a common interface.

The system covers deep learning model training via automatic differentiation and gradient descent optimization, as well as model deployment using pre-trained weight imports. Additional capabilities include computer vision implementation, mixed precision computation, and CUDA device state management.

## Tags

### Part of an Awesome List

- [Neural Networks and Deep Learning](https://awesome-repositories.com/f/awesome-lists/ai/neural-networks-and-deep-learning.md) — Serves as a deep learning framework for building, training, and running neural networks with gradient tracking.
- [Artificial Intelligence](https://awesome-repositories.com/f/awesome-lists/ai/artificial-intelligence.md) — Rust bindings for the PyTorch machine learning library.
- [Deep Learning](https://awesome-repositories.com/f/awesome-lists/ai/deep-learning.md) — Rust bindings for the PyTorch C++ API.

### Data & Databases

- [Array and Tensor Manipulation](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-transformation/array-tensor-manipulation.md) — Provides comprehensive mathematical operations for reshaping and transforming multi-dimensional tensors. ([source](https://docs.rs/tch/latest/tch/))
- [High-Performance Tensor Libraries](https://awesome-repositories.com/f/data-databases/high-performance-tensor-libraries.md) — Provides high-performance multidimensional array mathematics with low-level hardware acceleration.

### Artificial Intelligence & ML

- [Automatic Differentiation Engines](https://awesome-repositories.com/f/artificial-intelligence-ml/automatic-differentiation-engines.md) — Implements a computational graph system to automatically compute gradients for optimizing neural network weights.
- [Hardware Dispatchers](https://awesome-repositories.com/f/artificial-intelligence-ml/hardware-acceleration-kernels/hardware-dispatchers.md) — Dynamically routes mathematical operations to CPU or GPU backends based on the data's device placement.
- [Inference Execution Engines](https://awesome-repositories.com/f/artificial-intelligence-ml/inference-execution-engines.md) — Provides a runtime for executing TorchScript models independently of the original Python environment.
- [Deep Learning](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/inference-engines/deep-learning.md) — Implements high-performance runtimes that execute neural network models across CPUs and GPUs. ([source](https://docs.rs/tch/index.html))
- [Tensor Computing Libraries](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-optimization-and-inference/hardware-and-acceleration/tensor-computing-libraries.md) — Provides a high-performance numerical library for manipulating multi-dimensional arrays across CPU and GPU accelerators.
- [Tensor Memory Management](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-optimization-and-inference/hardware-and-acceleration/tensor-computing-libraries/tensor-memory-management.md) — Manages the allocation and placement of multi-dimensional arrays across different hardware devices. ([source](https://docs.rs/tch/0.24.0/tch/))
- [Neural Network Construction](https://awesome-repositories.com/f/artificial-intelligence-ml/neural-network-construction.md) — Enables the definition of custom network layers and sequential modules to build deep learning architectures. ([source](https://cdn.jsdelivr.net/gh/laurentmazare/tch-rs@main/README.md))
- [Gradient Descent Algorithms](https://awesome-repositories.com/f/artificial-intelligence-ml/optimization-algorithms/gradient-descent-algorithms.md) — Implements gradient descent algorithms to minimize loss functions via automatic differentiation. ([source](https://cdn.jsdelivr.net/gh/laurentmazare/tch-rs@main/README.md))
- [PyTorch Backends](https://awesome-repositories.com/f/artificial-intelligence-ml/pytorch-backends.md) — Implements a Rust interface that leverages PyTorch for tensor operations and GPU acceleration.
- [Framework Interoperability Layers](https://awesome-repositories.com/f/artificial-intelligence-ml/framework-interoperability-layers.md) — Provides an interface connecting low-level C++ APIs with high-level language logic to execute tensor computations. ([source](https://docs.rs/tch/index/index.html))
- [Gradient Computation](https://awesome-repositories.com/f/artificial-intelligence-ml/gradient-computation.md) — Includes mechanisms to control gradient tracking to optimize memory during inference. ([source](https://docs.rs/tch/))
- [Computer Vision](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/frameworks/computer-vision.md) — Provides toolkits for developing deep learning applications focused on image processing and computer vision.
- [Mixed-Precision Computing](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/machine-learning-training/distributed-and-accelerated-compute/training-acceleration-tools/mixed-precision-training/mixed-precision-computing.md) — Supports operations using various numerical precisions to increase throughput and reduce memory bandwidth. ([source](https://docs.rs/tch/latest/tch/))
- [Model Deployment Runtimes](https://awesome-repositories.com/f/artificial-intelligence-ml/model-deployment-runtimes.md) — Runs pre-trained or JIT-compiled PyTorch models for fast inference and predictions in production environments.
- [Model Execution Interfaces](https://awesome-repositories.com/f/artificial-intelligence-ml/model-execution-interfaces.md) — Provides interfaces for loading and running machine learning models trained in external environments. ([source](https://docs.rs/tch/0.24.0/tch/))
- [Model Predictions](https://awesome-repositories.com/f/artificial-intelligence-ml/model-predictions.md) — Supports loading saved model weights to perform forward passes and generate predictions. ([source](https://cdn.jsdelivr.net/gh/laurentmazare/tch-rs@main/README.md))
- [Model Runtimes](https://awesome-repositories.com/f/artificial-intelligence-ml/model-runtimes.md) — Provides a runtime for loading and executing serialized TorchScript models independently of the training environment.
- [Visual Content Analysis](https://awesome-repositories.com/f/artificial-intelligence-ml/visual-content-analysis.md) — Provides specialized functions and pre-defined models for analyzing images and video content. ([source](https://docs.rs/tch/0.24.0/tch/))

### Programming Languages & Runtimes

- [C-API Wrappers](https://awesome-repositories.com/f/programming-languages-runtimes/c-api-wrappers.md) — Wraps low-level C++ tensor operations in an ergonomic object-oriented layer for Rust.

### Scientific & Mathematical Computing

- [Computational Backend Integrations](https://awesome-repositories.com/f/scientific-mathematical-computing/computational-backend-integrations.md) — Delegates high-performance numerical computations and tensor manipulations to the LibTorch C++ backend.

### Development Tools & Productivity

- [Rust Python Extension Developers](https://awesome-repositories.com/f/development-tools-productivity/compilers-toolchains/c-extension-interfaces/c-extension-development/rust-python-extension-developers.md) — Provides a mechanism for building performance-sensitive Python extensions using Rust and shared tensor interfaces. ([source](https://github.com/LaurentMazare/tch-rs/blob/main/CHANGELOG.md))
