Skip to main content

CoreOps

Trait CoreOps 

Source
pub trait CoreOps: AsView {
Show 66 methods // Required methods fn exp(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn neg(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn sign(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn conj(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn log(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn expm1( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn log1p( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn erf(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn sin(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn cos(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn tanh(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn sqrt(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn rsqrt( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn abs( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as CoreRepr>::Real> where Self::Repr: CoreRepr; fn sigmoid( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn silu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn softplus( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn gelu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn gelu_tanh( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn mul( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn sub( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn div( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn rem( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn pow( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn maximum( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn minimum( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn add( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn add_into( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, dest: Dest<<Self::Repr as Repr>::Write<'_>>, ) -> Result<()> where Self::Repr: CoreRepr; fn matmul( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn compare( &self, b: &impl AsView<Repr = Self::Repr>, dir: CompareDir, exec: &mut dyn Engine, ) -> Result<<Self::Repr as CoreRepr>::Bool> where Self::Repr: CoreRepr; fn clamp( &self, lower: &impl AsView<Repr = Self::Repr>, upper: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn where_select<Y: SelectOperand<Self::Repr> + ?Sized>( &self, on_true: &Y, on_false: &impl AsView<Repr = Y::Repr>, exec: &mut dyn Engine, ) -> Result<<Y::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn dot_general( &self, b: &impl AsView<Repr = Self::Repr>, config: DotGeneralConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn dot_general_with( &self, b: &impl AsView<Repr = Self::Repr>, config: DotGeneralConfig, options: &DotGeneralOptions, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reduce_sum( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reduce_max( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reduce_min( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reduce_prod( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reduce_sum_squares( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reduce_mean( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reshape( &self, shape: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn broadcast_in_dim( &self, shape: &[usize], dims: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn transpose( &self, perm: &[isize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn reverse( &self, axes: &[isize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn tril( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn triu( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn extract_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn embed_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn slice( &self, config: SliceConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn pad( &self, config: PadConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn gather( &self, indices: &impl AsView, config: GatherConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn scatter( &self, indices: &impl AsView, updates: &impl AsView, config: ScatterConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn dynamic_slice( &self, starts: &impl AsView, sizes: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn dynamic_update_slice( &self, update: &impl AsView<Repr = Self::Repr>, starts: &impl AsView, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn concatenate( inputs: &[&Self], axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr, Self: Sized; fn convert(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor> where Self::Repr: CoreRepr; fn cast(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor> where Self::Repr: CoreRepr; fn scale_real( &self, factor: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn scale_complex( &self, factor: Complex64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn log_softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn masked_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn masked_log_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn take_along_axis( &self, indices: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn layer_norm( &self, axis: isize, weight: Option<&Self>, bias: Option<&Self>, eps: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr; fn rms_norm( &self, axis: isize, weight: Option<&Self>, bias: Option<&Self>, eps: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value> where Self::Repr: CoreRepr;
}
Expand description

Core tensor operations on anything that implements AsView: owned and borrowed tensors, typed tensors and strided views. Results are Tensors for erased inputs and typed tensors for typed inputs. Axes are signed (-1 is the last axis); the engine is always the last argument.

Generated by api_ops! from the core registry.

Required Methods§

Source

