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
impl CpuBackend
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a CPU backend using the environment-driven CPU context.
§Examples
use tenferro_cpu::CpuBackend;
let backend = CpuBackend::new();Sourcepub fn from_external_managed_domains(
default_domain: CpuDomainId,
domains: impl IntoIterator<Item = ExternalCpuDomain>,
) -> Result<Self, CpuBackendError>
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.
Sourcepub fn from_external_managed_domains_with_provider_bundle(
default_domain: CpuDomainId,
domains: impl IntoIterator<Item = ExternalCpuDomain>,
provider_bundle: CpuProviderBundle,
) -> Result<Self, CpuBackendError>
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.
Sourcepub fn with_kind(kind: CpuBackendKind) -> Result<Self, CpuBackendError>
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.
Sourcepub fn try_new() -> Result<Self, CpuBackendError>
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.
Sourcepub fn from_context(ctx: Arc<CpuContext>) -> Self
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);Sourcepub fn from_context_with_buffer_pool_limit(
ctx: Arc<CpuContext>,
max_retained_capacity_bytes: usize,
) -> Self
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);Sourcepub fn with_threads(num_threads: usize) -> Result<Self, CpuBackendError>
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.
Sourcepub fn with_threads_and_kind(
num_threads: usize,
kind: CpuBackendKind,
) -> Result<Self, CpuBackendError>
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.
Sourcepub fn for_placement(
&self,
requested: CpuPlacement,
) -> Result<Self, CpuPlacementError>
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.
Sourcepub fn placement(&self) -> CpuPlacement
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);Sourcepub fn resolved_placement(&self) -> Option<&ResolvedCpuPlacement>
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());
}Sourcepub fn topology(&self) -> &CpuTopology
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());Sourcepub fn supports_placement(&self, placement: CpuPlacement) -> bool
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));Sourcepub fn execution_info(&self) -> CpuExecutionInfo
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());Sourcepub fn kind(&self) -> CpuBackendKind
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());Sourcepub fn provider_bundle(&self) -> &CpuProviderBundle
pub fn provider_bundle(&self) -> &CpuProviderBundle
Return the immutable CPU provider slots selected for this handle.
Sourcepub fn runtime_identity(&self) -> CpuRuntimeIdentity
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.
Sourcepub fn with_provider_bundle(
self,
bundle: CpuProviderBundle,
) -> Result<Self, CpuProviderBundleInstallError>
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.
Sourcepub fn num_threads(&self) -> usize
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);Sourcepub fn buffer_pool_len(&self) -> Result<usize>
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.
Sourcepub fn buffer_pool_stats(&self) -> Result<BufferPoolStats>
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.
Sourcepub fn buffer_pool_cache_stats(&self) -> Result<CacheStats>
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.
Sourcepub fn indexed_plan_cache_limits(&self) -> Result<IndexedPlanCacheLimits>
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.
Sourcepub fn set_indexed_plan_cache_limits(
&mut self,
limits: IndexedPlanCacheLimits,
) -> Result<()>
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.
Sourcepub fn indexed_plan_cache_stats(&self) -> Result<CacheStats>
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.
Sourcepub fn clear_indexed_plan_cache(&mut self) -> Result<()>
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.
Sourcepub fn buffer_pool_limit_bytes(&self) -> usize
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);Sourcepub fn set_buffer_pool_limit_bytes(
&mut self,
max_retained_capacity_bytes: usize,
) -> Result<()>
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.
Sourcepub fn reset_buffer_pool(&mut self) -> Result<()>
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.
Sourcepub fn install<R: Send>(&self, op: impl FnOnce() -> R + Send) -> R
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
impl CpuBackend
Sourcepub fn with_allocation_domain(
self,
domain: Arc<dyn SharedTensorAllocationDomain>,
) -> Self
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));Sourcepub fn allocation_domain(&self) -> Option<AllocationDomainId>
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);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
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<()>
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<()>
Source§impl BackendSessionHost for CpuBackend
impl BackendSessionHost for CpuBackend
fn with_backend_session<R: Send>( &mut self, f: impl FnOnce(&mut dyn BackendSession) -> R + Send, ) -> R
Source§impl Clone for CpuBackend
impl Clone for CpuBackend
Source§fn clone(&self) -> CpuBackend
fn clone(&self) -> CpuBackend
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 CpuBackend
impl Debug for CpuBackend
Source§impl Default for CpuBackend
impl Default for CpuBackend
Source§impl DotGeneralPreparation for CpuBackend
impl DotGeneralPreparation for CpuBackend
Source§impl ElementwiseRuntime for CpuBackend
impl ElementwiseRuntime for CpuBackend
Source§impl IndexingRuntime for CpuBackend
impl IndexingRuntime for CpuBackend
Source§impl LayoutRuntime for CpuBackend
impl LayoutRuntime for CpuBackend
Source§impl ReductionRuntime for CpuBackend
impl ReductionRuntime for CpuBackend
Source§impl RuntimeCacheOwner for CpuBackend
impl RuntimeCacheOwner for CpuBackend
Source§impl TensorAnalytic for CpuBackend
impl TensorAnalytic for CpuBackend
Source§fn rsqrt_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
fn rsqrt_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
Source§fn pow_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn pow_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn expm1_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
fn expm1_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
Source§fn log1p_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
fn log1p_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
Source§impl TensorBackendCapability for CpuBackend
impl TensorBackendCapability for CpuBackend
fn backend_id(&self) -> BackendId
fn capabilities(&self) -> &'static [OperationCapability]
Source§fn capability(&self, query: CapabilityQuery) -> Option<OperationCapability>
fn capability(&self, query: CapabilityQuery) -> Option<OperationCapability>
Source§fn require_capability(
&self,
query: CapabilityQuery,
axis: CapabilityAxis,
) -> Result<OperationCapability, Error>
fn require_capability( &self, query: CapabilityQuery, axis: CapabilityAxis, ) -> Result<OperationCapability, Error>
Source§impl TensorBuffer for CpuBackend
impl TensorBuffer for CpuBackend
fn reclaim_buffer(&mut self, tensor: Tensor)
Source§impl TensorDeviceTransfer for CpuBackend
impl TensorDeviceTransfer for CpuBackend
Source§impl TensorDot for CpuBackend
impl TensorDot for CpuBackend
Source§fn dot_general(
&mut self,
lhs: &Tensor,
rhs: &Tensor,
config: &DotGeneralConfig,
) -> Result<Tensor>
fn dot_general( &mut self, lhs: &Tensor, rhs: &Tensor, config: &DotGeneralConfig, ) -> Result<Tensor>
Source§fn dot_general_read_into(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
out: TensorWrite<'_>,
) -> Result<()>
fn dot_general_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, config: &DotGeneralConfig, out: TensorWrite<'_>, ) -> Result<()>
Source§fn dot_general_read_into_accum(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
config: &DotGeneralConfig,
accumulation: DotGeneralAccumulation,
out: TensorWrite<'_>,
) -> Result<()>
fn dot_general_read_into_accum( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, config: &DotGeneralConfig, accumulation: DotGeneralAccumulation, out: TensorWrite<'_>, ) -> Result<()>
Source§impl TensorElementwise for CpuBackend
impl TensorElementwise for CpuBackend
Source§fn elementwise_read_into(
&mut self,
op: ElementwiseReadOp,
inputs: &[TensorRead<'_>],
out: TensorWrite<'_>,
) -> Result<()>
fn elementwise_read_into( &mut self, op: ElementwiseReadOp, inputs: &[TensorRead<'_>], out: TensorWrite<'_>, ) -> Result<()>
Source§fn add_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn add_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn sub_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn sub_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn mul_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn mul_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn div_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn div_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn rem(&mut self, lhs: &Tensor, rhs: &Tensor) -> Result<Tensor>
fn rem(&mut self, lhs: &Tensor, rhs: &Tensor) -> Result<Tensor>
Source§fn rem_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn rem_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn maximum_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn maximum_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn minimum_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
) -> Result<Tensor>
fn minimum_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, ) -> Result<Tensor>
Source§fn compare(
&mut self,
lhs: &Tensor,
rhs: &Tensor,
dir: &CompareDir,
) -> Result<Tensor>
fn compare( &mut self, lhs: &Tensor, rhs: &Tensor, dir: &CompareDir, ) -> Result<Tensor>
Source§fn compare_read(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
dir: &CompareDir,
) -> Result<Tensor>
fn compare_read( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, dir: &CompareDir, ) -> Result<Tensor>
Source§fn select(
&mut self,
pred: &Tensor,
on_true: &Tensor,
on_false: &Tensor,
) -> Result<Tensor>
fn select( &mut self, pred: &Tensor, on_true: &Tensor, on_false: &Tensor, ) -> Result<Tensor>
Source§fn select_read(
&mut self,
pred: TensorRead<'_>,
on_true: TensorRead<'_>,
on_false: TensorRead<'_>,
) -> Result<Tensor>
fn select_read( &mut self, pred: TensorRead<'_>, on_true: TensorRead<'_>, on_false: TensorRead<'_>, ) -> Result<Tensor>
Source§fn clamp(
&mut self,
input: &Tensor,
lower: &Tensor,
upper: &Tensor,
) -> Result<Tensor>
fn clamp( &mut self, input: &Tensor, lower: &Tensor, upper: &Tensor, ) -> Result<Tensor>
Source§fn clamp_read(
&mut self,
input: TensorRead<'_>,
lower: TensorRead<'_>,
upper: TensorRead<'_>,
) -> Result<Tensor>
fn clamp_read( &mut self, input: TensorRead<'_>, lower: TensorRead<'_>, upper: TensorRead<'_>, ) -> Result<Tensor>
Source§fn add_into(
&mut self,
lhs: &Tensor,
rhs: &Tensor,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn add_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn add_read_into(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn add_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn sub_into(
&mut self,
lhs: &Tensor,
rhs: &Tensor,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn sub_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn sub_read_into(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn sub_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn mul_into(
&mut self,
lhs: &Tensor,
rhs: &Tensor,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn mul_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn mul_read_into(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn mul_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn neg_into(
&mut self,
input: &Tensor,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn neg_into( &mut self, input: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn neg_read_into(
&mut self,
input: TensorRead<'_>,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn neg_read_into( &mut self, input: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn conj_into(
&mut self,
input: &Tensor,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn conj_into( &mut self, input: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn conj_read_into(
&mut self,
input: TensorRead<'_>,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn conj_read_into( &mut self, input: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn div_into(
&mut self,
lhs: &Tensor,
rhs: &Tensor,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn div_into( &mut self, lhs: &Tensor, rhs: &Tensor, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§fn div_read_into(
&mut self,
lhs: TensorRead<'_>,
rhs: TensorRead<'_>,
out: TensorWrite<'_>,
) -> Result<(), Error>
fn div_read_into( &mut self, lhs: TensorRead<'_>, rhs: TensorRead<'_>, out: TensorWrite<'_>, ) -> Result<(), Error>
Source§impl TensorIndexing for CpuBackend
impl TensorIndexing for CpuBackend
Source§fn gather(
&mut self,
operand: &Tensor,
start_indices: &Tensor,
config: &GatherConfig,
) -> Result<Tensor>
fn gather( &mut self, operand: &Tensor, start_indices: &Tensor, config: &GatherConfig, ) -> Result<Tensor>
Source§fn scatter(
&mut self,
operand: &Tensor,
scatter_indices: &Tensor,
updates: &Tensor,
config: &ScatterConfig,
) -> Result<Tensor>
fn scatter( &mut self, operand: &Tensor, scatter_indices: &Tensor, updates: &Tensor, config: &ScatterConfig, ) -> Result<Tensor>
Source§fn dynamic_slice(
&mut self,
input: &Tensor,
starts: &Tensor,
slice_sizes: &[usize],
) -> Result<Tensor>
fn dynamic_slice( &mut self, input: &Tensor, starts: &Tensor, slice_sizes: &[usize], ) -> Result<Tensor>
Source§impl TensorReduction for CpuBackend
impl TensorReduction for CpuBackend
Source§fn reduce_sum_read(
&mut self,
input: TensorRead<'_>,
axes: &[usize],
) -> Result<Tensor>
fn reduce_sum_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor>
Source§fn reduce_prod_read(
&mut self,
input: TensorRead<'_>,
axes: &[usize],
) -> Result<Tensor>
fn reduce_prod_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor>
Source§fn reduce_max_read(
&mut self,
input: TensorRead<'_>,
axes: &[usize],
) -> Result<Tensor>
fn reduce_max_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor>
Source§fn reduce_min_read(
&mut self,
input: TensorRead<'_>,
axes: &[usize],
) -> Result<Tensor>
fn reduce_min_read( &mut self, input: TensorRead<'_>, axes: &[usize], ) -> Result<Tensor>
Source§impl TensorStructural for CpuBackend
impl TensorStructural for CpuBackend
Source§fn to_contiguous_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
fn to_contiguous_read(&mut self, input: TensorRead<'_>) -> Result<Tensor>
Source§fn copy_read_into(
&mut self,
src: TensorRead<'_>,
dst: TensorWrite<'_>,
) -> Result<()>
fn copy_read_into( &mut self, src: TensorRead<'_>, dst: TensorWrite<'_>, ) -> Result<()>
Source§fn transpose_read(
&mut self,
input: TensorRead<'_>,
perm: &[usize],
) -> Result<Tensor>
fn transpose_read( &mut self, input: TensorRead<'_>, perm: &[usize], ) -> Result<Tensor>
Source§fn reshape_read(
&mut self,
input: TensorRead<'_>,
shape: &[usize],
) -> Result<Tensor>
fn reshape_read( &mut self, input: TensorRead<'_>, shape: &[usize], ) -> Result<Tensor>
Source§fn broadcast_in_dim(
&mut self,
input: &Tensor,
shape: &[usize],
dims: &[usize],
) -> Result<Tensor>
fn broadcast_in_dim( &mut self, input: &Tensor, shape: &[usize], dims: &[usize], ) -> Result<Tensor>
Source§fn broadcast_in_dim_read(
&mut self,
input: TensorRead<'_>,
shape: &[usize],
dims: &[usize],
) -> Result<Tensor>
fn broadcast_in_dim_read( &mut self, input: TensorRead<'_>, shape: &[usize], dims: &[usize], ) -> Result<Tensor>
Source§fn cast(&mut self, input: &Tensor, to: DType) -> Result<Tensor>
fn cast(&mut self, input: &Tensor, to: DType) -> Result<Tensor>
Source§fn extract_diagonal(
&mut self,
input: &Tensor,
axis_a: usize,
axis_b: usize,
) -> Result<Tensor>
fn extract_diagonal( &mut self, input: &Tensor, axis_a: usize, axis_b: usize, ) -> Result<Tensor>
Source§impl<T, R> TensorViewCanonicalization<T, R> for CpuBackend
impl<T, R> TensorViewCanonicalization<T, R> for CpuBackend
Source§fn to_contiguous(
&mut self,
view: &TypedTensorView<'_, T, R>,
) -> Result<TypedTensor<T, R>>
fn to_contiguous( &mut self, view: &TypedTensorView<'_, T, R>, ) -> Result<TypedTensor<T, R>>
Source§fn copy_into(
&mut self,
src: &TypedTensorView<'_, T, R>,
dst: &mut TypedTensorViewMut<'_, T, R>,
) -> Result<()>
fn copy_into( &mut self, src: &TypedTensorView<'_, T, R>, dst: &mut TypedTensorViewMut<'_, T, R>, ) -> Result<()>
impl BackendRuntimeCache for CpuBackend
impl TensorBackend for CpuBackend
impl TensorFusion for CpuBackend
Auto Trait Implementations§
impl Freeze for CpuBackend
impl !RefUnwindSafe for CpuBackend
impl Send for CpuBackend
impl Sync for CpuBackend
impl Unpin for CpuBackend
impl UnsafeUnpin for CpuBackend
impl !UnwindSafe for CpuBackend
Blanket Implementations§
Source§impl<T> BackendSession for Twhere
T: TensorBackendOps + SessionCachedDot + TensorDeviceTransfer,
impl<T> BackendSession for Twhere
T: TensorBackendOps + SessionCachedDot + TensorDeviceTransfer,
fn session_type_name(&self) -> &'static str
unsafe fn session_data_mut(&mut self) -> *mut ()
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,
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