pub struct CpuAffinityInput {
pub domain: Option<CpuDomainId>,
pub logical_bytes: usize,
}Expand description
CPU affinity metadata for one logical operation input.
The resolver reads this metadata only. It never changes, copies, or rehomes tensor payloads.
§Examples
use tenferro_cpu::CpuAffinityInput;
use tenferro_tensor::CpuDomainId;
let input = CpuAffinityInput {
domain: Some(CpuDomainId::new(3)),
logical_bytes: 64,
};
assert_eq!(input.logical_bytes, 64);Fields§
§domain: Option<CpuDomainId>Known CPU execution domain, or None when affinity is unknown.
logical_bytes: usizeLogical input size used by CpuAffinityPolicy::DominantInputBytes.
Implementations§
Source§impl CpuAffinityInput
impl CpuAffinityInput
Sourcepub fn from_tensor(tensor: &Tensor) -> Result<Self, CpuAffinityInputError>
pub fn from_tensor(tensor: &Tensor) -> Result<Self, CpuAffinityInputError>
Construct resolver input metadata from a tensor.
The logical byte count is the checked shape product times the tensor’s scalar byte width. CPU affinity is copied from placement metadata; the tensor and its storage are otherwise untouched.
§Examples
use tenferro_cpu::CpuAffinityInput;
use tenferro_tensor::Tensor;
let tensor = Tensor::from_vec_col_major(vec![2], vec![1.0_f64, 2.0])?;
let input = CpuAffinityInput::from_tensor(&tensor)?;
assert_eq!(input.logical_bytes, 2 * std::mem::size_of::<f64>());§Errors
Returns CpuAffinityInputError when the logical element or byte
count cannot be represented by usize.
Sourcepub fn from_parts(
domain: Option<CpuDomainId>,
shape: &[usize],
dtype: DType,
) -> Result<Self, CpuAffinityInputError>
pub fn from_parts( domain: Option<CpuDomainId>, shape: &[usize], dtype: DType, ) -> Result<Self, CpuAffinityInputError>
Construct resolver input metadata from placement, shape, and dtype.
Scalar shapes have one element. Any zero extent yields zero logical bytes without multiplying the other extents.
§Examples
use tenferro_cpu::CpuAffinityInput;
use tenferro_tensor::DType;
let scalar = CpuAffinityInput::from_parts(None, &[], DType::F32)?;
let empty = CpuAffinityInput::from_parts(None, &[usize::MAX, 0], DType::F64)?;
assert_eq!(scalar.logical_bytes, 4);
assert_eq!(empty.logical_bytes, 0);§Errors
Returns CpuAffinityInputError::ShapeProductOverflow when non-zero
extents overflow, or
CpuAffinityInputError::LogicalByteCountOverflow when multiplying by
the dtype width overflows.
Trait Implementations§
Source§impl Clone for CpuAffinityInput
impl Clone for CpuAffinityInput
Source§fn clone(&self) -> CpuAffinityInput
fn clone(&self) -> CpuAffinityInput
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 CpuAffinityInput
impl Debug for CpuAffinityInput
Source§impl PartialEq for CpuAffinityInput
impl PartialEq for CpuAffinityInput
Source§fn eq(&self, other: &CpuAffinityInput) -> bool
fn eq(&self, other: &CpuAffinityInput) -> bool
self and other values to be equal, and is used by ==.impl Copy for CpuAffinityInput
impl Eq for CpuAffinityInput
impl StructuralPartialEq for CpuAffinityInput
Auto Trait Implementations§
impl Freeze for CpuAffinityInput
impl RefUnwindSafe for CpuAffinityInput
impl Send for CpuAffinityInput
impl Sync for CpuAffinityInput
impl Unpin for CpuAffinityInput
impl UnsafeUnpin for CpuAffinityInput
impl UnwindSafe for CpuAffinityInput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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