Skip to main content

CpuEngine

Struct CpuEngine 

pub struct CpuEngine { /* private fields */ }
Expand description

A caller-held CPU execution engine.

The engine owns one [threadteam::Pool] (or none for CpuEngine::serial) and the workspace operations write: the buffer pool that recycles outputs, the contraction scratch, and a handle to a [CpuPlanCache]. It implements [tenferro_tensor::Engine], so every operation takes it as &mut.

§Examples

use tenferro_cpu::CpuEngine;
use tenferro_tensor::{Tensor, TensorElementwise, TensorRead};

let mut engine = CpuEngine::serial();
let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
let b = Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0])?;
let c = engine.add_read(TensorRead::from_tensor(&a), TensorRead::from_tensor(&b))?;
assert_eq!(c.as_slice::<f64>()?, &[4.0, 6.0]);

Implementations§

§

impl CpuEngine

pub fn new(pool: Pool) -> CpuEngine

An engine that computes on pool, which it takes over.

Every operation may use all workers of the pool; a caller that wants fewer threads builds a smaller pool. Pool::builder reserves the worker stack the providers need by default.

§Examples
let pool = tenferro_cpu::Pool::builder().threads(4).build()?;
let engine = tenferro_cpu::CpuEngine::new(pool);
assert_eq!(engine.num_threads(), 4);

pub fn serial() -> CpuEngine

An engine with no pool: every operation runs on the calling thread.

A serial engine never starts or enters a pool, so it is safe to use from inside any other pool.

§Examples
let engine = tenferro_cpu::CpuEngine::serial();
assert_eq!(engine.num_threads(), 1);

pub fn with_plan_cache(self, plans: CpuPlanCache) -> CpuEngine

Use plans as this engine’s plan cache, shared with every other engine that holds a clone of it.

§Examples
use tenferro_cpu::{CpuEngine, CpuPlanCache};

let plans = CpuPlanCache::new();
let engine = CpuEngine::serial().with_plan_cache(plans.clone());
assert!(engine.plan_cache().shares_with(&plans));

pub fn plan_cache(&self) -> &CpuPlanCache

The plan cache this engine reads plans from.

§Examples
let engine = tenferro_cpu::CpuEngine::serial();
assert_eq!(engine.plan_cache().stats().entries, 0);

pub fn with_runtime_engine_id(self, id: EngineId) -> CpuEngine

Run prepared programs under a runtime engine id other than the default [crate::runtime_engine_id]; it must match the id this engine kind was registered under.

§Examples
use tenferro_runtime::EngineId;
let id = EngineId::new("example.cpu.v1")?;
let engine = tenferro_cpu::CpuEngine::serial().with_runtime_engine_id(id.clone());
assert_eq!(tenferro_runtime::ExecutionEngine::target(&engine).engine_id(), &id);

pub fn with_allocation_domain( self, domain: Arc<dyn SharedTensorAllocationDomain>, ) -> CpuEngine

Bind outputs and managed inputs to a shared allocation domain.

§Examples
let engine = tenferro_cpu::CpuEngine::serial();
assert!(engine.allocation_domain().is_none());

pub fn allocation_domain(&self) -> Option<AllocationDomainId>

The shared allocation domain this engine is bound to, if any.

§Examples
assert_eq!(tenferro_cpu::CpuEngine::serial().allocation_domain(), None);

pub fn shared_allocation_domain( &self, ) -> Option<&Arc<dyn SharedTensorAllocationDomain>>

The shared allocator this engine is bound to, if any.

§Examples
assert!(tenferro_cpu::CpuEngine::serial().shared_allocation_domain().is_none());

pub fn with_batch_policy(self, policy: BatchPolicy) -> CpuEngine

This engine with a different default batch policy.

§Examples
use tenferro_cpu::{CpuBatchPolicy, CpuBatchStrategy, CpuEngine};

let engine = CpuEngine::serial()
    .with_batch_policy(CpuBatchPolicy::new(CpuBatchStrategy::Sequential));
assert_eq!(engine.batch_policy().strategy, CpuBatchStrategy::Sequential);

pub fn set_batch_policy(&mut self, policy: BatchPolicy) -> BatchPolicy

Replace the default batch policy, returning the previous one.

For a one-operation override use [crate::with_batch_policy].

§Examples
use tenferro_cpu::{CpuBatchPolicy, CpuBatchStrategy, CpuEngine};

