Skip to main content

CpuBackend

Struct CpuBackend 

Source
pub struct CpuBackend { /* private fields */ }
Expand description

A cheap cloneable handle to shared CPU execution coordination.

Clones share topology, execution engines, arbitration, and engine-owned buffer resources.

§Examples

use tenferro_cpu::CpuBackend;

let backend = CpuBackend::new();
let clone = backend.clone();
assert_eq!(backend.kind(), clone.kind());

Implementations§

Source§

impl CpuBackend

Source

pub fn new() -> Self

Create a CPU backend using the environment-driven CPU context.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::new();
Source

pub fn from_external_managed_domains( default_domain: CpuDomainId, domains: impl IntoIterator<Item = ExternalCpuDomain>, ) -> Result<Self, CpuBackendError>

Create one coordinator from caller-owned CPU domain executors.

The descriptors are moved into prebuilt engines. Auto selects default_domain; explicit placement requests are registry-only and never construct a managed context or thread pool.

§Examples
use std::num::NonZeroUsize;
use std::sync::Arc;
use tenferro_cpu::{
    discover_cpu_topology, CpuBackend, CpuBackendError, CpuContext,
    CpuExecutionMode, CpuPlacementGuarantee, CpuProviderBundleInstallError,
    ExternalCpuDomain, ResolvedCpuPlacement,
};
use tenferro_tensor::CpuDomainId;

let topology = discover_cpu_topology()?;
let id = CpuDomainId::new(7);
let domain = ExternalCpuDomain::new(
    id,
    ResolvedCpuPlacement::AllAllowed {
        cpus: topology.allowed_cpus().clone(),
    },
    Arc::new(CpuContext::with_threads(1)?),
    NonZeroUsize::new(1).unwrap(),
    CpuPlacementGuarantee::AdvisoryDeclared,
)?;
match CpuBackend::from_external_managed_domains(id, [domain]) {
    Ok(backend) => assert_eq!(
        backend.execution_info().execution_mode(),
        CpuExecutionMode::ExternalManaged,
    ),
    Err(CpuBackendError::Tensor(error)) => assert!(
        std::error::Error::source(&error)
            .and_then(|source| source.downcast_ref::<CpuProviderBundleInstallError>())
            .is_some(),
        "an uncontrolled compiled provider must retain its typed source",
    ),
    Err(error) => return Err(error.into()),
}
§Errors

Returns CpuBackendError::Placement when process topology discovery fails. Returns CpuBackendError::ExternalRegistry for an empty registry, duplicate domain or placement identity, a CPU outside the process-allowed set, a missing default domain, or an exact ResolvedCpuPlacement::AllAllowed declaration that differs from the process-allowed CPU set. Returns CpuBackendError::Tensor with a CpuProviderBundleInstallError source when the compiled standard provider cannot satisfy an external domain contract. Applications that supply controlled providers can use CpuBackend::from_external_managed_domains_with_provider_bundle.

Source

pub fn from_external_managed_domains_with_provider_bundle( default_domain: CpuDomainId, domains: impl IntoIterator<Item = ExternalCpuDomain>, provider_bundle: CpuProviderBundle, ) -> Result<Self, CpuBackendError>

Create one coordinator from caller-owned CPU domain executors and an immutable provider bundle.

Domain registry construction and provider compatibility validation are atomic: no backend is returned unless provider_bundle satisfies every supplied domain. The bundle currently selects dot_general operation- family providers; linalg operation-family selection still follows the compiled CpuBackendKind and is not replaced by this API.

§Examples
use std::num::NonZeroUsize;
use std::sync::Arc;
use tenferro_cpu::{
    discover_cpu_topology, CpuBackend, CpuBackendKind, CpuContext,
    CpuExecutionMode, CpuPlacementGuarantee, CpuProviderBundle,
    ExternalCpuDomain, ResolvedCpuPlacement,
};
use tenferro_tensor::CpuDomainId;

