Skip to main content

TypedTensorOpsExt

Trait TypedTensorOpsExt 

Source
pub trait TypedTensorOpsExt<T: TensorScalar> {
Show 27 methods // Required methods fn add<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn sub<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn mul<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn div<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn pow<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn maximum<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn minimum<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn neg<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn abs<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn sign<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn conj<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn exp<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn log<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn sin<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn cos<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn tanh<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn sqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn rsqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn expm1<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn log1p<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>; fn compare<B: TensorBackend>( &self, rhs: &TypedTensor<T>, dir: CompareDir, backend: &mut B, ) -> Result<TypedTensor<bool>>; fn clamp<B: TensorBackend>( &self, lower: &TypedTensor<T>, upper: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn matmul<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>; fn reduce_sum<B: TensorBackend>( &self, axes: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>; fn reshape<B: TensorBackend>( &self, shape: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>; fn transpose<B: TensorBackend>( &self, perm: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>; fn broadcast_in_dim<B: TensorBackend>( &self, shape: &[usize], dims: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>;
}
Expand description

Backend-explicit operations for dynamic-rank typed tensors.

TypedTensor is owned by tenferro-tensor, so tenferro-runtime exposes these operations as a crate-root extension trait rather than as inherent methods.

§Public API rationale

This trait is intentionally public for the same reason as TensorOpsExt: downstream users need a supported backend-explicit typed tensor surface, and tenferro-runtime cannot add inherent methods to a type owned by tenferro-tensor. The private typed_tensor module is implementation detail, not a retained module/free-function API.

§Examples

use tenferro_cpu::CpuBackend;
use tenferro_runtime::{TypedTensor, TypedTensorOpsExt};

let mut backend = CpuBackend::new();
let x = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![1.0, 2.0]).unwrap();
let y = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![3.0, 4.0]).unwrap();
let sum = x.add(&y, &mut backend).unwrap();
assert_eq!(sum.host_data().unwrap(), &[4.0, 6.0]);

Required Methods§

Source

fn add<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Elementwise addition with NumPy-style broadcasting.

Source

fn sub<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Elementwise subtraction with NumPy-style broadcasting.

Source

fn mul<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Elementwise multiplication with NumPy-style broadcasting.

Source

fn div<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Elementwise division with NumPy-style broadcasting.

Source

fn pow<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Elementwise power with NumPy-style broadcasting.

Source

fn maximum<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Elementwise maximum with NumPy-style broadcasting.

Source

fn minimum<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Elementwise minimum with NumPy-style broadcasting.

Source

fn neg<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise negation.

Source

fn abs<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise absolute value.

Source

fn sign<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise sign.

Source

fn conj<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise complex conjugate.

Source

fn exp<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise exponential.

Source

fn log<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise natural logarithm.

Source

fn sin<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise sine.

Source

fn cos<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise cosine.

Source

fn tanh<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise hyperbolic tangent.

Source

fn sqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise square root.

Source

fn rsqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise reciprocal square root.

Source

fn expm1<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise exp(x) - 1.

Source

fn log1p<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>

Elementwise log(1 + x).

Source

fn compare<B: TensorBackend>( &self, rhs: &TypedTensor<T>, dir: CompareDir, backend: &mut B, ) -> Result<TypedTensor<bool>>

Elementwise comparison with NumPy-style broadcasting.

Source

fn clamp<B: TensorBackend>( &self, lower: &TypedTensor<T>, upper: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Clamp values elementwise between lower and upper bounds.

Source

fn matmul<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>

Rank-2 matrix multiplication.

Source

fn reduce_sum<B: TensorBackend>( &self, axes: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>

Sum over one or more axes.

Source

fn reshape<B: TensorBackend>( &self, shape: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>

Reshape through the backend structural operation.

Source

fn transpose<B: TensorBackend>( &self, perm: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>

Permute axes through the backend structural operation.

Source

fn broadcast_in_dim<B: TensorBackend>( &self, shape: &[usize], dims: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>

Broadcast into a larger shape.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§