let mut engine = CpuEngine::serial();
let previous = engine.set_batch_policy(CpuBatchPolicy::new(CpuBatchStrategy::Outer));
assert_eq!(previous.strategy, CpuBatchStrategy::Auto);

pub fn batch_policy(&self) -> BatchPolicy

The default batch policy of this engine.

§Examples
use tenferro_cpu::{CpuBatchStrategy, CpuEngine};
assert_eq!(CpuEngine::serial().batch_policy().strategy, CpuBatchStrategy::Auto);

pub fn num_threads(&self) -> usize

The number of workers operations may use: the pool size, or one.

§Examples
assert_eq!(tenferro_cpu::CpuEngine::serial().num_threads(), 1);

pub fn has_team(&self) -> bool

Whether the engine runs its parallel work on a reserved threadteam::Team.

true for an engine built from a pool of two or more workers whose members were reserved. false for CpuEngine::serial, for a one-worker pool, and for a pool whose members could not be reserved within about ten seconds of construction (the engine then runs serially and CpuEngine::num_threads reports one). Benchmarks should assert this after construction.

§Examples
assert!(!tenferro_cpu::CpuEngine::serial().has_team());
let pool = tenferro_cpu::Pool::builder().threads(2).build()?;
assert!(tenferro_cpu::CpuEngine::new(pool).has_team());

pub fn is_broken(&self) -> bool

Whether an earlier operation broke this engine (see [CpuEngineError::Broken]).

§Examples
assert!(!tenferro_cpu::CpuEngine::serial().is_broken());

pub fn exec(&mut self) -> Result<Exec<'_>, Error>

The provider execution bundle for this engine: a placement token over every worker of its pool, its workspace and its batch policy.

A downstream kernel that calls a provider (cpueinsum, tcontract, tlinalg) directly passes this bundle by &mut, so it uses the same threads, budget and batch policy as tenferro. The bundle is not Clone: it is the engine’s whole thread budget for that one call, and the provider splits it. Getting it applies the same checks as an operation.

§Errors

Returns [crate::Error::RuntimeState] with a [CpuEngineError] source when the engine is broken.

§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
let exec = engine.exec()?;
assert_eq!(exec.budget(), 1);

pub fn with_exec<R>( &mut self, op: impl FnOnce(&mut Exec<'_>) -> R, ) -> Result<R, Error>

Run op on the engine’s provider bundle, keeping the engine’s guarantees.

op receives the same bundle an operation mints (a placement token over every worker of the pool, the workspace and the batch policy; see CpuEngine::exec) and runs on the calling thread. Unlike CpuEngine::exec, the call is an engine operation: a panic inside op marks the engine broken, and contraction scratch retained above CpuEngine::buffer_pool_limit_bytes is released when op returns.

The bundle is borrowed for the call only, and the engine stays mutably borrowed while op runs, so neither can be stored or re-entered from inside op; the compiler rejects both:

ⓘ
let mut engine = tenferro_cpu::CpuEngine::serial();
let engine_ref = &mut engine;
engine_ref.with_exec(|_| engine_ref.with_exec(|exec| exec.budget()))?;
ⓘ
let mut engine = tenferro_cpu::CpuEngine::serial();
let mut kept = None;
engine.with_exec(|exec| kept = Some(exec))?;
§Errors

Returns [crate::Error::RuntimeState] with a [CpuEngineError::Broken] source, without calling op, when an earlier operation panicked.

§Panics

Resumes a panic raised by op after marking the engine broken.

§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
let budget = engine.with_exec(|exec| exec.budget())?;
assert_eq!(budget, 1);

A panic inside op breaks the engine, and a broken engine refuses later calls with an error:

use tenferro_cpu::{CpuEngine, CpuEngineError};

let mut engine = CpuEngine::serial();
let unwind = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
    engine.with_exec(|_| panic!("a failing block"))
}));
assert!(unwind.is_err());
assert!(engine.is_broken());

let refused = engine.with_exec(|exec| exec.budget()).unwrap_err();
let source = std::error::Error::source(&refused).and_then(|s| s.downcast_ref());
assert_eq!(source, Some(&CpuEngineError::Broken));

pub fn buffer_pool_len(&self) -> usize

Number of retained buffers in the engine’s buffer pool.

§Examples
assert_eq!(tenferro_cpu::CpuEngine::serial().buffer_pool_len(), 0);

pub fn buffer_pool_stats(&self) -> BufferPoolStats

