Skip to main content

AllocationGroup

Struct AllocationGroup 

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

One group of move-only owners and append-only logical descriptors.

§Examples

use tenferro_tensor::AllocationGroup;

let (group, bindings) = AllocationGroup::from_tensors(Vec::new())?;
assert!(bindings.is_empty());
assert!(format!("{group:?}").contains("AllocationGroup"));

Implementations§

Source§

impl AllocationGroup

Source

pub fn from_tensors( tensors: Vec<Tensor>, ) -> Result<(Self, Box<[DescriptorSlot]>), GroupError>

Build one move-only group for detached runtime input ownership.

§Examples
use tenferro_tensor::AllocationGroup;

let (group, bindings) = AllocationGroup::from_tensors(Vec::new())?;
assert!(bindings.is_empty());
assert!(format!("{group:?}").contains("AllocationGroup"));
§Errors

Returns GroupError::IndexOverflow when the input count cannot be represented by a descriptor slot.

Source

pub fn read_views<'a>( &'a self, bindings: &[DescriptorSlot], ) -> Result<Vec<TensorRead<'a>>, GroupError>

Borrow dtype-erased read views for descriptor bindings without materializing or cloning any owner.

§Errors

Returns GroupError::DescriptorSlotOutOfBounds, GroupError::DescriptorSlotVacant, or GroupError::InvalidDescriptor when a binding does not identify a valid descriptor.

Source

pub fn read_view<'a>( &'a self, slot: DescriptorSlot, ) -> Result<TensorRead<'a>, GroupError>

Borrow one dtype-erased read view for a descriptor without materializing or cloning its physical owner.

§Errors

Returns GroupError::DescriptorSlotOutOfBounds, GroupError::DescriptorSlotVacant, or GroupError::InvalidDescriptor when slot is not a valid descriptor.

Source

pub fn append_tensor( &mut self, tensor: Tensor, ) -> Result<DescriptorSlot, GroupError>

Append a tensor owner and return its new descriptor slot without copying.

§Errors

Returns GroupError::IndexOverflow when allocation or descriptor indices cannot be represented, or GroupError::InvalidDescriptor when the consumed tensor descriptor is invalid.

Source

pub fn append_group( &mut self, source: AllocationGroup, source_slot: DescriptorSlot, ) -> Result<DescriptorSlot, GroupError>

Append one descriptor and all of its physical owners without copying.

§Errors

Returns GroupError::IndexOverflow when group indices overflow or GroupError::InvalidDescriptor when source_slot is invalid.

Source

pub fn take_tensor( &mut self, slot: DescriptorSlot, ) -> Result<Tensor, GroupError>

Extract one uniquely-owned descriptor while retaining all other group descriptors in place.

This is structural: aliased allocations return a typed error and the group remains unchanged.

§Errors

Returns GroupError::AliasedAllocation for an aliased allocation or GroupError::InvalidDescriptor for an invalid slot; every extraction failure leaves the group unchanged.

Source

pub fn into_tensor( self, slot: DescriptorSlot, ) -> Result<Tensor, (Self, GroupError)>

Consume the group and extract one descriptor as a standalone tensor.

Extraction is structural: it succeeds only when no other descriptor aliases the selected physical allocation. Failure returns the exact unchanged group and typed error without copying.

§Errors

Returns GroupError::AliasedAllocation when another descriptor references the allocation, or GroupError::InvalidDescriptor for an invalid slot. Each extraction failure returns the unchanged group.

Trait Implementations§

Source§

impl Debug for AllocationGroup

Source§

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

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

impl Default for AllocationGroup

Source§

fn default() -> AllocationGroup

Returns the “default value” for a type. 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
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
Source§

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

Source§

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

Source§

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

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.