rusttorch-core
Tensor computation, automatic differentiation, device selection, and shared
error types for RustTorch. Use this small package when you need tensor math
without the model-building or data-loading facade; use rusttorch when you
also need layers and optimizers.
Installation
[]
= { = "0.4", = ["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 ;
Use resolve_device(DeviceSpec::Auto) to choose an available accelerator or
CPU, and create or move tensors onto that device. Use no_grad for inference
or parameter assignment. The API guide has
examples of matrix multiplication, backend selection, and gradients.