Expand description
CPU backend, kernels, provider selection, and CPU resource pools.
§Examples
use tenferro_cpu::CpuBackend;
use tenferro_tensor::{BackendSessionHost, Tensor, TensorRead};
let mut backend = CpuBackend::new();
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 = backend
.with_backend_session(|session| {
session.add_read(TensorRead::from_tensor(&a), TensorRead::from_tensor(&b))
})??;
assert_eq!(c.as_slice::<f64>().unwrap(), &[4.0, 6.0]);The deleted one-shot spellings do not compile on the owner or on a session. Each fixture below fails for that reason and nothing else.
ⓘ
use tenferro_cpu::CpuBackend;
use tenferro_tensor::Tensor;
let mut backend = CpuBackend::new();
let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
let b = Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap();
let _ = backend.add(&a, &b);ⓘ
use tenferro_cpu::CpuBackend;
use tenferro_tensor::Tensor;
let mut backend = CpuBackend::new();
let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
let b = Tensor::from_vec_col_major(vec![2], vec![3.0_f64, 4.0]).unwrap();
let _ = backend.mul(&a, &b);ⓘ
use tenferro_cpu::CpuBackend;
use tenferro_tensor::Tensor;
let mut backend = CpuBackend::new();
let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
let _ = backend.exp(&a);ⓘ
use tenferro_cpu::CpuBackend;
use tenferro_tensor::Tensor;
let mut backend = CpuBackend::new();
let a = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0]).unwrap();
let _ = backend.reduce_sum(&a, &[0]);ⓘ
use tenferro_cpu::CpuBackend;
use tenferro_tensor::Tensor;
let mut backend = CpuBackend::new();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap();
let _ = backend.transpose(&a, &[1, 0]);ⓘ
use tenferro_cpu::CpuBackend;
use tenferro_tensor::{DotGeneralConfig, Tensor};
let mut backend = CpuBackend::new();
let a = Tensor::from_vec_col_major(vec![2, 2], vec![1.0_f64, 2.0, 3.0, 4.0]).unwrap();
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 _ = backend.dot_general(&a, &a, &config);The owner no longer implements the cache-aware contraction entry, so an
owner-level BackendCachedDot bound does not hold either:
ⓘ
use tenferro_cpu::CpuBackend;
use tenferro_tensor::BackendCachedDot;
fn requires_cached_dot<B: BackendCachedDot>(_backend: &mut B) {}
let mut backend = CpuBackend::new();
requires_cached_dot(&mut backend);Re-exports§
pub use affinity::available_parallelism;pub use affinity::process_cpu_affinity;pub use affinity::process_cpu_affinity_count;pub use affinity::CpuAffinityError;pub use backend::CpuBackend;pub use backend::CpuBackendError;pub use backend::CpuBackendKind;pub use backend::CpuExecutionInfo;pub use backend::CpuExecutionMode;pub use backend::CpuRuntimeIdentity;pub use backend::ExternalCpuDomainRegistryError;pub use context::CpuContext;pub use context::CpuContextError;pub use context::DEFAULT_WORKER_STACK_BYTES;pub use provider::CpuExecutionContext;pub use provider::ParallelMode;
Modules§
Macros§
- same_
variant_ pair - Dispatch a same-variant pair of tensors to a typed kernel.
- same_
variant_ unary - Dispatch a single tensor to a typed kernel and erase its result.
Structs§
- AddOp
- Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Addition.
- Buffer
Pool Stats - Snapshot of typed host buffers retained by a
BufferPool. - CpuAffinity
Input - CPU affinity metadata for one logical operation input.
- CpuAffinity
Selection - Deterministic CPU affinity selection returned by the pure resolver.
- CpuBatch
Policy - A batch strategy together with the thresholds
Autouses. - CpuBatch
Thresholds - Thresholds that
CpuBatchStrategy::Autoapplies. - CpuDomain
Executor Capabilities - Immutable construction-time capabilities of a CPU domain executor.
- CpuId
- An operating-system logical CPU identifier.
- CpuNode
- One usable OS NUMA node and its process-allowed logical CPUs.
- CpuProvider
Bundle - Immutable direct provider slots installed on a CPU backend.
- CpuProvider
Bundle Build Error - Error returned when a custom CPU provider bundle omits mandatory slots.
- CpuProvider
Bundle Builder - Construction-time builder for immutable CPU provider slots.
- CpuProvider
Execution Capabilities - Immutable execution capabilities declared by one CPU provider.
- CpuSet
- A sorted, deduplicated, non-empty set of logical CPUs.
- CpuTopology
- Process-visible CPU topology used for execution placement.
- External
CpuDomain - Caller-supplied descriptor for one externally managed CPU resource domain.
- Indexed
Plan Cache Limits - Limits for the CPU indexed-plan cache.
- MulOp
- Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Multiplication.
- Numa
Node Id - An operating-system NUMA node identifier.
- Rayon
CpuDomain Executor - Adapter that executes CPU-domain jobs on one caller-owned Rayon pool.
- SubOp
- Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Subtraction.
Enums§
- CpuAdmission
Mode - Admission contract for one CPU resource domain.
- CpuAffinity
Input Error - Failure to derive logical input bytes for CPU affinity resolution.
- CpuAffinity
Policy - Policy used to select a CPU execution domain from input affinity metadata.
- CpuAffinity
Resolution Error - Failure to resolve CPU affinity from input metadata.
- CpuAffinity
Selection Reason - Why the CPU affinity resolver selected a domain.
- CpuBatch
Strategy - How the items of one batched operation are executed.
- CpuDomain
Executor Error - Failure at the CPU executor admission or scheduling boundary.
- CpuDomain
Ownership - Ownership class of a CPU resource domain.
- CpuEngine
Construction Error - Typed failure raised while constructing a CPU execution engine.
- CpuExecutor
Affinity - Affinity claim made by a CPU domain executor.
- CpuExecutor
Reentrancy - Re-entry capability of one CPU domain executor.
- CpuExecutor
Shutdown - Ownership of CPU executor shutdown.
- CpuInner
Parallelism - Inner parallel-region support offered by a CPU domain executor.
- CpuPlacement
- Requested CPU execution placement.
- CpuPlacement
Control - Per-call control over where a CPU provider executes.
- CpuPlacement
Error - Failure to resolve a CPU placement for the selected public provider kind.
- CpuProvider
Bundle Install Error - Failure to install a CPU provider bundle for the backend’s domains.
- CpuProvider
Domain Error - Typed incompatibility between a CPU provider and a selected CPU domain.
- CpuProvider
Slot - Provider slot that failed construction-time domain validation.
- CpuSet
Error - Failure to construct a non-empty CPU set.
- CpuThread
Count Control - Per-call control over the maximum number of threads used by a CPU provider.
- CpuThread
Execution - What CPU execution the current thread is inside.
- CpuTopology
Error - Failure to canonicalize discovered NUMA topology.
- External
CpuDomain Error - Typed failure to construct an externally managed CPU resource domain.
- General
Contraction Policy - Policy applied when the configured general-contraction provider reports a typed capability miss.
- Resolved
CpuPlacement - Concrete CPU placement resolved for a managed domain or declared by an external domain.
Traits§
- Binary
Scalar Op - Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. A binary operation between two scalars of the same type.
- CpuDomain
Executor - Object-safe synchronous executor for one CPU resource domain.
- Faer
Parallelism Ext - Invoke a direct faer operation with the parallelism selected by a CPU session.
- Scoped
CpuJob - One borrowed job installed synchronously into a CPU domain executor.
- Scoped
CpuJobs - Synchronously submitted indexed jobs for engine-owned outer scheduling.
Functions§
- cpu_
capabilities - Return the CPU backend operation capability descriptor table.
- current_
cpu_ execution - Report what CPU execution the current thread is inside, including a managed Rayon worker running a session or scope callback.
- discover_
cpu_ topology - Discover the process-visible CPU and NUMA topology.
- resolve_
cpu_ affinity - Resolve a CPU execution domain from input affinity metadata.
- resolve_
cpu_ affinity_ with_ override - Resolve CPU affinity with an optional operation-local explicit override.
- runtime_
engine_ id - Return the canonical CPU runtime engine identifier.
- runtime_
engine_ registration - Build a runtime engine registration for a
CpuBackend. - runtime_
engine_ registration_ with_ id - Build a runtime engine registration for a
CpuBackendwith a caller-selected engine identifier. - runtime_
hardware_ class - Return the canonical CPU runtime hardware class.
- scalar_
binary_ into - Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. Apply a named binary operation elementwise into a caller-owned destination.
- scalar_
fold - Ordinary CPU entry points that take a caller-provided destination and the
caller’s own arithmetic instead of the typed pool.
Fold every element of a caller-owned tensor with a named associative
operation, starting from
init. - with_
batch_ policy - Run
fonsessionwithpolicyas the effective batch policy.