let topology = discover_cpu_topology()?;
let id = CpuDomainId::new(7);
let domain = ExternalCpuDomain::new(
    id,
    ResolvedCpuPlacement::AllAllowed {
        cpus: topology.allowed_cpus().clone(),
    },
    Arc::new(CpuContext::with_threads(1)?),
    NonZeroUsize::new(1).unwrap(),
    CpuPlacementGuarantee::AdvisoryDeclared,
)?;
let bundle = CpuProviderBundle::builder(CpuBackendKind::Faer).build()?;
let backend = CpuBackend::from_external_managed_domains_with_provider_bundle(
    id,
    [domain],
    bundle.clone(),
)?;
assert_eq!(
    backend.execution_info().execution_mode(),
    CpuExecutionMode::ExternalManaged,
);
assert!(backend.provider_bundle().shares_identity_with(&bundle));
§Errors

Returns the same topology and registry errors as CpuBackend::from_external_managed_domains. Provider incompatibility is returned as CpuBackendError::Tensor. Calling std::error::Error::source on that value yields the typed CpuProviderBundleInstallError, whose own source is the rejected crate::CpuProviderDomainError.

Source

pub fn with_kind(kind: CpuBackendKind) -> Result<Self, CpuBackendError>

Create a CPU backend using the selected compiled provider.

§Examples
use tenferro_cpu::{CpuBackend, CpuBackendKind};

let backend = CpuBackend::with_kind(CpuBackendKind::default_compiled()).unwrap();
assert_eq!(backend.kind(), CpuBackendKind::default_compiled());
§Errors

Returns CpuBackendError::Tensor when the provider is unavailable or its configuration is invalid, and CpuBackendError::Placement when CPU topology discovery or placement initialization fails.

Source

pub fn try_new() -> Result<Self, CpuBackendError>

Try to create a CPU backend using RAYON_NUM_THREADS.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::try_new()
    .unwrap_or_else(|_| CpuBackend::with_threads(1).unwrap());
let _ = backend.num_threads();
§Errors

Returns CpuBackendError::Tensor when RAYON_NUM_THREADS is zero, malformed, or the compiled provider cannot be selected, and CpuBackendError::Placement when CPU topology or managed placement initialization is unavailable.

Source

pub fn from_context(ctx: Arc<CpuContext>) -> Self

Create a CPU backend from an existing context.

§Examples
use std::sync::Arc;
use tenferro_cpu::{CpuBackend, CpuContext};

let ctx = Arc::new(CpuContext::with_threads(2).unwrap());
let backend = CpuBackend::from_context(ctx);
assert_eq!(backend.num_threads(), 2);
Source

pub fn from_context_with_buffer_pool_limit( ctx: Arc<CpuContext>, max_retained_capacity_bytes: usize, ) -> Self

Create a CPU backend from an existing context and buffer-pool retention cap.

The cap is measured in retained vector capacity bytes. A cap of zero disables buffer retention.

§Examples
use std::sync::Arc;
use tenferro_cpu::{CpuBackend, CpuContext};

let ctx = Arc::new(CpuContext::with_threads(1).unwrap());
let backend = CpuBackend::from_context_with_buffer_pool_limit(ctx, 0);
assert_eq!(backend.buffer_pool_limit_bytes(), 0);
Source

pub fn with_threads(num_threads: usize) -> Result<Self, CpuBackendError>

Create a CPU backend with a custom thread count.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::with_threads(2).unwrap();
assert_eq!(backend.num_threads(), 2);
§Errors

Returns CpuBackendError::Tensor with ValidationError::InvalidArgument when num_threads is zero or the context cannot be configured, and CpuBackendError::Placement when CPU topology or placement fails.

Source

pub fn with_threads_and_kind( num_threads: usize, kind: CpuBackendKind, ) -> Result<Self, CpuBackendError>

Create a CPU backend with a custom thread count and provider.

§Examples
use tenferro_cpu::{CpuBackend, CpuBackendKind};

let backend = CpuBackend::with_threads_and_kind(
    1,
    CpuBackendKind::default_compiled(),
)?;
assert_eq!(backend.num_threads(), 1);
§Errors

