burn_tensor::repr

Struct HandleContainer

Source
pub struct HandleContainer<H> {
    pub handles_orphan: Vec<TensorId>,
    /* private fields */
}
Available on crate feature repr only.
Expand description

Keep all tensor handles in one place and ensure that all resources are used optimally.

Fields§

§handles_orphan: Vec<TensorId>

Handle candidates to be freed.

Implementations§

Source§

impl<H: Clone> HandleContainer<H>

Source

pub fn new() -> Self

Create a new HandleContainer

Source

pub fn register_handle(&mut self, id: TensorId, handle: H)

Register a handle for the given tensor id.

Source

pub fn get_handle(&mut self, id: &TensorId, status: &TensorStatus) -> H

Get the handle for the given tensor id. The status is used to determine if the tensor should be popped out of the current tensor map, necessary for inplace operations.

§Warnings

Make sure the status corresponds to the operation you want to execute the handle on, otherwise you might remove a tensor handle that will be required in the future.

Source

pub fn get_tensor_handle( &mut self, tensor: &TensorDescription, ) -> TensorHandle<H>

Get the tensor handle for the given tensor description.

Source

pub fn get_float_tensor<B>( &mut self, tensor: &TensorDescription, ) -> B::FloatTensorPrimitive
where B: ReprBackend<Handle = H>,

Get the float tensor corresponding to the given tensor description.

Source

pub fn get_int_tensor<B>( &mut self, tensor: &TensorDescription, ) -> B::IntTensorPrimitive
where B: ReprBackend<Handle = H>,

Get the int tensor corresponding to the given tensor description.

Source

pub fn get_bool_tensor<B>( &mut self, tensor: &TensorDescription, ) -> B::BoolTensorPrimitive
where B: ReprBackend<Handle = H>,

Get the bool tensor corresponding to the given tensor description.

Source

pub fn get_quantized_tensor<B>( &mut self, tensor: &QuantizedTensorDescription, ) -> B::QuantizedTensorPrimitive
where B: ReprBackend<Handle = H>,

Get the quantized tensor corresponding to the given tensor description.

Source

pub fn register_float_tensor<B>( &mut self, id: &TensorId, tensor: B::FloatTensorPrimitive, )
where B: ReprBackend<Handle = H>,

Register a new float tensor with the corresponding tensor id.

Source

pub fn register_quantized_tensor<B>( &mut self, id: &QuantizedKind<TensorId>, tensor: B::QuantizedTensorPrimitive, )
where B: ReprBackend<Handle = H>,

Register a new quantized tensor with the corresponding tensor ids.

Source

pub fn register_int_tensor<B>( &mut self, id: &TensorId, tensor: B::IntTensorPrimitive, )
where B: ReprBackend<Handle = H>,

Register a new int tensor with the corresponding tensor id.

Source

pub fn register_bool_tensor<B>( &mut self, id: &TensorId, tensor: B::BoolTensorPrimitive, )
where B: ReprBackend<Handle = H>,

Register a new bool tensor with the corresponding tensor id.

Source

pub fn create_tensor_uninit(&mut self) -> Arc<TensorId>

Lazily create a new empty tensor and return its corresponding tensor id.

Source

pub fn free(&mut self, tensor: &TensorDescription)

Remove tensor handle from container if writable

Source

pub fn free_orphans(&mut self, remaining: &[&TensorId])

Remove tensor handle from container if not in use

Trait Implementations§

Source§

impl<H> Debug for HandleContainer<H>

Source§

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

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

impl<H: Default> Default for HandleContainer<H>

Source§

fn default() -> HandleContainer<H>

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

Auto Trait Implementations§

§

impl<H> Freeze for HandleContainer<H>

§

impl<H> RefUnwindSafe for HandleContainer<H>
where H: RefUnwindSafe,

§

impl<H> Send for HandleContainer<H>
where H: Send,

§

impl<H> Sync for HandleContainer<H>
where H: Sync,

§

impl<H> Unpin for HandleContainer<H>
where H: Unpin,

§

impl<H> UnwindSafe for HandleContainer<H>
where H: UnwindSafe,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V