Retained-buffer statistics of the engine’s buffer pool.

§Examples
assert_eq!(tenferro_cpu::CpuEngine::serial().buffer_pool_stats().buffers, 0);

pub fn buffer_pool_cache_stats(&self) -> CacheStats

The buffer pool as cache statistics (entries and retained bytes).

§Examples
assert_eq!(tenferro_cpu::CpuEngine::serial().buffer_pool_cache_stats().entries, 0);

pub fn buffer_pool_limit_bytes(&self) -> usize

The retention limit of recycled buffers, in retained capacity bytes.

§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
engine.set_buffer_pool_limit_bytes(0);
assert_eq!(engine.buffer_pool_limit_bytes(), 0);

pub fn set_buffer_pool_limit_bytes( &mut self, max_retained_capacity_bytes: usize, )

Bound the bytes of recycled buffers and contraction scratch retained between operations; zero disables retention.

Destinations larger than the retention limit cannot be recycled, so repeated calls allocate again and may pay first-touch costs. The default is 100 MiB; raise it when a run keeps producing outputs above that size.

§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
engine.set_buffer_pool_limit_bytes(1 << 20);
assert_eq!(engine.buffer_pool_limit_bytes(), 1 << 20);

pub fn reset_buffer_pool(&mut self)

Drop every retained buffer and contraction scratch.

§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
engine.reset_buffer_pool();
assert_eq!(engine.buffer_pool_len(), 0);

Trait Implementations§

§

impl Debug for CpuEngine

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Engine for CpuEngine

§

fn gather_read( &mut self, operand: TensorRead<'_>, start_indices: TensorRead<'_>, config: &GatherConfig, ) -> Result<Tensor, Error>

Gather with both operands taken as reads. Read more
§

fn vdot_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Compute the all-axis conjugating dot product without transferring either input. Read more
§

fn norm_squared_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Compute the all-axis sum of squared magnitudes without taking a square root. Read more
§