Returns CpuBackendError::Tensor with ValidationError::InvalidArgument when num_threads is zero or the provider is unavailable, and CpuBackendError::Placement when CPU topology or placement fails.

Source

pub fn for_placement( &self, requested: CpuPlacement, ) -> Result<Self, CpuPlacementError>

Clone this backend coordinator with a specific CPU placement request.

Managed explicit placement is supported for faer/native execution. Externally managed coordinators resolve explicit requests only to matching registered domains and never construct a fallback engine.

§Examples
use tenferro_cpu::{CpuBackend, CpuPlacement};

let backend = CpuBackend::new();
if backend.supports_placement(CpuPlacement::AllAllowed) {
    let placed = backend.for_placement(CpuPlacement::AllAllowed)?;
    assert_eq!(placed.placement(), CpuPlacement::AllAllowed);
}
§Errors

Returns CpuPlacementError when the requested placement is not available for this backend or its affinity cannot be configured.

Source

pub fn placement(&self) -> CpuPlacement

Return the placement requested by this handle.

§Examples
use tenferro_cpu::{CpuBackend, CpuPlacement};

assert_eq!(CpuBackend::new().placement(), CpuPlacement::Auto);
Source

pub fn resolved_placement(&self) -> Option<&ResolvedCpuPlacement>

Return the concrete managed placement or external placement declaration.

Provider-default-exclusive and compatibility contexts return None.

§Examples
use tenferro_cpu::{CpuBackend, CpuPlacement};

let backend = CpuBackend::new();
if backend.supports_placement(CpuPlacement::AllAllowed) {
    assert!(backend
        .for_placement(CpuPlacement::AllAllowed)?
        .resolved_placement()
        .is_some());
}
Source

pub fn topology(&self) -> &CpuTopology

Return the process-visible topology shared by all coordinator clones.

§Examples
use tenferro_cpu::CpuBackend;

assert!(!CpuBackend::new().topology().allowed_cpus().is_empty());
Source

pub fn supports_placement(&self, placement: CpuPlacement) -> bool

Report whether this coordinator can resolve a placement request.

§Examples
use tenferro_cpu::{CpuBackend, CpuPlacement};

assert!(CpuBackend::new().supports_placement(CpuPlacement::Auto));
Source

pub fn execution_info(&self) -> CpuExecutionInfo

Return a snapshot suitable for diagnostics and placement reporting.

§Examples
let backend = tenferro_cpu::CpuBackend::new();
assert_eq!(backend.execution_info().backend_kind(), backend.kind());
Source

pub fn kind(&self) -> CpuBackendKind

Return the runtime CPU provider selected by this backend.

§Examples
use tenferro_cpu::{CpuBackend, CpuBackendKind};

let backend = CpuBackend::new();
assert_eq!(backend.kind(), CpuBackendKind::default_compiled());
Source

pub fn provider_bundle(&self) -> &CpuProviderBundle

Return the immutable CPU provider slots selected for this handle.

Source

pub fn runtime_identity(&self) -> CpuRuntimeIdentity

Return the opaque identity of this backend’s executable witness.

The identity has no access to backend execution or storage resources. Clones of this backend retain the identity, while separately constructed backends and backends returned after changing immutable witness resources receive a distinct identity.

Source

pub fn with_provider_bundle( self, bundle: CpuProviderBundle, ) -> Result<Self, CpuProviderBundleInstallError>

Return this backend with an immutable construction-time provider bundle.

Existing clones retain their original bundle identity.

§Examples
use tenferro_cpu::{CpuBackend, CpuBackendKind, CpuProviderBundle};
let bundle = CpuProviderBundle::builder(CpuBackendKind::Faer).build()?;
let backend = CpuBackend::new().with_provider_bundle(bundle.clone())?;
assert!(backend.provider_bundle().shares_identity_with(&bundle));
§Errors

Returns CpuProviderBundleInstallError::IncompatibleDomain if a provider cannot satisfy one of this backend’s resource-domain contracts.

Source

pub fn num_threads(&self) -> usize

