pub struct EagerTensor { /* private fields */ }Expand description
Eager tensor with reverse-mode autodiff over concrete tensor values.
This executes each primitive immediately and records a lightweight reverse
DAG for backward(). Gradients accumulate across repeated backward()
calls until they are cleared explicitly.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 3.0]).unwrap(), ctx)?;
let loss = x.mul(&x).unwrap().reduce_sum(Some(&[0])).unwrap();
let _cotangents = loss.backward().unwrap();
let loss = x.mul(&x).unwrap().reduce_sum(Some(&[0])).unwrap();
let _cotangents = loss.backward().unwrap();
assert_eq!(x.grad().unwrap().unwrap().as_slice::<f64>().unwrap(), &[4.0, 8.0, 12.0]);
x.clear_grad();
assert!(x.grad().unwrap().is_none());Implementations§
Source§impl EagerTensor
impl EagerTensor
Sourcepub fn from_tensor_in(tensor: Tensor, ctx: Arc<EagerRuntime>) -> Result<Self>
pub fn from_tensor_in(tensor: Tensor, ctx: Arc<EagerRuntime>) -> Result<Self>
Create an untracked eager tensor inside an existing eager context.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx)?;
assert_eq!(x.materialized()?.as_slice::<f64>().unwrap(), &[1.0, 2.0]);§Errors
Returns tenferro_runtime::Error::RuntimeState when metadata cannot
be registered in the target context, or a typed tensor/backend error
while materializing the source value.
Sourcepub fn from_vec_col_major_in<T: TensorScalar>(
shape: impl IntoShapeVec,
data: Vec<T>,
ctx: Arc<EagerRuntime>,
) -> Result<Self>
pub fn from_vec_col_major_in<T: TensorScalar>( shape: impl IntoShapeVec, data: Vec<T>, ctx: Arc<EagerRuntime>, ) -> Result<Self>
Create an untracked eager tensor from compact column-major data inside an existing eager runtime.
§Errors
Returns Error::TensorRuntime with
tenferro_tensor::ValidationError::ShapeMismatch when the shape and
data length disagree, or with
tenferro_tensor::ValidationError::IntegerOverflow when shape
arithmetic overflows. Returns Error::RuntimeState when eager
metadata cannot be registered.
Sourcepub fn requires_grad_in(tensor: Tensor, ctx: Arc<EagerRuntime>) -> Result<Self>
pub fn requires_grad_in(tensor: Tensor, ctx: Arc<EagerRuntime>) -> Result<Self>
Create a tracked eager leaf inside an existing eager context.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx)?;
assert!(x.grad().unwrap().is_none());§Errors
Returns tenferro_runtime::Error::RuntimeState when gradient metadata
cannot be registered in the target context, or a typed tensor/backend
error while creating the leaf.
Sourcepub fn detach(&self) -> Self
pub fn detach(&self) -> Self
Detach this tensor from the reverse graph.
The returned tensor keeps the concrete value but no longer contributes gradients to the original graph.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx)?;
let y = x.detach();
assert_eq!(y.materialized()?.as_slice::<f64>().unwrap(), &[1.0, 2.0]);
assert!(y.grad().unwrap().is_none());Sourcepub fn detach_into(&self, ctx: &Arc<EagerRuntime>) -> Result<Self>
pub fn detach_into(&self, ctx: &Arc<EagerRuntime>) -> Result<Self>
Detach this tensor from its graph and re-register it in a different context as an untracked leaf.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx_a = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let ctx_b = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx_a)?;
let d = x.detach_into(&ctx_b)?;
assert!(!d.tracks_grad());
assert_eq!(d.ctx_id(), ctx_b.id());§Errors
Returns Error::RuntimeState if the source cannot be materialized or
the target context cannot register its metadata.
Sourcepub fn materialized(&self) -> Result<Arc<Tensor>>
pub fn materialized(&self) -> Result<Arc<Tensor>>
Materialize and share the concrete tensor value.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![3.0_f64]).unwrap(), ctx)?;
assert_eq!(x.materialized()?.as_slice::<f64>().unwrap(), &[3.0]);§Errors
Returns Error::RuntimeState when lazy/backend-resident storage cannot
be materialized, or when eager value-record state is poisoned.
Sourcepub fn dtype(&self) -> DType
pub fn dtype(&self) -> DType
Return this tensor’s scalar dtype without materializing through
materialized.
Sourcepub fn shape(&self) -> &[usize]
pub fn shape(&self) -> &[usize]
Return this tensor’s logical shape without materializing through
materialized.
Sourcepub fn tensor_read(&self) -> TensorRead<'_>
pub fn tensor_read(&self) -> TensorRead<'_>
Borrow this tensor value as a TensorRead.
This is the preferred borrowed input boundary for executor calls. It
preserves the option to replace eager storage with non-contiguous views
without forcing callers through materialized.
Sourcepub fn to_tensor(&self) -> Result<Tensor>
pub fn to_tensor(&self) -> Result<Tensor>
Materialize this eager tensor as an owned Tensor.
This is the owned materialization boundary for callers that need a standalone compact tensor. The operation is fallible because eager values may be backed by lazy or backend-resident storage.
§Errors
Returns Error::RuntimeState if backend state is unavailable, or a
typed tensor backend error when contiguous materialization fails.
Sourcepub fn grad(&self) -> Result<Option<Arc<Tensor>>>
pub fn grad(&self) -> Result<Option<Arc<Tensor>>>
Return the accumulated gradient currently stored for this tensor.
The stored gradient accumulates across repeated backward() calls
until it is cleared explicitly.
For complex scalar losses, stored gradients use tenferro’s Hermitian-adjoint cotangent convention. See https://tensor4all.org/tenferro-rs/guides/complex-ad.html.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx).unwrap();
let loss = x.exp().unwrap().reduce_sum(Some(&[0])).unwrap();
let _cotangents = loss.backward().unwrap();
let grad = x.grad()?.unwrap();
assert_eq!(grad.shape(), &[2]);§Errors
Returns Error::RuntimeState if the gradient slot is poisoned or no
longer available.
Sourcepub fn clear_grad(&self) -> Result<()>
pub fn clear_grad(&self) -> Result<()>
Clear the accumulated gradient stored for this tensor.
This only affects this tensor’s gradient slot. Other tensors in the same context retain their gradients until they are cleared explicitly or overwritten by later accumulation.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 3.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![3], vec![4.0_f64, 5.0, 6.0]).unwrap(), ctx).unwrap();
let loss = x.mul(&y).unwrap().reduce_sum(Some(&[0])).unwrap();
let _ = loss.backward().unwrap();
x.clear_grad()?;
assert!(x.grad()?.is_none());
assert!(y.grad()?.is_some());§Errors
Returns Error::RuntimeState if the gradient slot lock is poisoned.
Sourcepub fn tracks_grad(&self) -> bool
pub fn tracks_grad(&self) -> bool
Report whether this tensor participates in gradient tracking.
Tracked tensors keep a gradient slot in their eager context; untracked tensors and detached tensors do not.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let plain = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let tracked = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap(), ctx.clone()).unwrap();
let detached = tracked.detach();
assert!(!plain.tracks_grad());
assert!(tracked.tracks_grad());
assert!(!detached.tracks_grad());Sourcepub fn ctx_id(&self) -> ContextId
pub fn ctx_id(&self) -> ContextId
Return the opaque identifier of the context this tensor belongs to.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap(), ctx.clone()).unwrap();
assert_eq!(x.ctx_id(), ctx.id());Sourcepub fn runtime(&self) -> &Arc<EagerRuntime> ⓘ
pub fn runtime(&self) -> &Arc<EagerRuntime> ⓘ
Borrow the eager runtime context that owns this tensor.
Sourcepub fn same_context(&self, other: &Self) -> bool
pub fn same_context(&self, other: &Self) -> bool
Check whether two tensors belong to the same eager context.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap(), ctx).unwrap();
assert!(x.same_context(&y));Sourcepub fn backward(&self) -> Result<HashMap<ValueKey<StdTensorOp>, Arc<Tensor>>>
pub fn backward(&self) -> Result<HashMap<ValueKey<StdTensorOp>, Arc<Tensor>>>
Run reverse-mode AD from this scalar output.
Returns the full cotangent map produced by the reverse pass and also
accumulates into grad() for tracked eager tensors reachable from this
output.
For complex scalar outputs, cotangents use tenferro’s Hermitian real-inner-product convention. See https://tensor4all.org/tenferro-rs/guides/complex-ad.html.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 3.0]).unwrap(), ctx).unwrap();
let loss = x.add(&x).unwrap().reduce_sum(Some(&[0])).unwrap();
let _cotangents = loss.backward().unwrap();
let loss = x.add(&x).unwrap().reduce_sum(Some(&[0])).unwrap();
let _cotangents = loss.backward().unwrap();
assert_eq!(x.grad().unwrap().unwrap().as_slice::<f64>().unwrap(), &[4.0, 4.0, 4.0]);§Errors
Returns Error::NonScalarGrad when this output is not scalar,
Error::UnsupportedAdRule when a graph operation lacks a reverse rule,
or a typed validation/backend/runtime-state error during the reverse pass.
Sourcepub fn backward_with(
&self,
cotangent: &EagerTensor,
) -> Result<HashMap<ValueKey<StdTensorOp>, Arc<Tensor>>>
pub fn backward_with( &self, cotangent: &EagerTensor, ) -> Result<HashMap<ValueKey<StdTensorOp>, Arc<Tensor>>>
Run reverse-mode AD from this output with an explicit cotangent seed.
This is the stateful eager VJP sugar: it returns the cotangent map and
accumulates reachable tracked leaves into their grad() slots. Use
EagerRuntime::vjp when the VJP result should be returned as a
composable eager tensor without touching grad slots.
§Examples
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
use tenferro_cpu::CpuBackend;
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::requires_grad_in(
Tensor::from_vec_col_major(vec![2], vec![2.0_f64, 3.0]).unwrap(),
ctx.clone(),
)?;
let seed = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(),
ctx,
)?;
let y = x.mul(&x)?;
y.backward_with(&seed)?;
assert_eq!(x.grad()?.unwrap().as_slice::<f64>().unwrap(), &[4.0, 12.0]);§Errors
Returns Error::ContextMismatch when cotangent belongs to another
eager runtime, Error::Validation when its shape or dtype is not a
valid seed, Error::UnsupportedAdRule for an unavailable reverse
rule, or a typed backend/runtime-state error during execution.
Source§impl EagerTensor
impl EagerTensor
Sourcepub fn add(&self, other: &Self) -> Result<Self>
pub fn add(&self, other: &Self) -> Result<Self>
Elementwise addition.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap(), ctx.clone()).unwrap();
let z = x.add(&y).unwrap();
assert_eq!(z.materialized().unwrap().as_slice::<f64>().unwrap(), &[4.0, 6.0]);§Errors
Returns Error::ContextMismatch for tensors from different eager
runtimes, tenferro_tensor::Error::Validation with
ShapeMismatch/DTypeMismatch for incompatible operands, or a typed
backend/runtime-state error during execution.
Sourcepub fn sub(&self, other: &Self) -> Result<Self>
pub fn sub(&self, other: &Self) -> Result<Self>
Elementwise subtraction.
§Errors
Returns Error::ContextMismatch for tensors from different eager
runtimes, tenferro_tensor::Error::Validation with
ShapeMismatch/DTypeMismatch for incompatible operands, or a typed
backend/runtime-state error during execution.
Sourcepub fn mul(&self, other: &Self) -> Result<Self>
pub fn mul(&self, other: &Self) -> Result<Self>
Elementwise multiplication.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap(), ctx.clone()).unwrap();
let z = x.mul(&y).unwrap();
assert_eq!(z.materialized().unwrap().as_slice::<f64>().unwrap(), &[3.0, 8.0]);§Errors
Returns Error::ContextMismatch for tensors from different eager
runtimes, tenferro_tensor::Error::Validation with
ShapeMismatch/DTypeMismatch for incompatible operands, or a typed
backend/runtime-state error during execution.
Sourcepub fn neg(&self) -> Result<Self>
pub fn neg(&self) -> Result<Self>
Negate the tensor.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, -2.0]).unwrap(), ctx.clone()).unwrap();
let y = x.neg().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[-1.0, 2.0]);§Errors
Returns tenferro_tensor::Error::Unsupported when the backend does
not implement negation for the dtype, or a typed backend/runtime-state
error during execution.
Sourcepub fn exp(&self) -> Result<Self>
pub fn exp(&self) -> Result<Self>
Elementwise exponential.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![0.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.exp().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0]);§Errors
Returns tenferro_tensor::Error::Unsupported when the backend does
not implement exponentiation for the dtype, or a typed backend/
runtime-state error during execution.
Sourcepub fn reduce_sum(&self, axes: Option<&[usize]>) -> Result<Self>
pub fn reduce_sum(&self, axes: Option<&[usize]>) -> Result<Self>
Reduce sum over the requested axes.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.reduce_sum(None).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[10.0]);§Errors
Returns tenferro_tensor::Error::Validation with AxisOutOfBounds or
DuplicateAxis for an invalid reduction axis, or a typed
unsupported/backend/runtime-state error for the selected dtype.
Sourcepub fn reduce_sum_squares(&self, axes: &[usize]) -> Result<Self>
pub fn reduce_sum_squares(&self, axes: &[usize]) -> Result<Self>
Sum elementwise squares over the requested axes.
Each value is squared in its input dtype before reduction. The initial
supported dtypes are f32 and f64; other dtypes return a typed
unsupported error. Passing an empty axis slice returns the elementwise
square without reducing rank.
This operation is useful when the squared sum is needed directly. Use the linalg norm APIs when a square root or complex magnitude semantics are required.
§Errors
Returns a typed validation error for invalid axes, a typed unsupported error for other dtypes, or a typed backend or runtime-state error during execution.
Sourcepub fn dot_general(
&self,
other: &Self,
config: DotGeneralConfig,
) -> Result<Self>
pub fn dot_general( &self, other: &Self, config: DotGeneralConfig, ) -> Result<Self>
Execute a dot-general contraction eagerly.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{DotGeneralConfig, EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let a = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 3], vec![1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0]).unwrap(), ctx.clone()).unwrap();
let b = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3, 2], vec![1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0]).unwrap(), ctx.clone()).unwrap();
let c = a.dot_general(&b, DotGeneralConfig {
lhs_contracting_dims: vec![1],
rhs_contracting_dims: vec![0],
lhs_batch_dims: vec![],
rhs_batch_dims: vec![],
}).unwrap();
assert_eq!(c.shape(), &[2, 2]);§Errors
Returns tenferro_tensor::Error::Validation with RankMismatch,
AxisOutOfBounds, DuplicateAxis, ShapeMismatch, or DTypeMismatch
when config or the operands are invalid; backend and runtime-state
failures retain their typed sources.
Sourcepub fn dot_general_with_conj(
&self,
other: &Self,
config: DotGeneralConfig,
lhs_conj: bool,
rhs_conj: bool,
) -> Result<Self>
pub fn dot_general_with_conj( &self, other: &Self, config: DotGeneralConfig, lhs_conj: bool, rhs_conj: bool, ) -> Result<Self>
Execute a dot-general contraction, optionally conjugating either operand.
Untracked tensors route the conjugation flags directly to the backend so
the conjugated operand does not need to be materialized. Tracked tensors
fall back to explicit Conj plus DotGeneral so reverse-mode AD keeps
the same graph semantics as the standard eager ops.
§Errors
Returns Error::ContextMismatch for operands from different eager
runtimes, tenferro_tensor::Error::Validation for rank/axis/shape or
dtype mismatches in config, or a typed backend/runtime-state error.
Sourcepub fn scale_real(&self, factor: f64) -> Result<Self>
pub fn scale_real(&self, factor: f64) -> Result<Self>
Scale by a real scalar: y = factor * x.
Integer factors are rounded to the nearest integer before multiplication,
boolean factors map finite zero to false and other finite values to
true, and complex tensors receive a zero-imaginary scalar.
§Errors
Returns Error::TensorRuntime with
tenferro_tensor::ValidationError::InvalidArgument when an integer or
boolean factor is non-finite or outside the input dtype’s range. Backend
and runtime execution failures retain their typed source variants.
Sourcepub fn scale_complex(&self, factor: Complex64) -> Result<Self>
pub fn scale_complex(&self, factor: Complex64) -> Result<Self>
Scale a complex tensor by a complex scalar: y = factor * x.
§Errors
Returns Error::TensorRuntime with
tenferro_tensor::ValidationError::InvalidArgument for a non-complex
input dtype. Backend and runtime execution failures retain their typed
source variants.
Sourcepub fn matmul(&self, other: &Self) -> Result<Self>
pub fn matmul(&self, other: &Self) -> Result<Self>
Matrix multiplication for rank-2 tensors.
This is a convenience wrapper over Self::dot_general that
contracts the left matrix’s column axis with the right matrix’s row
axis.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let a = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(),
ctx.clone(),
).unwrap();
let b = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![2, 1], vec![5.0_f64, 6.0]).unwrap(),
ctx,
).unwrap();
let c = a.matmul(&b).unwrap();
assert_eq!(c.shape(), &[2, 1]);
assert_eq!(c.materialized().unwrap().as_slice::<f64>().unwrap(), &[23.0, 34.0]);§Errors
Returns tenferro_tensor::ValidationError::RankMismatch when either operand is
not rank 2, ShapeMismatch when the inner dimensions differ, or a typed
dtype/backend/runtime-state error during the contraction.
Sourcepub fn transpose(&self, perm: &[usize]) -> Result<Self>
pub fn transpose(&self, perm: &[usize]) -> Result<Self>
Permute tensor axes.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(
vec![2, 3],
vec![1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0],
).unwrap(), ctx.clone()).unwrap();
let y = x.transpose(&[1, 0]).unwrap();
assert_eq!(y.shape(), &[3, 2]);
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 3.0, 5.0, 2.0, 4.0, 6.0]);§Errors
Returns tenferro_tensor::Error::Validation with AxisOutOfBounds
or DuplicateAxis when perm is not a permutation, or a typed
backend/runtime-state error while creating the view.
Sourcepub fn reshape(&self, shape: &[usize]) -> Result<Self>
pub fn reshape(&self, shape: &[usize]) -> Result<Self>
Reshape without changing element order.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(
vec![2, 3],
vec![1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0],
).unwrap(), ctx.clone()).unwrap();
let y = x.reshape(&[6]).unwrap();
assert_eq!(y.shape(), &[6]);
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);§Errors
Returns tenferro_tensor::ValidationError::ShapeMismatch when the element count
changes, InvalidArgument when the target shape product overflows, or a
typed backend/runtime-state error.
Sourcepub fn slice(&self, config: SliceConfig) -> Result<Self>
pub fn slice(&self, config: SliceConfig) -> Result<Self>
Slice with explicit start, limit, and stride per axis.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, SliceConfig, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![4], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x
.slice(SliceConfig {
starts: vec![1],
limits: vec![3],
strides: vec![1],
})
.unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[2.0, 3.0]);§Errors
Returns tenferro_tensor::Error::Validation with
AxisOutOfBounds/InvalidArgument when starts, limits, or strides are
invalid, or a typed backend/runtime-state error while creating the view.
Sourcepub fn broadcast_in_dim(&self, shape: &[usize], dims: &[usize]) -> Result<Self>
pub fn broadcast_in_dim(&self, shape: &[usize], dims: &[usize]) -> Result<Self>
Broadcast into a larger shape with explicit dimension placement.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 3.0]).unwrap(), ctx.clone()).unwrap();
let y = x.broadcast_in_dim(&[3, 2], &[0]).unwrap();
assert_eq!(y.shape(), &[3, 2]);§Errors
Returns tenferro_tensor::Error::Validation with AxisOutOfBounds,
DuplicateAxis, or ShapeMismatch when shape/dims cannot broadcast
the input, or a typed backend/runtime-state error.
Sourcepub fn convert(&self, to: DType) -> Result<Self>
pub fn convert(&self, to: DType) -> Result<Self>
Convert the tensor to a different dtype using checked conversion.
Use cast when a lossy dtype projection is intended.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{DType, EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, -2.0]).unwrap(), ctx.clone()).unwrap();
let y = x.convert(DType::C64).unwrap();
assert_eq!(y.dtype(), DType::C64);
assert_eq!(y.shape(), &[2]);§Errors
Returns tenferro_tensor::Error::UnsupportedDTypeConversion when the
requested pair is outside tenferro’s checked dtype-promotion lattice.
Use cast for explicit lossy projection; backend
execution can additionally return a typed runtime-state error.
Sourcepub fn cast(&self, to: DType) -> Result<Self>
pub fn cast(&self, to: DType) -> Result<Self>
Cast the tensor to a different dtype using explicit dtype projection.
cast may truncate, narrow precision, project complex values to their
real component, or use boolean truthiness where the backend supports the
requested projection.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{DType, EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.2_f64, -2.8]).unwrap(), ctx.clone()).unwrap();
let y = x.cast(DType::I32).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<i32>().unwrap(), &[1, -2]);§Errors
Returns a typed tenferro_tensor::Error::Unsupported when the eager
backend cannot project the requested dtype, or a backend/runtime-state
error during execution.
Sourcepub fn pad(&self, config: PadConfig) -> Result<Self>
pub fn pad(&self, config: PadConfig) -> Result<Self>
Pad with zeros using StableHLO-style edge and interior padding.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, PadConfig, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let y = x
.pad(PadConfig {
edge_padding_low: vec![1],
edge_padding_high: vec![1],
interior_padding: vec![1],
})
.unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.0, 1.0, 0.0, 2.0, 0.0]);§Errors
Returns tenferro_runtime::Error::TensorRuntime containing
tenferro_tensor::ValidationError::InvalidArgument when a
padding vector has a length different from the input rank, interior
padding is negative, or edge/interior padding produces a negative
dimension or checked output-size arithmetic overflows.
Backend execution and unavailable runtime state are propagated as their
typed tenferro_runtime::Error::TensorRuntime or
tenferro_runtime::Error::RuntimeState variants.
Sourcepub fn reverse(&self, axes: &[usize]) -> Result<Self>
pub fn reverse(&self, axes: &[usize]) -> Result<Self>
Reverse the order of elements along the requested axes.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![4], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.reverse(&[0]).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[4.0, 3.0, 2.0, 1.0]);§Errors
Returns tenferro_tensor::Error::Validation with AxisOutOfBounds or
DuplicateAxis for an invalid axis list, or a typed backend/
runtime-state error during execution.
Sourcepub fn gather(&self, indices: &Self, config: GatherConfig) -> Result<Self>
pub fn gather(&self, indices: &Self, config: GatherConfig) -> Result<Self>
Gather slices from self using integer start indices.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, GatherConfig, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(
vec![5],
vec![10.0_f64, 20.0, 30.0, 40.0, 50.0],
).unwrap(), ctx.clone()).unwrap();
let indices = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![4_i64, 1, 0]).unwrap(), ctx.clone()).unwrap();
let y = x
.gather(
&indices,
GatherConfig {
offset_dims: vec![],
collapsed_slice_dims: vec![0],
start_index_map: vec![0],
index_vector_dim: 1,
slice_sizes: vec![1],
},
)
.unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[50.0, 20.0, 10.0]);§Errors
Returns tenferro_tensor::Error::Validation when the gather
configuration has an invalid rank, axis, shape, or index dtype, or a
typed backend/runtime-state error.
Sourcepub fn scatter(
&self,
indices: &Self,
updates: &Self,
config: ScatterConfig,
) -> Result<Self>
pub fn scatter( &self, indices: &Self, updates: &Self, config: ScatterConfig, ) -> Result<Self>
Scatter updates into self using StableHLO scatter semantics.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, ScatterConfig, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let operand = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![4], vec![0.0_f64, 0.0, 0.0, 0.0]).unwrap(), ctx.clone()).unwrap();
let indices = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 1], vec![1_i64, 3]).unwrap(), ctx.clone()).unwrap();
let updates = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![5.0_f64, 7.0]).unwrap(), ctx.clone()).unwrap();
let result = operand
.scatter(
&indices,
&updates,
ScatterConfig {
update_window_dims: vec![],
inserted_window_dims: vec![0],
scatter_dims_to_operand_dims: vec![0],
index_vector_dim: 1,
},
)
.unwrap();
assert_eq!(result.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.0, 5.0, 0.0, 7.0]);§Errors
Returns tenferro_tensor::Error::Validation when the scatter
configuration, index/update shapes, or index dtype is invalid, or a
typed backend/runtime-state error.
Sourcepub fn dynamic_slice(&self, starts: &Self, sizes: &[usize]) -> Result<Self>
pub fn dynamic_slice(&self, starts: &Self, sizes: &[usize]) -> Result<Self>
Slice using runtime start indices.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![5], vec![1.0_f64, 2.0, 3.0, 4.0, 5.0]).unwrap(), ctx.clone()).unwrap();
let starts = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![2_i64]).unwrap(), ctx.clone()).unwrap();
let y = x.dynamic_slice(&starts, &[2]).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[3.0, 4.0]);§Errors
Returns tenferro_tensor::Error::Validation when starts has the
wrong dtype/shape or sizes exceeds the operand rank, including an
AxisOutOfBounds or ShapeMismatch, or a typed backend/runtime-state
error.
Sourcepub fn concatenate(tensors: &[&Self], axis: usize) -> Result<Self>
pub fn concatenate(tensors: &[&Self], axis: usize) -> Result<Self>
Concatenate tensors along one axis.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap(), ctx.clone()).unwrap();
let z = EagerTensor::concatenate(&[&x, &y], 0).unwrap();
assert_eq!(z.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 2.0, 3.0, 4.0]);§Errors
Returns tenferro_tensor::ValidationError::InvalidArgument when tensors is
empty or axis is outside the rank, ShapeMismatch/DTypeMismatch
when inputs cannot be concatenated, or a typed backend/runtime-state
error.
Sourcepub fn extract_diag(&self, axis_a: usize, axis_b: usize) -> Result<Self>
pub fn extract_diag(&self, axis_a: usize, axis_b: usize) -> Result<Self>
Extract the diagonal along two axes.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(
vec![3, 3],
vec![1.0_f64, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0],
).unwrap(), ctx.clone()).unwrap();
let y = x.extract_diag(0, 1).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 5.0, 9.0]);§Errors
Returns tenferro_tensor::Error::Validation with RankMismatch,
AxisOutOfBounds, or DuplicateAxis when the selected axes cannot form
a diagonal, or a typed backend/runtime-state error.
Sourcepub fn embed_diag(&self, axis_a: usize, axis_b: usize) -> Result<Self>
pub fn embed_diag(&self, axis_a: usize, axis_b: usize) -> Result<Self>
Embed a vector or lower-rank tensor along a diagonal.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 3.0]).unwrap(), ctx.clone()).unwrap();
let y = x.embed_diag(0, 1).unwrap();
assert_eq!(y.shape(), &[3, 3]);
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0]);§Errors
Returns tenferro_tensor::Error::Validation with RankMismatch,
AxisOutOfBounds, or DuplicateAxis when the diagonal axes are not
valid for embedding, or a typed backend/runtime-state error.
Sourcepub fn tril(&self, k: i64) -> Result<Self>
pub fn tril(&self, k: i64) -> Result<Self>
Keep the lower triangle and zero the rest.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.tril(0).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 2.0, 0.0, 4.0]);§Errors
Returns tenferro_tensor::ValidationError::RankMismatch when the operand is not
a matrix, or a typed unsupported/backend/runtime-state error.
Sourcepub fn triu(&self, k: i64) -> Result<Self>
pub fn triu(&self, k: i64) -> Result<Self>
Keep the upper triangle and zero the rest.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.triu(0).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 0.0, 3.0, 4.0]);§Errors
Returns tenferro_tensor::ValidationError::RankMismatch when the operand is not
a matrix, or a typed unsupported/backend/runtime-state error.
Sourcepub fn reduce_prod(&self, axes: Option<&[usize]>) -> Result<Self>
pub fn reduce_prod(&self, axes: Option<&[usize]>) -> Result<Self>
Reduce product over the requested axes.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.reduce_prod(None).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[24.0]);§Errors
Returns tenferro_tensor::Error::Validation with AxisOutOfBounds or
DuplicateAxis for an invalid reduction axis, or a typed
unsupported/backend/runtime-state error for the selected dtype.
Sourcepub fn reduce_max(&self, axes: Option<&[usize]>) -> Result<Self>
pub fn reduce_max(&self, axes: Option<&[usize]>) -> Result<Self>
Reduce maximum over the requested axes.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.reduce_max(None).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[4.0]);§Errors
Returns tenferro_tensor::Error::Validation with AxisOutOfBounds or
DuplicateAxis for an invalid reduction axis, or a typed
unsupported/backend/runtime-state error for the selected dtype.
Sourcepub fn reduce_min(&self, axes: Option<&[usize]>) -> Result<Self>
pub fn reduce_min(&self, axes: Option<&[usize]>) -> Result<Self>
Reduce minimum over the requested axes.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.reduce_min(None).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0]);§Errors
Returns tenferro_tensor::Error::Validation with AxisOutOfBounds or
DuplicateAxis for an invalid reduction axis, or a typed
unsupported/backend/runtime-state error for the selected dtype.
Source§impl EagerTensor
impl EagerTensor
Sourcepub fn abs(&self) -> Result<Self>
pub fn abs(&self) -> Result<Self>
Elementwise absolute value.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![-1.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let y = x.abs().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 2.0]);§Errors
Returns tenferro_tensor::Error::Unsupported when the dtype has no
absolute-value implementation, or a typed backend/runtime-state error.
Sourcepub fn conj(&self) -> Result<Self>
pub fn conj(&self) -> Result<Self>
Elementwise complex conjugate.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, -2.0]).unwrap(), ctx.clone()).unwrap();
let y = x.conj().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, -2.0]);§Errors
Returns tenferro_tensor::Error::Unsupported when conjugation is not
defined for the dtype, or a typed backend/runtime-state error.
Sourcepub fn sign(&self) -> Result<Self>
pub fn sign(&self) -> Result<Self>
Elementwise sign.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![-2.0_f64, 3.0]).unwrap(), ctx.clone()).unwrap();
let y = x.sign().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[-1.0, 1.0]);§Errors
Returns tenferro_tensor::Error::Unsupported when sign is not
defined for the dtype, or a typed backend/runtime-state error.
Sourcepub fn log(&self) -> Result<Self>
pub fn log(&self) -> Result<Self>
Elementwise natural logarithm.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![1.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.log().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.0]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn sqrt(&self) -> Result<Self>
pub fn sqrt(&self) -> Result<Self>
Elementwise square root.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![4.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.sqrt().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[2.0]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn rsqrt(&self) -> Result<Self>
pub fn rsqrt(&self) -> Result<Self>
Elementwise reciprocal square root.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![4.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.rsqrt().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.5]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn sin(&self) -> Result<Self>
pub fn sin(&self) -> Result<Self>
Elementwise sine.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![0.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.sin().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.0]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn cos(&self) -> Result<Self>
pub fn cos(&self) -> Result<Self>
Elementwise cosine.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![0.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.cos().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn tanh(&self) -> Result<Self>
pub fn tanh(&self) -> Result<Self>
Elementwise hyperbolic tangent.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![0.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.tanh().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.0]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn expm1(&self) -> Result<Self>
pub fn expm1(&self) -> Result<Self>
Elementwise exp(x) - 1.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![0.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.expm1().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.0]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn log1p(&self) -> Result<Self>
pub fn log1p(&self) -> Result<Self>
Elementwise log(1 + x).
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![1], vec![0.0_f64]).unwrap(), ctx.clone()).unwrap();
let y = x.log1p().unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[0.0]);§Errors
Returns tenferro_tensor::Error::Unsupported for an unsupported
dtype, or a typed backend/runtime-state error during execution.
Sourcepub fn div(&self, other: &Self) -> Result<Self>
pub fn div(&self, other: &Self) -> Result<Self>
Elementwise division.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![8.0_f64, -6.0, 9.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![2.0_f64, 3.0, 3.0]).unwrap(), ctx.clone()).unwrap();
let z = x.div(&y).unwrap();
assert_eq!(z.materialized().unwrap().as_slice::<f64>().unwrap(), &[4.0, -2.0, 3.0]);§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch or
ValidationError::DTypeMismatch for
incompatible operands, or a typed backend/runtime-state error. Addition
does not have a zero-divisor failure; numerical zero-divisor errors are
specific to division and remainder.
Sourcepub fn rem(&self, other: &Self) -> Result<Self>
pub fn rem(&self, other: &Self) -> Result<Self>
Elementwise remainder.
§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch or
ValidationError::DTypeMismatch for
incompatible operands, or a typed backend/runtime-state error.
Subtraction does not have a zero-divisor failure; numerical
zero-divisor errors are specific to division and remainder.
Sourcepub fn pow(&self, other: &Self) -> Result<Self>
pub fn pow(&self, other: &Self) -> Result<Self>
Elementwise power.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let base = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![2.0_f64, 3.0]).unwrap(), ctx.clone()).unwrap();
let exp = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let y = base.pow(&exp).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[8.0, 9.0]);§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch or
ValidationError::DTypeMismatch for
incompatible operands, NumericalFailure for a checked invalid power,
or a typed backend/runtime-state error.
Sourcepub fn maximum(&self, other: &Self) -> Result<Self>
pub fn maximum(&self, other: &Self) -> Result<Self>
Elementwise maximum.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 5.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap(), ctx.clone()).unwrap();
let z = x.maximum(&y).unwrap();
assert_eq!(z.materialized().unwrap().as_slice::<f64>().unwrap(), &[3.0, 5.0]);§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch or
ValidationError::DTypeMismatch for
incompatible operands, or a typed unsupported/backend/runtime-state
error.
Sourcepub fn minimum(&self, other: &Self) -> Result<Self>
pub fn minimum(&self, other: &Self) -> Result<Self>
Elementwise minimum.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 5.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap(), ctx.clone()).unwrap();
let z = x.minimum(&y).unwrap();
assert_eq!(z.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 4.0]);§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch or
ValidationError::DTypeMismatch for
incompatible operands, or a typed unsupported/backend/runtime-state
error.
Sourcepub fn compare(&self, other: &Self, dir: CompareDir) -> Result<Self>
pub fn compare(&self, other: &Self, dir: CompareDir) -> Result<Self>
Elementwise comparison.
§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch or
ValidationError::DTypeMismatch for
incompatible operands, or a typed unsupported/backend/runtime-state
error.
Sourcepub fn select(condition: &Self, on_true: &Self, on_false: &Self) -> Result<Self>
pub fn select(condition: &Self, on_true: &Self, on_false: &Self) -> Result<Self>
Select values from on_true or on_false using condition.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let condition = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![false, true]).unwrap(), ctx.clone()).unwrap();
let on_true = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![10.0_f64, 20.0]).unwrap(), ctx.clone()).unwrap();
let on_false = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap(), ctx.clone()).unwrap();
let y = EagerTensor::select(&condition, &on_true, &on_false).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 20.0]);§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch when the three operands do not
broadcast, DTypeMismatch for incompatible value dtypes, or a typed
backend/runtime-state error.
Sourcepub fn where_select(
condition: &Self,
on_true: &Self,
on_false: &Self,
) -> Result<Self>
pub fn where_select( condition: &Self, on_true: &Self, on_false: &Self, ) -> Result<Self>
Select values from on_true or on_false using condition.
§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch when the three operands do not
broadcast, DTypeMismatch for incompatible value dtypes, or a typed
backend/runtime-state error.
Sourcepub fn clamp(&self, lower: &Self, upper: &Self) -> Result<Self>
pub fn clamp(&self, lower: &Self, upper: &Self) -> Result<Self>
Clamp values elementwise between lower and upper bounds.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![-2.0_f64, 0.5, 5.0]).unwrap(), ctx.clone()).unwrap();
let lower = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![-1.0_f64, 0.0, 1.0]).unwrap(), ctx.clone()).unwrap();
let upper = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 4.0]).unwrap(), ctx.clone()).unwrap();
let y = x.clamp(&lower, &upper).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[-1.0, 0.5, 4.0]);§Errors
Returns crate::error::Error::ContextMismatch for different eager runtimes,
tenferro_tensor::ValidationError::ShapeMismatch when the three operands do not
broadcast, DTypeMismatch for incompatible bounds, or a typed
unsupported/backend/runtime-state error.
Source§impl EagerTensor
impl EagerTensor
Sourcepub fn slice_axis(&self, axis: usize, range: Range<usize>) -> Result<Self>
pub fn slice_axis(&self, axis: usize, range: Range<usize>) -> Result<Self>
Slice one axis with an exclusive-end range, keeping all other axes.
§Examples
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::new()?;
let x = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![4], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(),
ctx,
).unwrap();
let y = x.slice_axis(0, 1..3).unwrap();
assert_eq!(y.shape(), &[2]);§Errors
Returns tenferro_tensor::ValidationError::AxisOutOfBounds when axis is not
present, InvalidArgument when range exceeds the axis extent, or a
typed backend/runtime-state error.
Sourcepub fn slice_builder(&self) -> EagerSliceBuilder<'_>
pub fn slice_builder(&self) -> EagerSliceBuilder<'_>
Start a rank-preserving slicing builder for this tensor.
§Examples
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::new()?;
let x = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![3], vec![1.0_f64, 2.0, 3.0]).unwrap(),
ctx,
).unwrap();
let y = x.slice_builder().axis(0, 0..2).apply().unwrap();
assert_eq!(y.shape(), &[2]);Sourcepub fn take_axis(&self, axis: usize, indices: &[usize]) -> Result<Self>
pub fn take_axis(&self, axis: usize, indices: &[usize]) -> Result<Self>
Select entries from one axis using host-known indices.
The index list is primal metadata: gradients flow to self, including
accumulation for repeated indices, but not to the selected positions.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![3], vec![10.0_f64, 20.0, 30.0]).unwrap(),
ctx,
).unwrap();
let y = x.take_axis(0, &[2, 0]).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[30.0, 10.0]);§Errors
Returns tenferro_tensor::ValidationError::AxisOutOfBounds for an invalid axis,
InvalidArgument when an index is outside the axis extent or cannot fit
in the backend index dtype, or a typed backend/runtime-state error.
Sourcepub fn take_rows(&self, rows: &[usize]) -> Result<Self>
pub fn take_rows(&self, rows: &[usize]) -> Result<Self>
Select matrix rows using host-known row indices.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(),
ctx,
).unwrap();
let y = x.take_rows(&[1]).unwrap();
assert_eq!(y.shape(), &[1, 2]);
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[2.0, 4.0]);§Errors
Returns tenferro_tensor::ValidationError::InvalidArgument for a row index
outside the matrix, or Error::Validation for a non-matrix input;
backend/runtime-state failures retain their typed source.
Sourcepub fn take_cols(&self, cols: &[usize]) -> Result<Self>
pub fn take_cols(&self, cols: &[usize]) -> Result<Self>
Select matrix columns using host-known column indices.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(),
ctx,
).unwrap();
let y = x.take_cols(&[1]).unwrap();
assert_eq!(y.shape(), &[2, 1]);
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[3.0, 4.0]);§Errors
Returns tenferro_tensor::ValidationError::InvalidArgument for a column index
outside the matrix, or Error::Validation for a non-matrix input;
backend/runtime-state failures retain their typed source.
Sourcepub fn take_block(&self, rows: &[usize], cols: &[usize]) -> Result<Self>
pub fn take_block(&self, rows: &[usize], cols: &[usize]) -> Result<Self>
Select a matrix block using host-known row and column indices.
This is a convenience wrapper over row selection followed by column selection. The row and column lists, plus the approximation rank implied by their lengths, are fixed primal metadata.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap(),
ctx,
).unwrap();
let y = x.take_block(&[1], &[0]).unwrap();
assert_eq!(y.shape(), &[1, 1]);
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[2.0]);§Errors
Propagates tenferro_tensor::ValidationError::InvalidArgument for an out of
bounds row or column and Error::Validation for a non-matrix input;
backend/runtime-state failures retain their typed source.
Sourcepub fn index_select(&self, axis: isize, positions: &[usize]) -> Result<Self>
pub fn index_select(&self, axis: isize, positions: &[usize]) -> Result<Self>
Select entries from one axis using host-known positions.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let x = EagerTensor::from_tensor_in(
Tensor::from_vec_col_major(vec![3], vec![10.0_f64, 20.0, 30.0]).unwrap(),
ctx,
).unwrap();
let y = x.index_select(-1, &[2, 0]).unwrap();
assert_eq!(y.materialized().unwrap().as_slice::<f64>().unwrap(), &[30.0, 10.0]);§Errors
Returns tenferro_tensor::ValidationError::AxisOutOfBounds for an invalid
signed axis, InvalidArgument for an out-of-range position or integer
conversion overflow, or a typed backend/runtime-state error.
Sourcepub fn stack(tensors: &[&Self], dim: isize) -> Result<Self>
pub fn stack(tensors: &[&Self], dim: isize) -> Result<Self>
Stack tensors along a newly inserted axis.
The returned tensor uses the context of the first input, matching
Self::concatenate. All inputs must belong to that same context.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_ad::{EagerRuntime, EagerTensor, Tensor};
let ctx = EagerRuntime::with_cpu_backend(CpuBackend::new())?;
let a = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![], vec![1.0_f64]).unwrap(), ctx.clone()).unwrap();
let b = EagerTensor::from_tensor_in(Tensor::from_vec_col_major(vec![], vec![2.0_f64]).unwrap(), ctx).unwrap();
let out = EagerTensor::stack(&[&a, &b], -1).unwrap();
assert_eq!(out.shape(), &[2]);
assert_eq!(out.materialized().unwrap().as_slice::<f64>().unwrap(), &[1.0, 2.0]);§Errors
Returns tenferro_tensor::ValidationError::InvalidArgument when tensors is
empty or dim is outside the insertion rank, ShapeMismatch when
inputs differ in shape, or a typed context/backend/runtime-state error.
Trait Implementations§
Source§impl Add for &EagerTensor
impl Add for &EagerTensor
Source§fn add(self, rhs: &EagerTensor) -> Result<EagerTensor>
fn add(self, rhs: &EagerTensor) -> Result<EagerTensor>
+ operation. Read moreSource§impl Clone for EagerTensor
impl Clone for EagerTensor
Source§fn clone(&self) -> EagerTensor
fn clone(&self) -> EagerTensor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EagerTensor
impl Debug for EagerTensor
Source§impl Div for &EagerTensor
impl Div for &EagerTensor
Source§fn div(self, rhs: &EagerTensor) -> Result<EagerTensor>
fn div(self, rhs: &EagerTensor) -> Result<EagerTensor>
/ operation. Read moreSource§impl Mul for &EagerTensor
impl Mul for &EagerTensor
Source§fn mul(self, rhs: &EagerTensor) -> Result<EagerTensor>
fn mul(self, rhs: &EagerTensor) -> Result<EagerTensor>
* operation. Read moreSource§impl Neg for &EagerTensor
impl Neg for &EagerTensor
Source§impl Rem for &EagerTensor
impl Rem for &EagerTensor
Source§fn rem(self, rhs: &EagerTensor) -> Result<EagerTensor>
fn rem(self, rhs: &EagerTensor) -> Result<EagerTensor>
% operation. Read moreSource§impl Sub for &EagerTensor
impl Sub for &EagerTensor
Source§fn sub(self, rhs: &EagerTensor) -> Result<EagerTensor>
fn sub(self, rhs: &EagerTensor) -> Result<EagerTensor>
- operation. Read moreAuto Trait Implementations§
impl Freeze for EagerTensor
impl !RefUnwindSafe for EagerTensor
impl Send for EagerTensor
impl Sync for EagerTensor
impl Unpin for EagerTensor
impl UnsafeUnpin for EagerTensor
impl !UnwindSafe for EagerTensor
Blanket Implementations§
§impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
type Output = Output
fn add_by_ref(&self, rhs: &Rhs) -> <Lhs as AddByRef<Rhs>>::Output
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
type Output = Output
fn div_by_ref(&self, rhs: &Rhs) -> <Lhs as DivByRef<Rhs>>::Output
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more