Expand description
Linear algebra extension operations for tenferro.
This crate owns the graph-facing linalg op payloads and runtime
registration. Tensor-facing operations are exposed through extension traits.
CPU backend kernels live in this crate behind the linalg backend trait.
A CPU backend paired by tenferro_gpu::AppleContext additionally supports
guarded rank-2 Cholesky on matching Apple managed F32, F64, C32, and
C64 tensors. This is an explicit CPU selection and is not a general
managed-memory fallback for other linalg operations.
§Examples
use tenferro_linalg::TracedTensorLinalgExt;
use tenferro_cpu::CpuBackend;
use tenferro_runtime::{GraphCompiler, Runtime, TracedTensor};
let a = TracedTensor::from_vec_col_major(
vec![2, 2],
vec![4.0_f64, 2.0, 2.0, 3.0],
)
.unwrap();
let l = a.cholesky().unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&l).unwrap();
let backend = CpuBackend::new();
let engine_id = tenferro_cpu::runtime_engine_id().unwrap();
let mut builder = Runtime::builder();
builder
.register_engine(tenferro_cpu::runtime_engine_registration(&backend).unwrap())
.unwrap();
builder
.install_extension_module(tenferro_linalg::extension_module::<CpuBackend>(engine_id).unwrap())
.unwrap();
let runtime = builder.build().unwrap();
let out = runtime.run_compiled(&program, &[]).unwrap().pop().unwrap();
assert_eq!(out.shape(), &[2, 2]);Re-exports§
pub use backend::LinalgBackend;pub use error::Error;pub use error::Result;
Modules§
Structs§
- Eigh
Options - Options for Hermitian eigenvalue decomposition.
- Linalg
AdMode Support - User-visible AD support for one mode.
- Linalg
AdOutput Support - AD support status for one output of a linalg operation.
- Linalg
AdSupport - AD support manifest entry for one linalg operation.
- QrOptions
- Options for QR decomposition.
- SvdOptions
- Options for singular value decomposition.
Enums§
- Eigh
Gauge - Eigenvector gauge convention used by
EighOptions. - Linalg
AdOp Kind - Operation keys covered by the linalg AD support manifest.
- Linalg
AdRoute - Implementation route used for a user-visible AD mode.
- Linalg
AdRule Support - AD rule support status for a linalg operation or output.
- QrGauge
- QR factor gauge convention used by
QrOptions. - SvdGauge
- Singular-vector gauge convention used by
SvdOptions.
Constants§
- DEFAULT_
DECOMPOSITION_ DERIVATIVE_ EPS - Default derivative regularization used by decomposition AD rules.
- LINALG_
EXTENSION_ FAMILY_ ID
Traits§
- Eager
Tensor Linalg Ext - Linear algebra extension methods for [
EagerTensor]. - Linalg
Scalar - Scalar types supported by statically typed linear algebra methods.
- Tensor
Linalg Ext - Linear algebra methods for dtype-erased owned tensors.
- Tensor
Read Linalg Ext - Linear algebra methods for borrowed tensor reads.
- Traced
Tensor Linalg Ext - Linear algebra extension methods for [
TracedTensor]. - Typed
Tensor Linalg Ext - Linear algebra methods with statically typed inputs and outputs.
Functions§
- all_
linalg_ ad_ support - Return the complete linalg AD support manifest.
- extension_
module - Build this extension module for one runtime engine.
- linalg_
ad_ support - Return the support manifest entry for one linalg operation kind.
- semantic_
ad_ rules - Return the linalg semantic-program AD rule set.
Type Aliases§
- Typed
Eig - Fixed typed output tuple for general eigendecomposition.
- Typed
Full PivLu - Fixed typed output tuple for complete-pivot LU decomposition.
- TypedLu
- Fixed typed output tuple for LU decomposition.
- Typed
Svd - Fixed typed output tuple for singular value decomposition.