Return the selected CPU domain’s thread budget.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::with_threads(2).unwrap();
assert_eq!(backend.num_threads(), 2);
Source

pub fn buffer_pool_len(&self) -> Result<usize>

Number of retained typed host buffers currently held by this backend.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::new();
assert_eq!(backend.buffer_pool_len()?, 0);
§Errors

Returns crate::Error::RuntimeState when the engine registry or an initialized engine’s resources lock is poisoned.

Source

pub fn buffer_pool_stats(&self) -> Result<BufferPoolStats>

Snapshot reusable typed host buffers currently retained by this backend.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::new();
let stats = backend.buffer_pool_stats()?;
assert_eq!(stats.buffers, 0);
assert_eq!(stats.capacity_bytes, 0);
§Errors

Returns crate::Error::RuntimeState when the engine registry or an initialized engine’s resources lock is poisoned.

Source

pub fn buffer_pool_cache_stats(&self) -> Result<CacheStats>

Return cache-style stats for the CPU buffer pool.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::new();
let stats = backend.buffer_pool_cache_stats()?;
assert_eq!(stats.entries, 0);
assert_eq!(stats.retained_bytes, 0);
§Errors

Returns crate::Error::RuntimeState when the engine registry or an initialized engine’s resources lock is poisoned.

Source

pub fn indexed_plan_cache_limits(&self) -> Result<IndexedPlanCacheLimits>

Return the limits applied to each CPU engine’s indexed-plan cache.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::new();
assert!(backend.indexed_plan_cache_limits()?.max_entries() > 0);
§Errors

Returns crate::Error::RuntimeState when the shared cache configuration lock is poisoned.

Source

pub fn set_indexed_plan_cache_limits( &mut self, limits: IndexedPlanCacheLimits, ) -> Result<()>

Update indexed-plan cache limits for current and future CPU engines.

Shrinking either bound evicts least-recently-used plans immediately. A zero entry or byte bound disables retention.

§Examples
use tenferro_cpu::{CpuBackend, IndexedPlanCacheLimits};

let mut backend = CpuBackend::new();
backend.set_indexed_plan_cache_limits(IndexedPlanCacheLimits::new(8, 4096))?;
assert_eq!(backend.indexed_plan_cache_limits()?.max_entries(), 8);
§Errors

Returns crate::Error::RuntimeState without changing the configured limits when an engine registry or resource lock is poisoned.

Source

pub fn indexed_plan_cache_stats(&self) -> Result<CacheStats>

Snapshot aggregate indexed-plan cache statistics across initialized CPU engines.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::new();
assert_eq!(backend.indexed_plan_cache_stats()?.entries, 0);
§Errors

Returns crate::Error::RuntimeState when an engine registry or resource lock is poisoned.

Source

pub fn clear_indexed_plan_cache(&mut self) -> Result<()>

Clear indexed traversal plans retained by all initialized CPU engines.

§Examples
use tenferro_cpu::CpuBackend;

let mut backend = CpuBackend::new();
backend.clear_indexed_plan_cache()?;
assert_eq!(backend.indexed_plan_cache_stats()?.entries, 0);
§Errors

Returns crate::Error::RuntimeState without clearing any engine when an engine registry or resource lock is poisoned.

Source

pub fn buffer_pool_limit_bytes(&self) -> usize

Current CPU buffer-pool retention limit in bytes.

§Examples
use std::sync::Arc;
use tenferro_cpu::{CpuBackend, CpuContext};

let backend = CpuBackend::from_context_with_buffer_pool_limit(
    Arc::new(CpuContext::with_threads(1).unwrap()),
    4096,
);
assert_eq!(backend.buffer_pool_limit_bytes(), 4096);
Source

pub fn set_buffer_pool_limit_bytes( &mut self, max_retained_capacity_bytes: usize, ) -> Result<()>

Update the CPU buffer-pool retention limit in bytes.

Shrinking the limit evicts retained buffers immediately. A limit of zero disables buffer retention.

§Examples
use tenferro_cpu::CpuBackend;

