Skip to main content

Crate rusttorch_core

Crate rusttorch_core 

Source
Expand description

Shared runtime contracts for the RustTorch workspace.

§rusttorch-core compatibility

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

§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.

§Planned

§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.

§Python-only

No entries.

§Not supported

No entries.

Re-exports§

pub use device::DeviceCapabilities;
pub use device::DeviceSpec;
pub use device::available_devices;
pub use device::resolve_device;
pub use error::Result;
pub use error::RustTorchError;

Modules§

device
Runtime device discovery and strict device selection.
error
Errors returned by the fallible RustTorch API.

Structs§

Tensor
A tensor object.

Enums§

Device
A torch device.
Kind
The different kind of elements that a Tensor can hold.
Reduction

Functions§

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.