Skip to main content

Crate rusttorch

Crate rusttorch 

Source
Expand description

An unofficial, eager-first Rust frontend for LibTorch.

RustTorch provides fallible neural-network modules, optimizer builders, SafeTensors state exchange, and an optional inspectable graph API. Numerical operations and automatic differentiation remain delegated to tch and the linked LibTorch runtime.

§Quick start

use rusttorch::nn::Sequential;
use rusttorch::{DeviceSpec, Kind, Result, Tensor};

fn main() -> Result<()> {
    let model = Sequential::builder()
        .linear(2, 4)
        .relu()
        .linear(4, 1)
        .build(DeviceSpec::Auto)?;
    let input = Tensor::f_zeros([8, 2], (Kind::Float, model.device()))?;
    let output = model.forward(&input)?;
    assert_eq!(output.size(), [8, 1]);
    Ok(())
}

Explicit backend requests fail when unavailable; use DeviceSpec::Auto only when selecting the best available backend is desired. Model weights are exchanged through .safetensors files rather than Python pickle files.

§API coverage

This page is generated from compat/pytorch_api.toml against PyTorch v2.13.0 at commit cf30153, through tch 0.26.0. Each entry is independently scoped. Supported applies only to its written scope; row counts are not a compatibility score.

§Supported

§core.device

§data.batched_fetch

§data.batches

§data.chain_dataset

§data.concat_dataset

§data.dataset

  • PyTorch: torch.utils.data.Dataset
  • RustTorch: rusttorch_data::Dataset, rusttorch_data::DatasetSamples, rusttorch::data::Dataset, rusttorch::data::DatasetSamples
  • Implementation: Implemented by RustTorch
  • Scope: Finite map-style datasets with owned samples, fallible indexed access, length and empty queries, and a lazy borrowing iterator over samples in index order.
  • Pinned source: torch/utils/data/dataset.py
  • Evidence: tests/data.rs::dataset_default_is_empty_follows_len, tests/data.rs::dataset_samples_borrow_and_fetch_lazily_in_order
  • Notes: rusttorch-data owns the direct surface and rusttorch::data preserves it. DatasetSamples performs no dataset clone or precollection; format-specific decoding belongs in optional packages.

§data.loader

§data.loader.checkpoint_stream

§data.random_split

§data.sampler

§data.sampler.distributed

§data.stack_dataset

§data.subset

§data.tensor_dataset

§graph.executor

§graph.inspection

  • PyTorch: torch.fx.Graph.print_tabular, torch.fx.Graph.__str__
  • RustTorch: rusttorch::graph::Graph::summary, rusttorch::graph::Graph::to_dot, rusttorch::graph::GraphModule::summary, rusttorch::graph::GraphModule::to_dot
  • Implementation: Implemented by RustTorch
  • Scope: Deterministic textual summaries and DOT output for RustTorch graphs.
  • Pinned source: torch/fx/graph.py
  • Evidence: tests/graph.rs::summary_and_dot_are_deterministic_and_describe_the_graph
  • Notes: DOT generation returns text and does not invoke Graphviz.

§graph.ops

§graph.passes

  • PyTorch: torch.fx.passes
  • RustTorch: rusttorch::graph::GraphPass, rusttorch::graph::Validation, rusttorch::graph::DeadNodeElimination, rusttorch::graph::ShapePropagation, rusttorch::graph::PassReport
  • Implementation: Implemented by RustTorch
  • Scope: Validation, dead-node deactivation, and the tested shape-propagation subset for RustTorch graphs.
  • Pinned source: torch/fx/passes/__init__.py
  • Evidence: tests/graph.rs::finish_eliminates_dead_nodes_and_propagates_flatten_linear_shapes
  • Notes: These passes operate on RustTorch graphs and do not accept arbitrary FX passes.