let mut backend = CpuBackend::new();
backend.set_buffer_pool_limit_bytes(0)?;
assert_eq!(backend.buffer_pool_limit_bytes(), 0);
assert_eq!(backend.buffer_pool_len()?, 0);
§Errors

Returns crate::Error::RuntimeState without changing the configured limit when the engine registry or any initialized engine’s resources lock is poisoned.

Source

pub fn reset_buffer_pool(&mut self) -> Result<()>

Reset reusable typed host buffers currently retained by this backend.

This releases pool-owned vectors to the process allocator. Operating system RSS may not fall immediately because allocators can retain freed pages for future allocations.

§Examples
use tenferro_cpu::CpuBackend;

let mut backend = CpuBackend::new();
backend.reset_buffer_pool()?;
assert_eq!(backend.buffer_pool_len()?, 0);
§Errors

Returns crate::Error::RuntimeState without clearing any initialized engine when the engine registry or any engine’s resources lock is poisoned.

Source

pub fn install<R: Send>(&self, op: impl FnOnce() -> R + Send) -> R

Run a closure in this backend’s CPU execution scope.

§Examples
use tenferro_cpu::CpuBackend;

let backend = CpuBackend::with_threads(1).unwrap();
let value = backend.install(|| 1 + 1);
assert_eq!(value, 2);
§Panics

Panics when re-entered while another CPU backend execution is active on the current thread or managed Rayon scope. This includes direct nesting and backend calls from parallel child tasks; either could violate CPU or provider exclusivity. For an externally managed domain, it also panics with the executor’s typed diagnostic when synchronous executor entry fails because this convenience method cannot return a Result.

Source§

impl CpuBackend

Source

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

Bind this backend handle to a shared-allocation domain.

Host-only CPU behavior is unchanged. Operation crates can use the domain to require guarded access to matching managed allocations.

§Examples
use tenferro_cpu::CpuBackend;
use std::sync::Arc;
use tenferro_tensor::{AllocationDomainId, DType, SharedTensorAllocationDomain, Tensor};

#[derive(Debug)]
struct Domain(AllocationDomainId);
impl SharedTensorAllocationDomain for Domain {
    fn id(&self) -> AllocationDomainId { self.0 }
    fn allocate(&self, _: DType, _: &[usize]) -> tenferro_tensor::Result<Tensor> {
        Err(tenferro_tensor::Error::unsupported("example", "not implemented"))
    }
}
let id = AllocationDomainId::fresh();
let backend = CpuBackend::new().with_allocation_domain(Arc::new(Domain(id)));
assert_eq!(backend.allocation_domain(), Some(id));
Source

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

Return the configured shared-allocation domain.

§Examples
use tenferro_cpu::CpuBackend;

assert_eq!(CpuBackend::new().allocation_domain(), None);
Source

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

Return the allocator for this backend’s shared domain.

§Examples
use tenferro_cpu::CpuBackend;

assert!(CpuBackend::new().shared_allocation_domain().is_none());

Trait Implementations§

Source§

impl BackendCachedDot for CpuBackend

Source§

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

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

impl BackendSessionHost for CpuBackend

Source§

fn with_backend_session<R: Send>( &mut self, f: impl FnOnce(&mut dyn BackendSession) -> R + Send, ) -> R

Source§

impl Clone for CpuBackend

Source§

fn clone(&self) -> CpuBackend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CpuBackend

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CpuBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DotGeneralPreparation for CpuBackend

Source§