fn exp(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise exponential.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.exp(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn neg(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise negation.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.neg(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn sign(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise sign.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.sign(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn conj(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise complex conjugate (identity on real dtypes).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.conj(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn log(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise natural logarithm.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.log(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn expm1(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise exp(x) - 1.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.expm1(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn log1p(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise log(1 + x).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.log1p(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn erf(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise error function.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.erf(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn sin(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise sine.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.sin(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn cos(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise cosine.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.cos(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn tanh(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise hyperbolic tangent.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.tanh(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn sqrt(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise square root.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.sqrt(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn rsqrt(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise reciprocal square root.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.rsqrt(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn abs(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as CoreRepr>::Real>
where Self::Repr: CoreRepr,

Elementwise absolute value; complex inputs return their modulus.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.abs(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn sigmoid(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Logistic sigmoid.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.sigmoid(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn silu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

SiLU (x * sigmoid(x)).

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.silu(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn softplus(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Softplus log(1 + exp(x)).

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.softplus(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn gelu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

GELU with the exact error function.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.gelu(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn gelu_tanh( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

GELU with the tanh approximation.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.gelu_tanh(&mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn mul( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise product with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.mul(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn sub( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise difference with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.sub(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn div( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise quotient with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.div(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn rem( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise remainder with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.rem(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn pow( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise power with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.pow(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn maximum( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise maximum with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.maximum(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn minimum( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise minimum with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.minimum(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn add( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise sum with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel. add_into writes the result into the destination’s storage.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Omissions
  • traced and eager: only add; add_into exists on the concrete layer
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.add(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn add_into( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, dest: Dest<<Self::Repr as Repr>::Write<'_>>, ) -> Result<()>
where Self::Repr: CoreRepr,

Elementwise sum with broadcasting.

Writes into dest instead of returning a new tensor. Accepted destination modes: Overwrite; any other mode returns an Unsupported error before any data is read or written.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel. add_into writes the result into the destination’s storage.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Omissions
  • traced and eager: only add; add_into exists on the concrete layer
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.add(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn matmul( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Matrix product of the two leading axes, batched over trailing axes.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.matmul(&a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn compare( &self, b: &impl AsView<Repr = Self::Repr>, dir: CompareDir, exec: &mut dyn Engine, ) -> Result<<Self::Repr as CoreRepr>::Bool>
where Self::Repr: CoreRepr,

Elementwise comparison with broadcasting; returns a bool tensor.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{CompareDir, Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.compare(&a, CompareDir::Eq, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn clamp( &self, lower: &impl AsView<Repr = Self::Repr>, upper: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise clamp to [lower, upper] with broadcasting.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.clamp(&a, &a, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn where_select<Y: SelectOperand<Self::Repr> + ?Sized>( &self, on_true: &Y, on_false: &impl AsView<Repr = Y::Repr>, exec: &mut dyn Engine, ) -> Result<<Y::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Elementwise selection: on_true where the receiver is true, on_false elsewhere, with broadcasting. The receiver is the bool condition; a typed receiver must be TypedTensor<bool>.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::TypedTensor;

let mut engine = CpuEngine::serial();
let c = TypedTensor::<bool>::from_vec_col_major(vec![2], vec![true, false])?;
let x = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![1.0, 2.0])?;
let y = TypedTensor::<f64>::from_vec_col_major(vec![2], vec![3.0, 4.0])?;
let z = c.where_select(&x, &y, &mut engine)?;
assert_eq!(z.host_data()?, &[1.0, 4.0]);
Source

fn dot_general( &self, b: &impl AsView<Repr = Self::Repr>, config: DotGeneralConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

General contraction with batch dimensions (DotGeneralConfig); DotGeneralOptions conjugates an operand.

Uses the default tenferro_tensor::DotGeneralOptions; same as dot_general_with with &tenferro_tensor::DotGeneralOptions::default().

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Omissions
  • traced: no dot_general_with; conjugate an operand with conj() first
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{DotGeneralConfig, Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let cfg = DotGeneralConfig {
    lhs_contracting_dims: [1usize].into_iter().collect(),
    rhs_contracting_dims: [0usize].into_iter().collect(),
    lhs_batch_dims: Default::default(),
    rhs_batch_dims: Default::default(),
};
let y = a.dot_general(&a, cfg, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn dot_general_with( &self, b: &impl AsView<Repr = Self::Repr>, config: DotGeneralConfig, options: &DotGeneralOptions, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

General contraction with batch dimensions (DotGeneralConfig); DotGeneralOptions conjugates an operand.

With explicit tenferro_tensor::DotGeneralOptions.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Omissions
  • traced: no dot_general_with; conjugate an operand with conj() first
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{DotGeneralConfig, Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let cfg = DotGeneralConfig {
    lhs_contracting_dims: [1usize].into_iter().collect(),
    rhs_contracting_dims: [0usize].into_iter().collect(),
    lhs_batch_dims: Default::default(),
    rhs_batch_dims: Default::default(),
};
let y = a.dot_general(&a, cfg, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn reduce_sum( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Sum over axes (None: every axis); axes are signed, -1 is the last axis.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reduce_sum(Some(&[-1]), &mut engine)?;
assert_eq!(y.shape(), &[2]);
Source

fn reduce_max( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Maximum over axes (None: every axis); axes are signed, -1 is the last axis.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reduce_max(Some(&[-1]), &mut engine)?;
assert_eq!(y.shape(), &[2]);
Source

fn reduce_min( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Minimum over axes (None: every axis); axes are signed, -1 is the last axis.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reduce_min(Some(&[-1]), &mut engine)?;
assert_eq!(y.shape(), &[2]);
Source

fn reduce_prod( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Product over axes (None: every axis); axes are signed, -1 is the last axis.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reduce_prod(Some(&[-1]), &mut engine)?;
assert_eq!(y.shape(), &[2]);
Source

fn reduce_sum_squares( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Sum of squared magnitudes over axes (None: every axis); axes are signed, -1 is the last axis.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reduce_sum_squares(Some(&[-1]), &mut engine)?;
assert_eq!(y.shape(), &[2]);
Source

fn reduce_mean( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Mean over axes (None: every axis); axes are signed, -1 is the last axis.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reduce_mean(Some(&[-1]), &mut engine)?;
assert_eq!(y.shape(), &[2]);
Source

fn reshape( &self, shape: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Reshape to shape in column-major element order.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel. A view that is not compact in column-major order is gathered by the engine; reshape is a data operation, not a metadata query.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reshape(&[4], &mut engine)?;
assert_eq!(y.shape(), &[4]);
Source

fn broadcast_in_dim( &self, shape: &[usize], dims: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Broadcast to shape; dims[i] is the output axis of input axis i (an IR-level dimension map, unsigned like the *Config structs).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.broadcast_in_dim(&[2, 2, 3], &[0, 1], &mut engine)?;
assert_eq!(y.shape(), &[2, 2, 3]);
Source

fn transpose( &self, perm: &[isize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Permute axes; perm is signed (-1 is the last axis).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.transpose(&[1, 0], &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn reverse( &self, axes: &[isize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Reverse the order of elements along axes (signed).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.reverse(&[-1], &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn tril( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Lower triangle of the two leading axes relative to diagonal k.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.tril(0, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn triu( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Upper triangle of the two leading axes relative to diagonal k.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.triu(0, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn extract_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Extract the diagonal of axes axis_a and axis_b (signed).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.extract_diag(0, 1, &mut engine)?;
assert_eq!(y.shape(), &[2]);
Source

fn embed_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Embed axis axis_a of the receiver as the diagonal of a new axis pair; axis_b (signed, against the output rank) is the position of the inserted axis.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.embed_diag(0, -1, &mut engine)?;
assert_eq!(y.shape(), &[2, 2, 2]);
Source

fn slice( &self, config: SliceConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Static strided slice (SliceConfig).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{SliceConfig, Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.slice(SliceConfig { starts: vec![0, 0], limits: vec![1, 2], strides: vec![1, 1] }, &mut engine)?;
assert_eq!(y.shape(), &[1, 2]);
Source

fn pad( &self, config: PadConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Pad with edge and interior padding (PadConfig).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{PadConfig, Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.pad(PadConfig { edge_padding_low: vec![1, 0], edge_padding_high: vec![0, 0], interior_padding: vec![0, 0] }, &mut engine)?;
assert_eq!(y.shape(), &[3, 2]);
Source

fn gather( &self, indices: &impl AsView, config: GatherConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

XLA-style gather (GatherConfig); indices is an integer tensor of any representation.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_runtime::CoreOps;

// See the `gather` tests for a complete configuration.
fn _uses_gather<X: CoreOps>() {}
Source

fn scatter( &self, indices: &impl AsView, updates: &impl AsView, config: ScatterConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

XLA-style scatter (ScatterConfig); indices and updates may have any representation.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_runtime::CoreOps;

// See the `scatter` tests for a complete configuration.
fn _uses_scatter<X: CoreOps>() {}
Source

fn dynamic_slice( &self, starts: &impl AsView, sizes: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Slice of sizes starting at the run-time starts (an integer vector).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let starts = Tensor::from_vec_col_major(vec![2], vec![1_i64, 0])?;
let y = a.dynamic_slice(&starts, &[1, 2], &mut engine)?;
assert_eq!(y.shape(), &[1, 2]);
Source

fn dynamic_update_slice( &self, update: &impl AsView<Repr = Self::Repr>, starts: &impl AsView, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Copy of the receiver with update written at the run-time starts.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Omissions
  • traced and eager: not available
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let u = Tensor::from_vec_col_major(vec![1, 2], vec![9.0_f64, 9.0])?;
let starts = Tensor::from_vec_col_major(vec![2], vec![1_i64, 0])?;
let y = a.dynamic_update_slice(&u, &starts, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn concatenate( inputs: &[&Self], axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr, Self: Sized,

Concatenate inputs along axis (signed). Called as CoreOps::concatenate(&[&a, &b], axis, exec).

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::Tensor;

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = Tensor::concatenate(&[&a, &a], -1, &mut engine)?;
assert_eq!(y.shape(), &[2, 4]);
Source

fn convert(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor>
where Self::Repr: CoreRepr,

Checked dtype conversion along tenferro’s promotion lattice. The result is a dtype-erased Tensor because its dtype is a run-time value.

This operation has no options.

§Layout

An owned Tensor receiver is converted directly. Any other receiver (a borrowed view or a typed tensor) is first gathered once into a compact tensor of the same placement and dtype, because the engine conversion reads an owned tensor.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{DType, Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.convert(DType::C64, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn cast(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor>
where Self::Repr: CoreRepr,

Explicit, possibly lossy dtype projection. The result is a dtype-erased Tensor because its dtype is a run-time value.

This operation has no options.

§Layout

An owned Tensor receiver is converted directly. Any other receiver (a borrowed view or a typed tensor) is first gathered once into a compact tensor of the same placement and dtype, because the engine conversion reads an owned tensor.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{DType, Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.cast(DType::F32, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn scale_real( &self, factor: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Multiply by a real scalar.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.scale_real(2.0, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn scale_complex( &self, factor: Complex64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Multiply by a complex scalar.

This operation has no options.

§Layout

Every operand is read through TensorRead by the engine’s *_read entry: owned, borrowed, typed and strided inputs reach the same body. Implicit broadcasting is a zero-stride view, never a copy. Whether a strided or negative-stride view is read in place or gathered once (same placement and dtype) is the engine’s documented choice for that kernel.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use num_complex::Complex64;
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::Tensor;

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![1], vec![Complex64::new(1.0, 0.0)])?;
let y = a.scale_complex(Complex64::new(0.0, 1.0), &mut engine)?;
assert_eq!(y.shape(), &[1]);
Source

fn softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Softmax along axis (signed).

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.softmax(-1, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn log_softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Log-softmax along axis (signed).

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.log_softmax(-1, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn masked_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Softmax along axis over the entries where mask is true.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let m = Tensor::from_vec_col_major(vec![2, 2], vec![true, true, false, true])?;
let y = a.masked_softmax(&m, -1, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn masked_log_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Log-softmax along axis over the entries where mask is true.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let m = Tensor::from_vec_col_major(vec![2, 2], vec![true, true, false, true])?;
let y = a.masked_log_softmax(&m, -1, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn take_along_axis( &self, indices: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Gather along axis (signed) with per-position integer indices.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let i = Tensor::from_vec_col_major(vec![2, 1], vec![1_i64, 0])?;
let y = a.take_along_axis(&i, -1, &mut engine)?;
assert_eq!(y.shape(), &[2, 1]);
Source

fn layer_norm( &self, axis: isize, weight: Option<&Self>, bias: Option<&Self>, eps: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

Layer normalization over axis (signed) with optional affine weight and bias.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.layer_norm(-1, None, None, 1e-5, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);
Source

fn rms_norm( &self, axis: isize, weight: Option<&Self>, bias: Option<&Self>, eps: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
where Self::Repr: CoreRepr,

RMS normalization over axis (signed) with optional affine weight and bias.

This operation has no options.

§Layout

Composed from core primitives inside the engine; operands are read through TensorRead and intermediates are engine allocations. A fused engine kernel is used when the engine offers one.

§Errors

Returns an error of kind:

  • Validation
  • Unsupported
§Examples
use tenferro_cpu::CpuEngine;
use tenferro_runtime::CoreOps;
use tenferro_tensor::{Tensor};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let y = a.rms_norm(-1, None, None, 1e-5, &mut engine)?;
assert_eq!(y.shape(), &[2, 2]);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<X: AsView + ?Sized> CoreOps for X