§nn.cross_entropy

  • PyTorch: torch.nn.functional.cross_entropy
  • RustTorch: rusttorch::nn::functional::cross_entropy
  • Implementation: Delegated to LibTorch
  • Scope: Default class-index cross entropy with deterministic values on the tested shape.
  • Pinned source: torch/nn/functional.py
  • Evidence: tests/eager.rs::mse_and_cross_entropy_have_deterministic_values
  • Notes: Weights, custom ignore index, label smoothing, probability targets, and reduction selection are not exposed.

§nn.flatten

§nn.identity

§nn.linear

§nn.mse_loss

§nn.relu

§runtime.setup

§Partial

§autograd.reverse_mode

  • PyTorch: torch.Tensor.backward, torch.no_grad, torch.Tensor.detach
  • RustTorch: rusttorch_core::Tensor, rusttorch_core::no_grad, rusttorch_core::no_grad_guard, rusttorch::Tensor, rusttorch::no_grad, rusttorch::no_grad_guard
  • Implementation: Delegated to LibTorch
  • Scope: Reverse-mode gradients through the tested eager and graph operations, plus tested no-grad and detach behavior.
  • Pinned source: torch/autograd/__init__.py
  • Evidence: tests/eager.rs::gradients_accumulate_across_eager_residual_branches, tests/eager.rs::no_grad_and_detach_stop_gradient_recording
  • Notes: rusttorch-core owns these direct reexports and the rusttorch facade preserves them; LibTorch owns autograd, while hooks, custom Function, forward AD, and the rest of the Python surface remain outside this claim.

§core.random

  • PyTorch: torch.manual_seed
  • RustTorch: rusttorch_core::manual_seed, rusttorch::manual_seed
  • Implementation: Delegated to LibTorch
  • Scope: A seed can be delegated to LibTorch; deterministic behavior and cross-language stream identity are not yet verified by a focused test.
  • Pinned source: torch/random.py
  • Evidence: —
  • Notes: rusttorch-core owns the direct function and the rusttorch facade preserves it. The function remains partial until executable evidence proves its documented contract.

§core.tensor

  • PyTorch: torch.Tensor, torch.dtype, torch.nn.functional reduction
  • RustTorch: rusttorch_core::Tensor, rusttorch_core::Kind, rusttorch_core::Reduction, rusttorch::Tensor, rusttorch::Kind, rusttorch::Reduction
  • Implementation: Delegated to LibTorch
  • Scope: Root type reexports plus the tensor construction, dtype, device, and eager operations exercised by current RustTorch tests.
  • Pinned source: torch/_tensor.py
  • Evidence: tests/eager.rs::tensor_core_types_are_reexported
  • Notes: rusttorch-core owns the direct reexports and the rusttorch facade preserves them. Reexporting tch::Tensor is not evidence that every torch.Tensor method matches PyTorch.

§data.collation

§data.dataset.datapipes

  • PyTorch: torch.utils.data.DataChunk, torch.utils.data.DFIterDataPipe, torch.utils.data.IterDataPipe, torch.utils.data.MapDataPipe
  • RustTorch: std::iter::Iterator, rusttorch_data::Dataset, rusttorch_data::WorkerSourceFactory, rusttorch_data::Transform, rusttorch::data::Dataset, rusttorch::data::WorkerSourceFactory, rusttorch::data::Transform
  • Implementation: Implemented by RustTorch
  • Scope: Ordinary typed Rust iterators replace basic iterable DataPipe traversal, Dataset replaces indexed MapDataPipe access, WorkerSourceFactory creates independent sharded iterators, and Transform composes typed sample operations.
  • Pinned source: torch/utils/data/datapipes/datapipe.py
  • Evidence: crates/rusttorch-data/tests/stream_workers.rs::four_explicit_modulo_shards_produce_each_logical_record_once, tests/data.rs::dataset_samples_borrow_and_fetch_lazily_in_order
  • Notes: RustTorch does not reproduce functional-name registration, reset/single-iterator hooks, Python serialization hooks, dataframe tracing, or DFIterDataPipe. Vec is the closest DataChunk container but does not retain a separate original-items raw iterator, so DataChunk is not claimed as supported.

§data.loader.checkpoint

§data.loader.pinning

§data.loader.prefetch

§data.loader.transforms

§data.loader.workers

