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§
Sourcefn exp(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn exp(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn neg(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn neg(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn sign(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn sign(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn conj(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn conj(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn log(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn log(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn expm1(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn expm1(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn log1p(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn log1p(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn erf(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn erf(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn sin(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn sin(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn cos(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn cos(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn tanh(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn tanh(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn sqrt(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn sqrt(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn rsqrt(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn rsqrt(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn abs(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as CoreRepr>::Real>
fn abs(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as CoreRepr>::Real>
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:
ValidationUnsupported
§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]);Sourcefn sigmoid(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn sigmoid(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn silu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn silu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn softplus(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn softplus(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn gelu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
fn gelu(&self, exec: &mut dyn Engine) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn gelu_tanh(
&self,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn gelu_tanh( &self, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn mul(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn mul( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn sub(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn sub( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn div(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn div( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn rem(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn rem( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn pow(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn pow( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn maximum(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn maximum( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn minimum(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn minimum( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn add(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn add( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§Omissions
- traced and eager: only
add;add_intoexists 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]);Sourcefn add_into(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
dest: Dest<<Self::Repr as Repr>::Write<'_>>,
) -> Result<()>
fn add_into( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, dest: Dest<<Self::Repr as Repr>::Write<'_>>, ) -> Result<()>
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:
ValidationUnsupported
§Omissions
- traced and eager: only
add;add_intoexists 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]);Sourcefn matmul(
&self,
b: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn matmul( &self, b: &impl AsView<Repr = Self::Repr>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn compare(
&self,
b: &impl AsView<Repr = Self::Repr>,
dir: CompareDir,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as CoreRepr>::Bool>
fn compare( &self, b: &impl AsView<Repr = Self::Repr>, dir: CompareDir, exec: &mut dyn Engine, ) -> Result<<Self::Repr as CoreRepr>::Bool>
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:
ValidationUnsupported
§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]);Sourcefn clamp(
&self,
lower: &impl AsView<Repr = Self::Repr>,
upper: &impl AsView<Repr = Self::Repr>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
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>
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:
ValidationUnsupported
§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]);Sourcefn 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>
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>
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:
ValidationUnsupported
§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]);Sourcefn dot_general(
&self,
b: &impl AsView<Repr = Self::Repr>,
config: DotGeneralConfig,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn dot_general( &self, b: &impl AsView<Repr = Self::Repr>, config: DotGeneralConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§Omissions
- traced: no
dot_general_with; conjugate an operand withconj()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]);Sourcefn dot_general_with(
&self,
b: &impl AsView<Repr = Self::Repr>,
config: DotGeneralConfig,
options: &DotGeneralOptions,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
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>
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:
ValidationUnsupported
§Omissions
- traced: no
dot_general_with; conjugate an operand withconj()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]);Sourcefn reduce_sum(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reduce_sum( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn reduce_max(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reduce_max( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn reduce_min(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reduce_min( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn reduce_prod(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reduce_prod( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn reduce_sum_squares(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reduce_sum_squares( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn reduce_mean(
&self,
axes: Option<&[isize]>,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reduce_mean( &self, axes: Option<&[isize]>, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn reshape(
&self,
shape: &[usize],
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reshape( &self, shape: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn broadcast_in_dim(
&self,
shape: &[usize],
dims: &[usize],
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn broadcast_in_dim( &self, shape: &[usize], dims: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn transpose(
&self,
perm: &[isize],
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn transpose( &self, perm: &[isize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn reverse(
&self,
axes: &[isize],
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn reverse( &self, axes: &[isize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn tril(
&self,
k: i64,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn tril( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn triu(
&self,
k: i64,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn triu( &self, k: i64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn extract_diag(
&self,
axis_a: isize,
axis_b: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn extract_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn embed_diag(
&self,
axis_a: isize,
axis_b: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn embed_diag( &self, axis_a: isize, axis_b: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn slice(
&self,
config: SliceConfig,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn slice( &self, config: SliceConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn pad(
&self,
config: PadConfig,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn pad( &self, config: PadConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn gather(
&self,
indices: &impl AsView,
config: GatherConfig,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn gather( &self, indices: &impl AsView, config: GatherConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§Examples
use tenferro_runtime::CoreOps;
// See the `gather` tests for a complete configuration.
fn _uses_gather<X: CoreOps>() {}Sourcefn scatter(
&self,
indices: &impl AsView,
updates: &impl AsView,
config: ScatterConfig,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn scatter( &self, indices: &impl AsView, updates: &impl AsView, config: ScatterConfig, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§Examples
use tenferro_runtime::CoreOps;
// See the `scatter` tests for a complete configuration.
fn _uses_scatter<X: CoreOps>() {}Sourcefn dynamic_slice(
&self,
starts: &impl AsView,
sizes: &[usize],
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn dynamic_slice( &self, starts: &impl AsView, sizes: &[usize], exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn dynamic_update_slice(
&self,
update: &impl AsView<Repr = Self::Repr>,
starts: &impl AsView,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn dynamic_update_slice( &self, update: &impl AsView<Repr = Self::Repr>, starts: &impl AsView, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn concatenate(
inputs: &[&Self],
axis: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn concatenate( inputs: &[&Self], axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn convert(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor>
fn convert(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor>
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:
ValidationUnsupported
§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]);Sourcefn cast(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor>
fn cast(&self, to: DType, exec: &mut dyn Engine) -> Result<Tensor>
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:
ValidationUnsupported
§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]);Sourcefn scale_real(
&self,
factor: f64,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn scale_real( &self, factor: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn scale_complex(
&self,
factor: Complex64,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn scale_complex( &self, factor: Complex64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn softmax(
&self,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn log_softmax(
&self,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn log_softmax( &self, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn masked_softmax(
&self,
mask: &impl AsView,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn masked_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn masked_log_softmax(
&self,
mask: &impl AsView,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn masked_log_softmax( &self, mask: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn take_along_axis(
&self,
indices: &impl AsView,
axis: isize,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn take_along_axis( &self, indices: &impl AsView, axis: isize, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn layer_norm(
&self,
axis: isize,
weight: Option<&Self>,
bias: Option<&Self>,
eps: f64,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn layer_norm( &self, axis: isize, weight: Option<&Self>, bias: Option<&Self>, eps: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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]);Sourcefn rms_norm(
&self,
axis: isize,
weight: Option<&Self>,
bias: Option<&Self>,
eps: f64,
exec: &mut dyn Engine,
) -> Result<<Self::Repr as Repr>::Value>
fn rms_norm( &self, axis: isize, weight: Option<&Self>, bias: Option<&Self>, eps: f64, exec: &mut dyn Engine, ) -> Result<<Self::Repr as Repr>::Value>
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:
ValidationUnsupported
§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".