rusttorch-core 0.2.0

Shared runtime, device, tensor, and error contracts for RustTorch
Documentation

rusttorch-core

Shared runtime, device, tensor, and error contracts for RustTorch.

Installation

[dependencies]
rusttorch-core = { version = "0.2", features = ["download-libtorch"] }

Features

This package has no default features. download-libtorch lets tch acquire its compatible LibTorch 2.13.0 runtime. doc-only is for checks and rustdoc; it intentionally does not provide a runtime for an executable.

Native runtime

An executable needs LibTorch/PyTorch 2.13.0, matching tch 0.26.0. Use download-libtorch, or disable default features and build with either LIBTORCH_USE_PYTORCH=1 against an installed Python torch 2.13.0 or LIBTORCH=/absolute/path/to/libtorch. The platform dynamic loader must find the selected runtime's shared libraries when the executable runs.

Example

use rusttorch_core::{Device, Kind, Result, Tensor};

fn main() -> Result<()> {
    let zeros = Tensor::f_zeros([2], (Kind::Float, Device::Cpu))?;
    assert_eq!(zeros.size(), [2]);
    Ok(())
}