§data.stream_workers

§graph.ir

§nn.dropout

  • PyTorch: torch.nn.Dropout, torch.nn.functional.dropout
  • RustTorch: rusttorch::nn::Dropout, rusttorch::nn::functional::dropout
  • Implementation: RustTorch frontend backed by LibTorch
  • Scope: Validated probabilities, explicit functional mode, module train/eval behavior, boundary probabilities, and evaluation gradients.
  • Pinned source: torch/nn/modules/dropout.py
  • Evidence: tests/eager.rs::dropout_boundary_probabilities_and_eval_gradients_are_correct
  • Notes: The full stochastic distribution, all shapes and dtypes, and backend parity are not claimed.

§nn.gelu

  • PyTorch: torch.nn.GELU, torch.nn.functional.gelu
  • RustTorch: rusttorch::nn::Gelu, rusttorch::nn::GeluApproximation, rusttorch::nn::functional::gelu, rusttorch::nn::functional::gelu_with_approximation
  • Implementation: Delegated to LibTorch
  • Scope: Exact GELU forward values for the tested default approximation.
  • Pinned source: torch/nn/modules/activation.py
  • Evidence: tests/eager.rs::identity_relu_gelu_and_flatten_match_expected_behavior
  • Notes: GeluApproximation::Tanh is exposed but lacks focused numerical and gradient evidence.

§nn.module

§nn.sequential

§optim.adam

§optim.sgd

§serialization.mapping

§serialization.safetensors

  • PyTorch: safetensors.torch.save_file, safetensors.torch.load_file
  • RustTorch: rusttorch::interop::save_state_dict, rusttorch::interop::load_state_dict, rusttorch::nn::Sequential::save_weights, rusttorch::nn::Sequential::load_weights, rusttorch::graph::GraphModule::save_weights, rusttorch::graph::GraphModule::load_weights
  • Implementation: RustTorch frontend backed by LibTorch
  • Scope: Tested CPU SafeTensors state round trips plus manually gated Python-to-Rust and Rust-to-Python exchange with architecture supplied separately.
  • Pinned source: torch/nn/modules/module.py
  • Evidence: tests/interop.rs::strict_safetensors_round_trip_restores_all_variables, tests/python_parity.rs::bidirectional_python_parity
  • Notes: The Python evidence requires scripts/run-python-parity.sh and is ignored by ordinary Cargo test; state loads to the target device.

§serialization.state_dict

§Planned

§amp

  • PyTorch: torch.amp.autocast, torch.amp.GradScaler
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Automatic mixed precision, gradient scaling, and dtype policy are not exposed yet.
  • Pinned source: torch/amp/autocast_mode.py
  • Evidence: —
  • Notes: A future surface must state supported devices and dtypes and carry backend parity evidence.

§audio

  • PyTorch: torch.utils.data.Dataset for audio samples
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Audio decoding, resampling, feature extraction, and augmentation belong in an optional data package.
  • Pinned source: torch/utils/data/dataset.py
  • Evidence: —
  • Notes: Decoded typed samples will use the shared RustTorch data-loading core.

§autograd.forward_ad

  • PyTorch: torch.autograd.forward_ad
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Forward-mode automatic differentiation and dual tensors are not exposed.
  • Pinned source: torch/autograd/forward_ad.py
  • Evidence: —
  • Notes: This row is separate from the currently tested reverse-mode subset.

§codec

  • PyTorch: torch.utils.data.Dataset for encoded media
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: General image, audio, and video codec integration is not included in the core crate.
  • Pinned source: torch/utils/data/dataset.py
  • Evidence: —
  • Notes: Optional format packages will turn encoded records into typed loader samples.

§compiler.export.interop

  • PyTorch: torch.export.save, torch.export.load
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: PT2 ExportedProgram archive import, validation, execution, and export are not implemented.
  • Pinned source: torch/export/__init__.py
  • Evidence: —
  • Notes: Artifact support must pin the archive version and supported operator set.