fn prepare( &self, request: DotGeneralPrepareRequest<'_>, ) -> Result<PrepareCapability, PrepareError>

Prepare one dot-general operation. Read more
Source§

impl ElementwiseRuntime for CpuBackend

Source§

fn prepare( &self, request: ElementwisePrepareRequest<'_>, ) -> Result<PrepareCapability, PrepareError>

Prepare one elementwise operation. Read more
Source§

impl IndexingRuntime for CpuBackend

Source§

fn prepare( &self, request: IndexingPrepareRequest<'_>, ) -> Result<PrepareCapability, PrepareError>

Prepare one indexing operation. Read more
Source§

impl LayoutRuntime for CpuBackend

Source§

fn prepare( &self, request: LayoutPrepareRequest<'_>, ) -> Result<PrepareCapability, PrepareError>

Prepare one layout operation. Read more
Source§

impl ReductionRuntime for CpuBackend

Source§

fn prepare( &self, request: ReductionPrepareRequest<'_>, ) -> Result<PrepareCapability, PrepareError>

Prepare one reduction operation. Read more
Source§

impl RuntimeCacheOwner for CpuBackend

Source§

fn cache_stats(&self) -> Result<CacheStats, CacheOwnerError>

Return this owner’s current cache statistics. Read more
Source§

fn clear_caches(&self) -> Result<(), CacheOwnerError>

Clear this owner’s retained caches. Read more
Source§

impl TensorAnalytic for CpuBackend

Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

impl TensorBackendCapability for CpuBackend

Source§

fn backend_id(&self) -> BackendId

Source§

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

Source§

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

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

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

impl TensorBuffer for CpuBackend

Source§

fn reclaim_buffer(&mut self, tensor: Tensor)

Source§

impl TensorDeviceTransfer for CpuBackend

Source§

fn download_to_host(&mut self, tensor: &Tensor) -> Result<Tensor>

Errors Read more
Source§

fn upload_host_tensor(&mut self, tensor: &Tensor) -> Result<Tensor>

Errors Read more
Source§

impl TensorDot for CpuBackend

Source§

fn dot_general( &mut self, lhs: &Tensor, rhs: &Tensor, config: &DotGeneralConfig, ) -> Result<Tensor>

Errors Read more
Source§

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

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

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

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

impl TensorElementwise for CpuBackend

Source§

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

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

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

Errors Read more
Source§

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

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

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

Errors Read more
Source§

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

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

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Elementwise remainder. Read more
Source§

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

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

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

fn compare( &mut self, lhs: &Tensor, rhs: &Tensor, dir: &CompareDir, ) -> Result<Tensor>

Errors Read more
Source§

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

Errors Read more
Source§

fn select( &mut self, pred: &Tensor, on_true: &Tensor, on_false: &Tensor, ) -> Result<Tensor>

Errors Read more
Source§

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

Errors Read more
Source§

fn clamp( &mut self, input: &Tensor, lower: &Tensor, upper: &Tensor, ) -> Result<Tensor>

Errors Read more
Source§

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

Errors Read more
Source§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl TensorIndexing for CpuBackend

Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

impl TensorReduction for CpuBackend

Source§

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

Errors Read more
Source§

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

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

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

Errors Read more
Source§

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

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

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

Errors Read more
Source§

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

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

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

Errors Read more
Source§

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

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

impl TensorStructural for CpuBackend

Source§

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

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

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

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

fn transpose(&mut self, input: &Tensor, perm: &[usize]) -> Result<Tensor>

Errors Read more
Source§

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

Errors Read more
Source§

fn reshape(&mut self, input: &Tensor, shape: &[usize]) -> Result<Tensor>

Errors Read more
Source§

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

Errors Read more
Source§

fn broadcast_in_dim( &mut self, input: &Tensor, shape: &[usize], dims: &[usize], ) -> Result<Tensor>

Errors Read more
Source§

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

Errors Read more
Source§

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

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

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

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

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

impl<T, R> TensorViewCanonicalization<T, R> for CpuBackend

Source§

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

Errors Read more
Source§

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

Errors Read more
Source§

impl BackendRuntimeCache for CpuBackend

Source§

impl TensorBackend for CpuBackend

Source§

impl TensorFusion for CpuBackend

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> BackendSession for T
where T: TensorBackendOps + SessionCachedDot + TensorDeviceTransfer,

Source§

fn session_type_name(&self) -> &'static str

Source§

unsafe fn session_data_mut(&mut self) -> *mut ()

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> SessionCachedDot for T
where T: TensorBackend + ?Sized,

Source§

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,