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,
impl<H> HandleContainer<H>where
H: Clone,
pub fn new() -> HandleContainer<H>
pub fn new() -> HandleContainer<H>
Create a new HandleContainer
pub fn register_handle(&mut self, id: TensorId, handle: H)
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
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>
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>::FloatTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_float_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> <B as Backend>::FloatTensorPrimitivewhere
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>::IntTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_int_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> <B as Backend>::IntTensorPrimitivewhere
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>::BoolTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_bool_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> <B as Backend>::BoolTensorPrimitivewhere
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>::QuantizedTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_quantized_tensor<B>(
&mut self,
tensor: &QuantizedTensorDescription,
) -> <B as Backend>::QuantizedTensorPrimitivewhere
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>,
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>,
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>,
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>,
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>
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)
pub fn free(&mut self, tensor: &TensorDescription)
Remove tensor handle from container if writable
pub fn free_orphans(&mut self, remaining: &[&TensorId])
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>
impl<H> Debug for HandleContainer<H>
§impl<H> Default for HandleContainer<H>where
H: Default,
impl<H> Default for HandleContainer<H>where
H: Default,
§fn default() -> HandleContainer<H>
fn default() -> HandleContainer<H>
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> 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.