§distributed.c10d

  • PyTorch: torch.distributed.init_process_group, torch.distributed.ProcessGroup
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Collectives, process groups, rendezvous, and distributed error handling are not exposed.
  • Pinned source: torch/distributed/distributed_c10d.py
  • Evidence: —
  • Notes: Future support must enumerate transports, operating systems, and failure semantics.

§distributed.ddp

  • PyTorch: torch.nn.parallel.DistributedDataParallel
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Distributed data parallel training, bucket scheduling, and state synchronization are not implemented.
  • Pinned source: torch/nn/parallel/distributed.py
  • Evidence: —
  • Notes: This depends on an independently verified process-group foundation.

§distributed.fsdp

  • PyTorch: torch.distributed.fsdp.FullyShardedDataParallel
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Parameter sharding, resharding, mixed precision, and distributed checkpoint integration are not implemented.
  • Pinned source: torch/distributed/fsdp/fully_sharded_data_parallel.py
  • Evidence: —
  • Notes: FSDP follows process groups, distributed checkpointing, and memory benchmarks.

§distributions

  • PyTorch: torch.distributions.Distribution
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Probability distributions, transforms, constraints, sampling, and log-probability APIs are not exposed.
  • Pinned source: torch/distributions/distribution.py
  • Evidence: —
  • Notes: Each future distribution requires numerical and gradient parity evidence.

§fft

  • PyTorch: torch.fft
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: The torch.fft namespace is not wrapped or compatibility-tested.
  • Pinned source: torch/fft/__init__.py
  • Evidence: —
  • Notes: Future coverage will be split by transform family and normalization behavior.

§func

  • PyTorch: torch.func
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Function transforms such as vmap, grad, jacrev, jacfwd, and functionalization are not exposed.
  • Pinned source: torch/_functorch/apis.py
  • Evidence: —
  • Notes: Rust interfaces require explicit ownership and mutation semantics.

§linalg

  • PyTorch: torch.linalg
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: The torch.linalg namespace is not wrapped or compatibility-tested.
  • Pinned source: torch/linalg/__init__.py
  • Evidence: —
  • Notes: Future rows will split decompositions, solvers, norms, and matrix functions.

§nested

  • PyTorch: torch.nested
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Nested tensor construction, operators, autograd, and layout behavior are not exposed.
  • Pinned source: torch/nested/__init__.py
  • Evidence: —
  • Notes: Support depends on stable LibTorch bindings and backend evidence.

§nn.attention

  • PyTorch: torch.nn.MultiheadAttention, torch.nn.functional.scaled_dot_product_attention
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Multi-head and scaled-dot-product attention modules, masks, kernels, and fast paths are not exposed.
  • Pinned source: torch/nn/modules/activation.py
  • Evidence: —
  • Notes: Backend and dtype-dependent kernels require separate compatibility evidence.

§nn.convolution

  • PyTorch: torch.nn.Conv1d, torch.nn.Conv2d, torch.nn.Conv3d, torch.nn.functional.conv2d
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Convolution modules and functional variants are not exposed through RustTorch.
  • Pinned source: torch/nn/modules/conv.py
  • Evidence: —
  • Notes: Future coverage will name dimensions, padding, groups, dtypes, and backends.

§nn.normalization

  • PyTorch: torch.nn.BatchNorm1d, torch.nn.LayerNorm, torch.nn.GroupNorm
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Normalization modules, functional forms, running statistics, and distributed variants are not exposed.
  • Pinned source: torch/nn/modules/batchnorm.py
  • Evidence: —
  • Notes: Future rows will separate batch, layer, group, and instance normalization.

§nn.recurrent

  • PyTorch: torch.nn.RNN, torch.nn.LSTM, torch.nn.GRU
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Recurrent modules, packed sequences, state layouts, and projections are not exposed.
  • Pinned source: torch/nn/modules/rnn.py
  • Evidence: —
  • Notes: Each family needs batch-first, direction, layer, dtype, and backend evidence.

