Skip to main content

NativeBackend

Struct NativeBackend 

Source
pub struct NativeBackend { /* private fields */ }
Expand description

Native backend using faer for GEMM and, with the hptt feature, HPTT for transpose (a naive kernel otherwise).

This is the sole owner of faer and hptt-rs dependencies in the workspace. Other crates access these capabilities through the ComputeBackend trait. Holds a PerformanceManager that drives the par_for_* dispatch decisions for each op based on a hardware-aware threshold table.

Implementations§

Source§

impl NativeBackend

Source

pub fn new() -> Self

Construct a NativeBackend with thresholds auto-detected from the current machine via ThresholdTable::detect().

Source

pub fn with_perf(perf: PerformanceManager) -> Self

Construct a NativeBackend with a user-supplied PerformanceManager.

Use this to override the auto-detected threshold table, e.g. to pin the laptop profile on a workstation for reproducible benchmarks.

Source

pub fn perf(&self) -> &PerformanceManager

Borrow the PerformanceManager driving this backend’s dispatch.

Source

pub fn shared() -> Arc<NativeBackend>

Get a shared singleton instance.

All tensors using the default backend share this single Arc, avoiding per-tensor allocation.

Trait Implementations§

Source§

impl Clone for NativeBackend

Source§

fn clone(&self) -> NativeBackend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComputeBackend for NativeBackend

Source§

fn gemm<T: Scalar>( &self, desc: GemmDescriptor<'_, T>, ) -> Result<(), BackendError>

GEMM: C = alpha * A * B + beta * C

Dispatches to faer for f64/f32/Complex<f64>/Complex<f32>.

Source§

fn transpose<T: Scalar>( &self, desc: TransposeDescriptor<'_, T>, ) -> Result<(), BackendError>

Transpose tensor axes according to permutation.

Uses HPTT for f64/f32/Complex when the hptt feature is enabled, otherwise a naive output-driven kernel.

Source§

fn svd<T: Scalar>(&self, desc: SvdDescriptor<'_, T>) -> Result<(), BackendError>

Thin SVD via faer: A = U * diag(S) * Vt

Dispatches to faer for f64/f32/Complex<f64>/Complex<f32>. For complex types, Vt stores V^H (conjugate transpose). faer’s SVD is column-major only; descriptors with any other order are rejected with BackendError::InvalidArgument.

Source§

fn qr<T: Scalar>(&self, desc: QrDescriptor<'_, T>) -> Result<(), BackendError>

Thin QR via faer: A = Q * R

Dispatches to faer for f64/f32/Complex<f64>/Complex<f32>. faer’s QR is column-major only; descriptors with any other order are rejected with BackendError::InvalidArgument.

Source§

fn lq<T: Scalar>(&self, desc: LqDescriptor<'_, T>) -> Result<(), BackendError>

Thin LQ via faer: A = L * Q

Internally computes QR of A^H (adjoint), then takes conjugate transposes. Dispatches to faer for f64/f32/Complex<f64>/Complex<f32>. faer’s QR (and hence this LQ) is column-major only; descriptors with any other order are rejected with BackendError::InvalidArgument.

Source§

fn eigh<T: Scalar>( &self, desc: EighDescriptor<'_, T>, ) -> Result<(), BackendError>

Self-adjoint eigenvalue decomposition via faer

Dispatches to faer for f64/f32/Complex<f64>/Complex<f32>. faer’s eigendecomposition is column-major only; descriptors with any other order are rejected with BackendError::InvalidArgument.

Source§

fn eig<T: Scalar>(&self, desc: EigDescriptor<'_, T>) -> Result<(), BackendError>

General eigenvalue decomposition via faer

Dispatches to faer for f64/f32/Complex<f64>/Complex<f32>. faer’s eigendecomposition is column-major only; descriptors with any other order are rejected with BackendError::InvalidArgument.

Source§

fn solve<T: Scalar>( &self, desc: SolveDescriptor<'_, T>, ) -> Result<(), BackendError>

Linear solve via faer LU decomposition with partial pivoting

Dispatches to faer for f64/f32/Complex<f64>/Complex<f32>. faer’s LU is column-major only; descriptors with any other order are rejected with BackendError::InvalidArgument.

Source§

fn name(&self) -> &'static str

Backend name
Source§

fn device_type(&self) -> DeviceType

Device type
Source§

fn preferred_order(&self) -> MemoryOrder

Preferred memory order for this backend’s data layout. Read more
Source§

fn par_for_svd(&self, m: usize, n: usize) -> ExecPolicy

Recommended execution policy for SVD at the given problem size. Read more
Source§

fn par_for_qr(&self, m: usize, n: usize) -> ExecPolicy

Recommended execution policy for QR at the given problem size.
Source§

fn par_for_lq(&self, m: usize, n: usize) -> ExecPolicy

Recommended execution policy for LQ at the given problem size.
Source§

fn par_for_eigh(&self, n: usize) -> ExecPolicy

Recommended execution policy for self-adjoint eigendecomposition.
Source§

fn par_for_eig(&self, n: usize) -> ExecPolicy

Recommended execution policy for general eigendecomposition.
Source§

fn par_for_gemm(&self, m: usize, n: usize, k: usize) -> ExecPolicy

Recommended execution policy for GEMM at the given problem size.
Source§

fn par_for_solve(&self, n: usize, _nrhs: usize) -> ExecPolicy

Recommended execution policy for linear solve.
Source§

fn par_for_transpose(&self, shape: &[usize]) -> ExecPolicy

Recommended execution policy for tensor transpose.
Source§

fn is_available(&self) -> bool

Check if backend is available
Source§

impl Debug for NativeBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NativeBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V