Struct burn::tensor::repr::HandleContainer

pub struct HandleContainer<H> {
    pub handles_orphan: Vec<TensorId>,
    /* private fields */
}
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§

§

impl<H> HandleContainer<H>
where H: Clone,

pub fn new() -> HandleContainer<H>

Create a new HandleContainer

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

Register a handle for the given tensor id.

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.

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

Get the tensor handle for the given tensor description.

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

Get the float tensor corresponding to the given tensor description.

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

Get the int tensor corresponding to the given tensor description.

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

Get the bool tensor corresponding to the given tensor description.

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

Get the quantized tensor corresponding to the given tensor description.

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

Register a new float tensor with the corresponding tensor id.

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

Register a new quantized tensor with the corresponding tensor ids.

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

Register a new int tensor with the corresponding tensor id.

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

Register a new bool tensor with the corresponding tensor id.

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

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

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

Remove tensor handle from container if writable

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

Remove tensor handle from container if not in use

Trait Implementations§

§

impl<H> Debug for HandleContainer<H>

§

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

Formats the value using the given formatter. Read more
§

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

§

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§

§

impl<T> Adaptor<()> for T

§

fn adapt(&self)

Adapt the type to be passed to a metric.
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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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