§nn.transformer

  • PyTorch: torch.nn.Transformer, torch.nn.TransformerEncoder, torch.nn.TransformerDecoder
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Transformer containers, masks, nested-tensor fast paths, and encoder and decoder layers are not exposed.
  • Pinned source: torch/nn/modules/transformer.py
  • Evidence: —
  • Notes: Attention kernels and normalization are separate prerequisites.

§onnx

  • PyTorch: torch.onnx.export
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: ONNX export, diagnostics, shape constraints, and verification are not implemented.
  • Pinned source: torch/onnx/__init__.py
  • Evidence: —
  • Notes: Future support must identify the opset and runtime verification matrix.

§optim.schedulers

  • PyTorch: torch.optim.lr_scheduler.LRScheduler
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Learning-rate schedulers, metric-driven scheduling, and scheduler checkpoint state are not exposed.
  • Pinned source: torch/optim/lr_scheduler.py
  • Evidence: —
  • Notes: Future rows must state exact step ordering and state behavior.

§profiler

  • PyTorch: torch.profiler.profile
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Operator tracing, schedules, memory profiling, stack capture, and trace export are not exposed.
  • Pinned source: torch/profiler/profiler.py
  • Evidence: —
  • Notes: Future support must keep profiling overhead and backend availability explicit.

§quantization

  • PyTorch: torch.ao.quantization
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Eager and graph quantization, observers, calibration, fake quantization, and quantized modules are not exposed.
  • Pinned source: torch/ao/quantization/__init__.py
  • Evidence: —
  • Notes: Coverage will distinguish training, post-training, export, dtype, operator, and backend support.

§sparse

  • PyTorch: torch.sparse
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Sparse layouts, constructors, operators, autograd, validation, and conversion are not exposed.
  • Pinned source: torch/sparse/__init__.py
  • Evidence: —
  • Notes: Future rows will distinguish COO, CSR, CSC, BSR, and BSC.

§special

  • PyTorch: torch.special
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: The torch.special namespace is not wrapped or compatibility-tested.
  • Pinned source: torch/special/__init__.py
  • Evidence: —
  • Notes: Future groups require numerical, gradient, dtype, and backend evidence.

§tabular

  • PyTorch: torch.utils.data.Dataset for tabular records
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: CSV, columnar, database, missing-value, categorical, and numerical preprocessing integrations are not included.
  • Pinned source: torch/utils/data/dataset.py
  • Evidence: —
  • Notes: Optional packages will map records into typed samples consumed by the shared loader.

§testing

  • PyTorch: torch.testing.assert_close
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Public tensor comparison, tolerance policy, generated utilities, and OpInfo-style coverage are not exposed.
  • Pinned source: torch/testing/__init__.py
  • Evidence: —
  • Notes: Internal tests are not a public torch.testing surface.

§text

  • PyTorch: torch.utils.data.Dataset for text samples
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Text decoding, tokenization, vocabulary management, packing, and augmentation are not included.
  • Pinned source: torch/utils/data/dataset.py
  • Evidence: —
  • Notes: Optional text packages will produce typed samples for the shared loader.

§utils.checkpoint

  • PyTorch: torch.utils.checkpoint.checkpoint
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Activation checkpointing, recomputation policy, RNG-state handling, and selective contexts are not exposed.
  • Pinned source: torch/utils/checkpoint.py
  • Evidence: —
  • Notes: Future support must prove gradients and memory behavior.

§video

  • PyTorch: torch.utils.data.Dataset for video samples
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Video decoding, frame sampling, temporal transforms, audio alignment, and batching are not included.
  • Pinned source: torch/utils/data/dataset.py
  • Evidence: —
  • Notes: Optional media packages will decode typed samples for the shared loader.

§vision

  • PyTorch: torch.utils.data.Dataset for image samples
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Image decoding, transforms, augmentation, detection targets, and vision datasets are not included.
  • Pinned source: torch/utils/data/dataset.py
  • Evidence: —
  • Notes: Optional vision packages will produce typed samples; torchvision is a separate upstream project.

§Python-only

