pub struct HandleContainer<H> { /* private fields */ }Expand description
Keep all tensor handles in one place and ensure that all resources are used optimally.
Implementations§
Source§impl<H: Clone> HandleContainer<H>
impl<H: Clone> HandleContainer<H>
Source§impl<H: Clone> HandleContainer<H>
impl<H: Clone> HandleContainer<H>
Sourcepub 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.
Sourcepub fn has_handle(&mut self, id: &TensorId) -> bool
pub fn has_handle(&mut self, id: &TensorId) -> bool
Whether an handle exists.
Sourcepub fn get_handle_ref(&self, id: &TensorId) -> Option<&H>
pub fn get_handle_ref(&self, id: &TensorId) -> Option<&H>
Get the reference to a handle.
Sourcepub 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.
Sourcepub fn get_tensor_handle(&mut self, tensor: &TensorIr) -> TensorHandle<H>
pub fn get_tensor_handle(&mut self, tensor: &TensorIr) -> TensorHandle<H>
Get the tensor handle for the given tensor intermediate representation.
Sourcepub fn get_float_tensor<B>(
&mut self,
tensor: &TensorIr,
) -> B::FloatTensorPrimitivewhere
B: BackendIr<Handle = H>,
pub fn get_float_tensor<B>(
&mut self,
tensor: &TensorIr,
) -> B::FloatTensorPrimitivewhere
B: BackendIr<Handle = H>,
Get the float tensor corresponding to the given tensor intermediate representation.
Sourcepub fn get_int_tensor<B>(&mut self, tensor: &TensorIr) -> B::IntTensorPrimitivewhere
B: BackendIr<Handle = H>,
pub fn get_int_tensor<B>(&mut self, tensor: &TensorIr) -> B::IntTensorPrimitivewhere
B: BackendIr<Handle = H>,
Get the int tensor corresponding to the given tensor intermediate representation.
Sourcepub fn get_bool_tensor<B>(
&mut self,
tensor: &TensorIr,
) -> B::BoolTensorPrimitivewhere
B: BackendIr<Handle = H>,
pub fn get_bool_tensor<B>(
&mut self,
tensor: &TensorIr,
) -> B::BoolTensorPrimitivewhere
B: BackendIr<Handle = H>,
Get the bool tensor corresponding to the given tensor intermediate representation.
Sourcepub fn get_quantized_tensor<B>(
&mut self,
tensor: &TensorIr,
) -> B::QuantizedTensorPrimitivewhere
B: BackendIr<Handle = H>,
pub fn get_quantized_tensor<B>(
&mut self,
tensor: &TensorIr,
) -> B::QuantizedTensorPrimitivewhere
B: BackendIr<Handle = H>,
Get the quantized tensor corresponding to the given tensor intermediate representation.
Sourcepub fn register_float_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::FloatTensorPrimitive,
)where
B: BackendIr<Handle = H>,
pub fn register_float_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::FloatTensorPrimitive,
)where
B: BackendIr<Handle = H>,
Register a new float tensor with the corresponding tensor id.
Sourcepub fn register_quantized_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::QuantizedTensorPrimitive,
)where
B: BackendIr<Handle = H>,
pub fn register_quantized_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::QuantizedTensorPrimitive,
)where
B: BackendIr<Handle = H>,
Register a new quantized tensor with the corresponding tensor ids.
Sourcepub fn register_int_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::IntTensorPrimitive,
)where
B: BackendIr<Handle = H>,
pub fn register_int_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::IntTensorPrimitive,
)where
B: BackendIr<Handle = H>,
Register a new int tensor with the corresponding tensor id.
Sourcepub fn register_bool_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::BoolTensorPrimitive,
)where
B: BackendIr<Handle = H>,
pub fn register_bool_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::BoolTensorPrimitive,
)where
B: BackendIr<Handle = H>,
Register a new bool tensor with the corresponding tensor id.
Sourcepub fn create_tensor_uninit(&mut self) -> TensorId
pub fn create_tensor_uninit(&mut self) -> TensorId
Lazily create a new empty tensor and return its corresponding tensor id.
Sourcepub fn remove_handle(&mut self, id: TensorId) -> Option<Handle<H>>
pub fn remove_handle(&mut self, id: TensorId) -> Option<Handle<H>>
Remove tensor handle from container.
Sourcepub fn num_handles(&self) -> usize
pub fn num_handles(&self) -> usize
Returns the number of handles.