morpheus.messages.memory.tensor_memory.TensorMemory#
- class TensorMemory(**kwargs)[source]#
Bases:
MessageDataThis is a base container class for data that will be used for inference stages. This class is designed to hold generic tensor data in either CuPy or NumPy arrays.
- Parameters:
- countint
Length of each tensor contained in
tensors.- tensorsTensorMapType
Collection of tensors uniquely identified by a name.
- Attributes:
- tensor_names
Methods
get_tensor(name)Get the Tensor stored in the container identified by
name.Get the tensors contained by this instance.
has_tensor(name)Returns True if a tensor with the requested name exists in the tensors object
set_tensor(name, tensor)Update the tensor identified by
name.set_tensors(tensors)Overwrite the tensors stored by this instance.
- get_tensor(name)[source]#
Get the Tensor stored in the container identified by
name.- Parameters:
- namestr
Tensor key name.
- Returns:
- NDArrayType
Tensor.
- Raises:
- KeyError
If tensor name does not exist in the container.
- get_tensors()[source]#
Get the tensors contained by this instance. It is important to note that when C++ execution is enabled the returned tensors will be a Python copy of the tensors stored in the C++ object. As such any changes made to the tensors will need to be updated with a call to
set_tensors.- Returns:
- TensorMapType
- has_tensor(name)[source]#
Returns True if a tensor with the requested name exists in the tensors object
- Parameters:
- namestr
Name to lookup
- Returns:
- bool
True if the tensor was found