§compiler.compile

  • PyTorch: torch.compile
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: CPython frame capture, Dynamo guards, and Python graph-break semantics are not native RustTorch APIs.
  • Pinned source: torch/_dynamo/eval_frame.py
  • Evidence: —
  • Notes: Rust deployment may consume compatible artifacts later without claiming Python runtime parity.

§compiler.export

  • PyTorch: torch.export.export
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Python program capture, dynamic Python object handling, and Python-side export diagnostics are not native RustTorch APIs.
  • Pinned source: torch/export/__init__.py
  • Evidence: —
  • Notes: Capture is tracked separately from planned PT2 artifact interoperability.

§compiler.fx

  • PyTorch: torch.fx.Graph, torch.fx.GraphModule, torch.fx.symbolic_trace
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Python symbolic tracing, dynamic module reconstruction, and FX graph compatibility are not provided.
  • Pinned source: torch/fx/graph.py
  • Evidence: —
  • Notes: RustTorch’s typed graph has separate rows and is not described as FX-compatible.

§data.dataset.datapipes.decorators

  • PyTorch: torch.utils.data.argument_validation, torch.utils.data.functional_datapipe, torch.utils.data.guaranteed_datapipes_determinism, torch.utils.data.non_deterministic, torch.utils.data.runtime_validation, torch.utils.data.runtime_validation_disabled
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Python decorators dynamically register DataPipe functions, label determinism, and toggle runtime validation or construction-time determinism contexts.
  • Pinned source: torch/utils/data/datapipes/_decorator.py
  • Evidence: —
  • Notes: Rust traits and the type system provide compile-time composition and validation but are not semantic implementations of these mutable Python registries and context managers.

§data.internal.exports

  • PyTorch: torch.utils.data._DatasetKind
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: The private loader-kind dispatch enum exported by the pinned module remains a Python implementation detail.
  • Pinned source: torch/utils/data/dataloader.py
  • Evidence: —
  • Notes: RustTorch uses type-state builders instead of exposing Python’s internal enum. argument_validation is separately attributed to the pinned DataPipe decorator module.

§Not supported

§serialization.pickle

  • PyTorch: torch.save, torch.load
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: Arbitrary Python pickle objects, whole-model class reconstruction, and CPython object graphs are intentionally unavailable.
  • Pinned source: torch/serialization.py
  • Evidence: —
  • Notes: RustTorch uses typed model construction and SafeTensors instead of executing pickle payloads.

§serialization.torchscript

  • PyTorch: torch.jit.load, torch.jit.ScriptModule
  • RustTorch: —
  • Implementation: Not implemented
  • Scope: RustTorch does not expose TorchScript modules or convert TorchScript into eager modules or its graph IR.
  • Pinned source: torch/jit/__init__.py
  • Evidence: —
  • Notes: Applications may use tch::CModule directly outside the RustTorch contract.

Modules§

data
Data APIs re-exported from rusttorch_data.
device
Runtime device discovery and strict device selection.
error
Errors returned by the fallible RustTorch API.
graph
Optional, inspectable graph IR executed eagerly through LibTorch.
interop
Model-state interchange helpers.
nn
Eager neural-network modules.
optim
Ergonomic optimizer builders backed by tch/LibTorch.

Structs§

DeviceCapabilities
Backends that can actually be used by the current process.
Tensor
A tensor object.

Enums§

Device
A torch device.
DeviceSpec
A device request that is resolved against the linked LibTorch build.
Kind
The different kind of elements that a Tensor can hold.
Reduction
RustTorchError
Recoverable configuration, graph, state, and backend failures.

Functions§

available_devices
Probes the linked LibTorch backends without consulting Python at runtime.
manual_seed
Seeds LibTorch’s random number generator.
no_grad
Runs a closure without keeping track of gradients.
no_grad_guard
Disables gradient tracking, this will be enabled back when the returned value gets deallocated. Note that it is important to bind this to a name like _guard and not to _ as the latter would immediately drop the guard. See https://internals.rust-lang.org/t/pre-rfc-must-bind/12658/46 for more details.
resolve_device
Resolves an explicit or automatic device request.

Type Aliases§

Result
Result type used by RustTorch APIs that can fail recoverably.