fn fused_activation_read( &mut self, op: ActivationOp, input: TensorRead<'_>, ) -> Result<Option<Tensor>, Error>

Compute a fused activation in one pass, or decline with Ok(None). Read more
§

fn softmax_read( &mut self, input: TensorRead<'_>, axis: usize, ) -> Result<Option<Tensor>, Error>

Fused real-float softmax along axis. Read more
§

fn axpby_read_into_accum( &mut self, alpha: ContractionScalar, x: TensorRead<'_>, beta: ContractionScalar, y: TensorWrite<'_>, ) -> Result<(), Error>

Apply y <- alpha * x + beta * y in one pass into caller-owned storage. Read more
§

fn native_engine(&mut self) -> Option<NativeSessionRef<'_>>

Return this engine’s backend-leaf native capability, if it has one. Read more
§

impl ExecutionEngine for CpuEngine

§

fn target(&self) -> EngineTarget

Immutable description used by [crate::Runtime::prepare].
§

fn take_extension_caches(&mut self) -> ExtensionCacheStore

Move this engine’s extension caches out for the duration of one run. Read more
§

fn restore_extension_caches(&mut self, caches: ExtensionCacheStore)

Return the extension caches taken by [Self::take_extension_caches].
§

fn mark_broken(&mut self)

Record that an extension callback panicked while the runtime had lent this engine’s extension caches to it. Read more
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Typed access for prepared operations that execute against the concrete engine type instead of the [Engine] operations.
§

fn event_domain_driver(&self) -> Arc<dyn EventDomainDriver> ⓘ

The driver that opens this engine’s event-domain runs. Read more
§

fn retire_run(&mut self, run: Box<dyn EventDomainRun>) -> Result<(), Error>

Take ownership of an event-domain run whose launches may still be running. Read more
§

fn synchronize(&mut self) -> Result<(), Error>

Block until the work this engine queued has completed. Read more
Source§

impl From<CpuEngine> for CpuBackend

Source§

fn from(engine: CpuEngine) -> Self

Converts to this type from the input type.
§

impl LinalgBackend for CpuEngine

§

fn cholesky(&mut self, input: &Tensor) -> Result<Tensor, Error>

Compute a Cholesky factorization. Read more
§

fn triangular_solve( &mut self, a: &Tensor, b: &Tensor, left_side: bool, lower: bool, transpose_a: bool, unit_diagonal: bool, ) -> Result<Tensor, Error>

Solve a triangular linear system with explicit side, triangle, transpose, and unit-diagonal flags. Read more
§

fn triangular_solve_read( &mut self, a: TensorRead<'_>, b: TensorRead<'_>, left_side: bool, lower: bool, transpose_a: bool, unit_diagonal: bool, ) -> Result<Tensor, Error>

Solve a triangular linear system from tensor read targets. Read more
§

fn lu(&mut self, input: &Tensor) -> Result<Vec<Tensor>, Error>

Compute public LU outputs (P, L, U, parity). Read more
§

fn full_piv_lu(&mut self, input: &Tensor) -> Result<Vec<Tensor>, Error>

Compute complete-pivot LU outputs (P, L, U, Q, parity). Read more
§

fn full_piv_lu_solve( &mut self, a: &Tensor, b: &Tensor, transpose_a: bool, ) -> Result<Tensor, Error>

Solve a linear system through the complete-pivot LU path. Read more
§

fn svd(&mut self, input: &Tensor) -> Result<Vec<Tensor>, Error>

Compute public SVD outputs (U, S, Vt). Read more
§

fn svd_full(&mut self, input: &Tensor) -> Result<Vec<Tensor>, Error>

Compute public full-matrices SVD outputs (U, S, Vt) with U shaped m x m and Vt shaped n x n, so the trailing Vt rows span the input’s right nullspace. Read more
§

fn svd_full_read(&mut self, input: TensorRead<'_>) -> Result<Vec<Tensor>, Error>

Compute full-matrices SVD outputs (U, S, Vt) from a tensor read target. Read more
§

fn svd_read(&mut self, input: TensorRead<'_>) -> Result<Vec<Tensor>, Error>

Compute a singular value decomposition from a tensor read target. Read more
§

fn qr(&mut self, input: &Tensor) -> Result<Vec<Tensor>, Error>

Compute public QR outputs (Q, R). Read more
§

fn qr_read(&mut self, input: TensorRead<'_>) -> Result<Vec<Tensor>, Error>

Compute public QR outputs (Q, R) from a tensor read target. Read more
§

fn eigh(&mut self, input: &Tensor) -> Result<Vec<Tensor>, Error>

Compute public Hermitian eigendecomposition outputs (values, vectors). Read more
§

fn eigh_read(&mut self, input: TensorRead<'_>) -> Result<Vec<Tensor>, Error>

Compute public Hermitian eigendecomposition outputs from a tensor read target. Read more
§

fn cholesky_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Compute Cholesky factorization from a tensor read target. Read more
§

fn lu_read(&mut self, input: TensorRead<'_>) -> Result<Vec<Tensor>, Error>

Compute public LU outputs from a tensor read target. Read more
§

fn full_piv_lu_read( &mut self, input: TensorRead<'_>, ) -> Result<Vec<Tensor>, Error>

Compute public full-pivoting LU outputs from a tensor read target. Read more
§

fn eig_read(&mut self, input: TensorRead<'_>) -> Result<Vec<Tensor>, Error>

Compute general eigendecomposition outputs from a tensor read target. Read more
§

fn eig(&mut self, input: &Tensor) -> Result<Vec<Tensor>, Error>

Compute public general eigendecomposition outputs (values, vectors). Eigenvectors come back with unit 2-norm columns, whichever provider computed them; a column the provider left non-finite is reported as a numerical failure instead of being returned as NaN (#2148). Read more
§

fn solve(&mut self, a: &Tensor, b: &Tensor) -> Result<Tensor, Error>

Solve a dense linear system. Read more
§

fn solve_read( &mut self, a: TensorRead<'_>, b: TensorRead<'_>, ) -> Result<Tensor, Error>

Solve a linear system from tensor read targets. Read more
§

fn solve_read_into( &mut self, a: TensorRead<'_>, b: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>

Solve into a caller-owned destination. Read more
§

fn svd_with_options( &mut self, input: &Tensor, options: SvdOptions, ) -> Result<Vec<Tensor>, Error>

Compute public SVD outputs (U, S, Vt) with explicit options. Read more
§

fn svd_with_options_read( &mut self, input: TensorRead<'_>, options: SvdOptions, ) -> Result<Vec<Tensor>, Error>

Compute public SVD outputs (U, S, Vt) from a tensor read target with explicit options. Read more
§

fn qr_with_options( &mut self, input: &Tensor, options: QrOptions, ) -> Result<Vec<Tensor>, Error>

Compute public QR outputs (Q, R) with explicit options. Read more
§

fn qr_with_options_read( &mut self, input: TensorRead<'_>, options: QrOptions, ) -> Result<Vec<Tensor>, Error>

Compute public QR outputs (Q, R) from a tensor read target with options. Read more
§

fn eigh_with_options( &mut self, input: &Tensor, options: EighOptions, ) -> Result<Vec<Tensor>, Error>

Compute public Hermitian eigendecomposition outputs with explicit options. Read more
§

fn eigh_with_options_read( &mut self, input: TensorRead<'_>, options: EighOptions, ) -> Result<Vec<Tensor>, Error>

Compute public eigh outputs (values, vectors) from a tensor read target with explicit options. Read more
§

impl SessionCachedDot for CpuEngine

§

fn dot_general_read_into_accum_cached( &mut self, cache_slot: Option<usize>, lhs: TensorRead<'_>, rhs: TensorRead<'_>, config: &DotGeneralConfig, accumulation: DotGeneralAccumulation, out: TensorWrite<'_>, ) -> Result<(), Error>

Apply session-cached scaled dot-general accumulation into output. Read more
§

impl TensorAnalytic for CpuEngine

§

fn exp_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn log_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn sin_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn cos_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn tanh_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn sqrt_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn rsqrt_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn pow_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Examples Read more
§

fn expm1_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn log1p_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn erf_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Elementwise error function erf(x) = 2/sqrt(pi) * integral_0^x exp(-t^2) dt. Read more
§

impl TensorBackendCapability for CpuEngine

§

fn backend_id(&self) -> BackendId

§

fn capabilities(&self) -> &'static [OperationCapability]

§

fn capability(&self, query: CapabilityQuery) -> Option<OperationCapability>

Look up one operation/dtype capability for this backend. Read more
§

fn require_capability( &self, query: CapabilityQuery, axis: CapabilityAxis, ) -> Result<OperationCapability, Error>

Require support for one operation/dtype/axis, returning a structured unsupported error otherwise. Read more
§

impl TensorBuffer for CpuEngine

§

fn reclaim_buffer(&mut self, tensor: Tensor)

§

impl TensorDeviceTransfer for CpuEngine

§

fn download_to_host(&mut self, tensor: TensorRead<'_>) -> Result<Tensor, Error>

Explicitly copy a provider-owned read target into host storage. Read more
§

fn upload_host_tensor( &mut self, tensor: TensorRead<'_>, ) -> Result<Tensor, Error>

Explicitly copy a host read target into provider storage. Read more
§

impl TensorDot for CpuEngine

The engine’s GEMM entries, and on a blas build the only GEMM entries.

On the native provider these run on the engine’s pool within its budget. A caller that wants independent GEMMs on lanes of one context forks the bundle that CpuEngine::with_exec lends and runs a cpueinsum plan per lane; that per-context entry exists only on the native provider.

On the blas provider a call takes the whole engine and the vendor library’s own threads: the context budget is not honoured by that provider, because the vendor step ignores the placement token and sizes itself from the library’s process-wide thread setting (OPENBLAS_NUM_THREADS, MKL_NUM_THREADS, VECLIB_MAXIMUM_THREADS). Lanes must not call into the vendor provider concurrently unless the linked library is known to tolerate it; two lanes asking for different widths cannot both be honoured by one global setting. tenferro does not offer a wrapper that sets that global per lane to simulate per-lane widths, because it would hide who owns the setting instead of answering it. See the “Lanes and the vendor provider” section of docs/guides/cpu-execution.md.

§Examples

use tenferro_cpu::CpuEngine;
use tenferro_tensor::{DotGeneralConfig, Tensor, TensorDot, TensorRead};

let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 3.0, 2.0, 4.0])?;
let identity = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 0.0, 0.0, 1.0])?;
let config = DotGeneralConfig {
    lhs_contracting_dims: [1].as_slice().into(),
    rhs_contracting_dims: [0].as_slice().into(),
    lhs_batch_dims: [].as_slice().into(),
    rhs_batch_dims: [].as_slice().into(),
};
let mut engine = CpuEngine::serial();
let product = engine.dot_general_read(
    TensorRead::from_tensor(&a),
    TensorRead::from_tensor(&identity),
    &config,
)?;
assert_eq!(product.as_slice::<f64>()?, &[1.0, 3.0, 2.0, 4.0]);
§

fn dot_general_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, config: &DotGeneralConfig, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with dot-general from read inputs. Read more
§

fn dot_general_read_into_accum( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, config: &DotGeneralConfig, accumulation: DotGeneralAccumulation, out: TensorWrite<'_>, ) -> Result<(), Error>

Apply scaled dot-general accumulation into caller-provided output. Read more
§

impl TensorElementwise for CpuEngine

§

fn elementwise_read_into( &mut self, op: ElementwiseReadOp, inputs: &[TensorRead<'_>], out: TensorWrite<'_>, ) -> Result<(), Error>

Execute an elementwise operation into caller-owned storage. Read more
§

fn add_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Elementwise addition accepting either owned tensors or borrowed views. Read more
§

fn sub_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Elementwise subtraction accepting either owned tensors or borrowed views. Read more
§

fn mul_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Examples Read more
§

fn neg_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn conj_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn div_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Examples Read more
§

fn rem(&mut self, lhs: &Tensor, rhs: &Tensor) -> Result<Tensor, Error>

Elementwise remainder. Read more
§

fn rem_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Elementwise remainder accepting owned tensors or borrowed views. Read more
§

fn abs_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn sign_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Examples Read more
§

fn maximum_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Examples Read more
§

fn minimum_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor, Error>

Examples Read more
§

fn compare_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, dir: &CompareDir, ) -> Result<Tensor, Error>

Errors Read more
§

fn select_read( &mut self, pred: TensorRead<'_>, on_true: TensorRead<'_>, on_false: TensorRead<'_>, ) -> Result<Tensor, Error>

Errors Read more
§

fn clamp_read( &mut self, input: TensorRead<'_>, lower: TensorRead<'_>, upper: TensorRead<'_>, ) -> Result<Tensor, Error>

Errors Read more
§

fn add_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise addition. Read more
§

fn add_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise addition from reads. Read more
§

fn sub_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise subtraction. Read more
§

fn sub_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise subtraction from reads. Read more
§

fn mul_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise multiplication. Read more
§

fn mul_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise multiplication from reads. Read more
§

fn neg_into( &mut self, input: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise negation. Read more
§

fn neg_read_into( &mut self, input: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise negation from a read. Read more
§

fn conj_into( &mut self, input: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise conjugation. Read more
§

fn conj_read_into( &mut self, input: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise conjugation from a read. Read more
§

fn div_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise division. Read more
§

fn div_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided output with elementwise division from reads. Read more
§

impl TensorFusion for CpuEngine

§

impl TensorIndexing for CpuEngine

§

fn gather( &mut self, operand: &Tensor, start_indices: &Tensor, config: &GatherConfig, ) -> Result<Tensor, Error>

Errors Read more
§

fn scatter( &mut self, operand: &Tensor, indices: &Tensor, updates: &Tensor, config: &ScatterConfig, ) -> Result<Tensor, Error>

Errors Read more
§

fn dynamic_update_slice_read( &mut self, operand: TensorRead<'_>, update: TensorRead<'_>, starts: TensorRead<'_>, ) -> Result<Tensor, Error>

Dynamic-update-slice with every input taken as a read. Read more
§

fn scatter_read( &mut self, operand: TensorRead<'_>, indices: TensorRead<'_>, updates: TensorRead<'_>, config: &ScatterConfig, ) -> Result<Tensor, Error>

Scatter with every input taken as a read. Read more
§

fn slice( &mut self, input: &Tensor, config: &SliceConfig, ) -> Result<Tensor, Error>

Errors Read more
§

fn slice_read( &mut self, input: TensorRead<'_>, config: &SliceConfig, ) -> Result<Tensor, Error>

Slice with the input taken as a read. Read more
§

fn dynamic_slice_read( &mut self, input: TensorRead<'_>, starts: TensorRead<'_>, slice_sizes: &[usize], ) -> Result<Tensor, Error>

Dynamic slice with every input taken as a read. Read more
§

fn dynamic_slice( &mut self, input: &Tensor, starts: &Tensor, slice_sizes: &[usize], ) -> Result<Tensor, Error>

Errors Read more
§

fn dynamic_update_slice( &mut self, operand: &Tensor, update: &Tensor, starts: &Tensor, ) -> Result<Tensor, Error>

Errors Read more
§

fn pad(&mut self, input: &Tensor, config: &PadConfig) -> Result<Tensor, Error>

Errors Read more
§

fn pad_read( &mut self, input: TensorRead<'_>, config: &PadConfig, ) -> Result<Tensor, Error>

Pad with the input taken as a read. Read more
§

fn concatenate( &mut self, inputs: &[&Tensor], axis: usize, ) -> Result<Tensor, Error>

Errors Read more
§

fn concatenate_read( &mut self, inputs: &[TensorRead<'_>], axis: usize, ) -> Result<Tensor, Error>

Concatenate with every input taken as a read. Read more
§

fn reverse(&mut self, input: &Tensor, axes: &[usize]) -> Result<Tensor, Error>

Errors Read more
§

fn reverse_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor, Error>

Reverse with the input taken as a read. Read more
§

impl TensorReduction for CpuEngine

§

fn reduce_sum_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor, Error>

Sum elements across axes from an owned tensor or borrowed view. Read more
§

fn reduce_prod_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor, Error>

Multiply elements across axes from an owned tensor or borrowed view. Read more
§

fn reduce_max_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor, Error>

Take maximum values across axes from an owned tensor or borrowed view. Read more
§

fn reduce_min_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor, Error>

Take minimum values across axes from an owned tensor or borrowed view. Read more
§

impl TensorStructural for CpuEngine

§

fn to_contiguous_read(&mut self, input: TensorRead<'_>) -> Result<Tensor, Error>

Materialize an owned tensor or borrowed view into fresh compact storage. Read more
§

fn copy_read_into( &mut self, src: TensorRead<'_>, dst: TensorWrite<'_>, ) -> Result<(), Error>

Overwrite caller-provided storage from a readable tensor or view. Read more
§

fn transpose_read( &mut self, input: TensorRead<'_>, perm: &[usize], ) -> Result<Tensor, Error>

Examples Read more
§

fn reshape_read( &mut self, input: TensorRead<'_>, shape: &[usize], ) -> Result<Tensor, Error>

Examples Read more
§

fn broadcast_in_dim_read( &mut self, input: TensorRead<'_>, shape: &[usize], dims: &[usize], ) -> Result<Tensor, Error>

Errors Read more
§

fn tril_read(&mut self, input: TensorRead<'_>, k: i64) -> Result<Tensor, Error>

Lower-triangular mask with the input taken as a read. Read more
§

fn triu_read(&mut self, input: TensorRead<'_>, k: i64) -> Result<Tensor, Error>

Upper-triangular mask with the input taken as a read. Read more
§

fn extract_diagonal_read( &mut self, input: TensorRead<'_>, axis_a: usize, axis_b: usize, ) -> Result<Tensor, Error>

Extract the diagonal with the input taken as a read. Read more
§

fn embed_diagonal_read( &mut self, input: TensorRead<'_>, axis_a: usize, axis_b: usize, ) -> Result<Tensor, Error>

Embed the input as a diagonal with the input taken as a read. Read more
§

fn cast(&mut self, input: &Tensor, to: DType) -> Result<Tensor, Error>

Cast a tensor to another dtype using explicit dtype projection. Read more
§

fn extract_diagonal( &mut self, input: &Tensor, axis_a: usize, axis_b: usize, ) -> Result<Tensor, Error>

Errors Read more
§

fn embed_diagonal( &mut self, input: &Tensor, axis_a: usize, axis_b: usize, ) -> Result<Tensor, Error>

Errors Read more
§

fn tril(&mut self, input: &Tensor, k: i64) -> Result<Tensor, Error>

Errors Read more
§

fn triu(&mut self, input: &Tensor, k: i64) -> Result<Tensor, Error>

Errors Read more
§

fn convert(&mut self, input: &Tensor, to: DType) -> Result<Tensor, Error>

Convert a tensor to another dtype using checked dtype conversion. Read more
§

impl<T, R> TensorViewCanonicalization<T, R> for CpuEngine
where T: TensorScalar + PoolScalar, R: TensorRank, <R as TensorRank>::Shape: Send + Sync, <R as TensorRank>::Strides: Send + Sync,

Typed view canonicalization runs on the engine.

§

fn to_contiguous( &mut self, view: &TypedTensorView<'_, T, R>, ) -> Result<TypedTensor<T, R>, Error>

Errors Read more
§

fn copy_into( &mut self, src: &TypedTensorView<'_, T, R>, dst: &mut TypedTensorViewMut<'_, T, R>, ) -> Result<(), Error>

Errors Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V