Class TensorMemory
Defined in File tensor_memory.hpp
Derived Types
public morpheus::InferenceMemory
(Class InferenceMemory)public morpheus::ResponseMemory
(Class ResponseMemory)
-
class TensorMemory
Container for holding a collection of named
TensorObject
s in astd::map
keyed by name. Base class forInferenceMemory
&ResponseMemory
Subclassed by morpheus::InferenceMemory, morpheus::ResponseMemory
Public Functions
-
TensorMemory(TensorIndex count)
Construct a new Tensor Memory object.
- Parameters
count –
-
TensorMemory(TensorIndex count, TensorMap &&tensors)
Construct a new Tensor Memory object.
- Parameters
count –
tensors –
- virtual ~TensorMemory() = default
-
bool has_tensor(const std::string &name) const
Verify whether the specified tensor name is present in the tensor memory.
- Parameters
- Returns
- Returns
name –
true
false
-
TensorObject &get_tensor(const std::string &name)
Get the tensor object identified by
name
- Parameters
- Throws
- Returns
name –
std::runtime_error – If no tensor matching
name
exists
-
const TensorObject &get_tensor(const std::string &name) const
Get the tensor object identified by
name
- Parameters
- Throws
- Returns
name –
std::runtime_error – If no tensor matching
name
existsconst TensorObject&
-
void set_tensor(const std::string &name, TensorObject &&tensor)
Set the tensor object identified by
name
- Parameters
name –
tensor –
- Throws
std::length_error – If the number of rows in
tensor
does not matchcount
.
-
const TensorMap &get_tensors() const
Get a reference to the internal tensors map.
- Returns
const TensorMap&
-
void set_tensors(TensorMap &&tensors)
Set the tensors object.
- Parameters
- Throws
tensors –
std::length_error – If the number of rows in the
tensors
do not matchcount
.
-
TensorMap copy_tensor_ranges(const std::vector<RangeType> &ranges, TensorIndex num_selected_rows) const
Copy tensor ranges.
- Parameters
ranges –
num_selected_rows –
- Returns
TensorMap
Public Members
- TensorIndex count = {0}
Protected Functions
-
void check_tensor_length(const TensorObject &tensor)
Checks if the number of rows in
tensor
matchescount
- Parameters
- Throws
tensor –
std::length_error – If the number of rows in
tensor
do not matchcount
.
-
void check_tensors_length(const TensorMap &tensors)
Checks each tesnor in
tensors
verifying that the number of rows matches count.- Parameters
- Throws
tensors –
std::length_error – If the number of rows in the
tensors
do not matchcount
.
-
void verify_tensor_exists(const std::string &name) const
Verify that a tensor identified by
name
exists, throws aruntime_error
othwerwise.- Parameters
- Throws
name –
std::runtime_error – If no tensor matching
name
exists
-
TensorMemory(TensorIndex count)