pub struct HandleContainer<H> {
pub handles_orphan: Vec<TensorId>,
/* private fields */
}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>
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 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: &TensorDescription,
) -> TensorHandle<H>
pub fn get_tensor_handle( &mut self, tensor: &TensorDescription, ) -> TensorHandle<H>
Get the tensor handle for the given tensor description.
Sourcepub fn get_float_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> B::FloatTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_float_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> B::FloatTensorPrimitivewhere
B: ReprBackend<Handle = H>,
Get the float tensor corresponding to the given tensor description.
Sourcepub fn get_int_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> B::IntTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_int_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> B::IntTensorPrimitivewhere
B: ReprBackend<Handle = H>,
Get the int tensor corresponding to the given tensor description.
Sourcepub fn get_bool_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> B::BoolTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_bool_tensor<B>(
&mut self,
tensor: &TensorDescription,
) -> B::BoolTensorPrimitivewhere
B: ReprBackend<Handle = H>,
Get the bool tensor corresponding to the given tensor description.
Sourcepub fn get_quantized_tensor<B>(
&mut self,
tensor: &QuantizedTensorDescription,
) -> B::QuantizedTensorPrimitivewhere
B: ReprBackend<Handle = H>,
pub fn get_quantized_tensor<B>(
&mut self,
tensor: &QuantizedTensorDescription,
) -> B::QuantizedTensorPrimitivewhere
B: ReprBackend<Handle = H>,
Get the quantized tensor corresponding to the given tensor description.
Sourcepub fn register_float_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::FloatTensorPrimitive,
)where
B: ReprBackend<Handle = H>,
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.
Sourcepub fn register_quantized_tensor<B>(
&mut self,
id: &QuantizedKind<TensorId>,
tensor: B::QuantizedTensorPrimitive,
)where
B: ReprBackend<Handle = H>,
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.
Sourcepub fn register_int_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::IntTensorPrimitive,
)where
B: ReprBackend<Handle = H>,
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.
Sourcepub fn register_bool_tensor<B>(
&mut self,
id: &TensorId,
tensor: B::BoolTensorPrimitive,
)where
B: ReprBackend<Handle = H>,
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.
Sourcepub 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.
Sourcepub fn free(&mut self, tensor: &TensorDescription)
pub fn free(&mut self, tensor: &TensorDescription)
Remove tensor handle from container if writable
Sourcepub fn free_orphans(&mut self, remaining: &[&TensorId])
pub fn free_orphans(&mut self, remaining: &[&TensorId])
Remove tensor handle from container if not in use