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§
Sourcefn add<B: TensorBackend>(
&self,
rhs: &TypedTensor<T>,
backend: &mut B,
) -> Result<TypedTensor<T>>
fn add<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>
Elementwise addition with NumPy-style broadcasting.
Sourcefn sub<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>>
Elementwise subtraction with NumPy-style broadcasting.
Sourcefn mul<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>>
Elementwise multiplication with NumPy-style broadcasting.
Sourcefn div<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>>
Elementwise division with NumPy-style broadcasting.
Sourcefn pow<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>>
Elementwise power with NumPy-style broadcasting.
Sourcefn maximum<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>>
Elementwise maximum with NumPy-style broadcasting.
Sourcefn minimum<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>>
Elementwise minimum with NumPy-style broadcasting.
Sourcefn neg<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn neg<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise negation.
Sourcefn abs<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn abs<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise absolute value.
Sourcefn sign<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn sign<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise sign.
Sourcefn conj<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn conj<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise complex conjugate.
Sourcefn exp<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn exp<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise exponential.
Sourcefn log<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn log<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise natural logarithm.
Sourcefn sin<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn sin<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise sine.
Sourcefn cos<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn cos<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise cosine.
Sourcefn tanh<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn tanh<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise hyperbolic tangent.
Sourcefn sqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn sqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise square root.
Sourcefn rsqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn rsqrt<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise reciprocal square root.
Sourcefn expm1<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn expm1<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise exp(x) - 1.
Sourcefn log1p<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
fn log1p<B: TensorBackend>(&self, backend: &mut B) -> Result<TypedTensor<T>>
Elementwise log(1 + x).
Sourcefn compare<B: TensorBackend>(
&self,
rhs: &TypedTensor<T>,
dir: CompareDir,
backend: &mut B,
) -> Result<TypedTensor<bool>>
fn compare<B: TensorBackend>( &self, rhs: &TypedTensor<T>, dir: CompareDir, backend: &mut B, ) -> Result<TypedTensor<bool>>
Elementwise comparison with NumPy-style broadcasting.
Sourcefn clamp<B: TensorBackend>(
&self,
lower: &TypedTensor<T>,
upper: &TypedTensor<T>,
backend: &mut B,
) -> Result<TypedTensor<T>>
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.
Sourcefn matmul<B: TensorBackend>(
&self,
rhs: &TypedTensor<T>,
backend: &mut B,
) -> Result<TypedTensor<T>>
fn matmul<B: TensorBackend>( &self, rhs: &TypedTensor<T>, backend: &mut B, ) -> Result<TypedTensor<T>>
Rank-2 matrix multiplication.
Sourcefn reduce_sum<B: TensorBackend>(
&self,
axes: &[usize],
backend: &mut B,
) -> Result<TypedTensor<T>>
fn reduce_sum<B: TensorBackend>( &self, axes: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>
Sum over one or more axes.
Sourcefn reshape<B: TensorBackend>(
&self,
shape: &[usize],
backend: &mut B,
) -> Result<TypedTensor<T>>
fn reshape<B: TensorBackend>( &self, shape: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>
Reshape through the backend structural operation.
Sourcefn transpose<B: TensorBackend>(
&self,
perm: &[usize],
backend: &mut B,
) -> Result<TypedTensor<T>>
fn transpose<B: TensorBackend>( &self, perm: &[usize], backend: &mut B, ) -> Result<TypedTensor<T>>
Permute axes through the backend structural operation.
Sourcefn broadcast_in_dim<B: TensorBackend>(
&self,
shape: &[usize],
dims: &[usize],
backend: &mut B,
) -> Result<TypedTensor<T>>
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.