blace.ai
|
#include <raw_memory_object.h>
Public Member Functions | |
RawMemoryObject (void *data_ptr, ml_core::DataTypeEnum type, ml_core::ColorFormatEnum color_format, std::vector< int64_t > memory_sizes, ml_core::OrderEnum order, ml_core::ValueRangeEnum value_range, std::optional< blace::ml_core::BlaceHash > hash=std::nullopt, bool copy_memory=true) | |
RawMemoryObject (void *data_ptr, blace::RawMemoryMetadata meta_data, bool copy_memory) | |
RawMemoryObject (const RawMemoryObject &other) | |
RawMemoryObject & | operator= (const RawMemoryObject &other) |
RawMemoryObject (RawMemoryObject &&other) | |
RawMemoryObject & | operator= (RawMemoryObject &&other) |
void * | get_data_ptr () const |
std::vector< int64_t > | get_memory_sizes () const |
int | get_memory_size () const |
ml_core::DataTypeEnum | get_type () |
ml_core::ColorFormatEnum | get_color_format () |
ml_core::ValueRangeEnum | get_value_range () |
ml_core::OrderEnum | get_order () |
ml_core::BlaceHash | get_hash () const |
bool | has_ownership () |
RawMemoryMetadata | get_meta_data () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Object to handle graph i/o of custom memory. The class either holds a pointer to externally managed memory (not taking ownership) or it stores a copy of the given memory internally.
blace::RawMemoryObject::RawMemoryObject | ( | void * | data_ptr, |
ml_core::DataTypeEnum | type, | ||
ml_core::ColorFormatEnum | color_format, | ||
std::vector< int64_t > | memory_sizes, | ||
ml_core::OrderEnum | order, | ||
ml_core::ValueRangeEnum | value_range, | ||
std::optional< blace::ml_core::BlaceHash > | hash = std::nullopt , |
||
bool | copy_memory = true |
||
) |
Constructs a RawMemoryObject from a memory pointer and meta data.
data_ptr | The pointer to memory on the cpu. |
type | Datatype of the memory. |
color_format | Color format of the memory. |
memory_sizes | A vector of the memory sizes. Total number of bytes is calculated from this. |
order | The memory order. |
value_range | The value range of the passed in data. See the enum for options. |
hash | Hash of the data stored in memory. Make sure that different data always has different hash values, otherwise caching will return old values. If std::nullopt is passed in, the hash will be computed based on the raw memory (safest, but also slowest option). |
copy_memory | If true, stores a copy of the passed memory. Otherwise the constructed object only keeps a reference and the original data_ptr memory has to be valid when accessed. |
blace::RawMemoryObject::RawMemoryObject | ( | void * | data_ptr, |
blace::RawMemoryMetadata | meta_data, | ||
bool | copy_memory | ||
) |
Constructs a RawMemoryObject from a memory pointer and meta data.
data_ptr | xxx |
meta_data | yyy |
copy_memory | zzz |
blace::RawMemoryObject::RawMemoryObject | ( | const RawMemoryObject & | other | ) |
Copy constructor.
other | The other object. |
blace::RawMemoryObject::RawMemoryObject | ( | RawMemoryObject && | other | ) |
Move constructor.
other | The other object. |
ml_core::ColorFormatEnum blace::RawMemoryObject::get_color_format | ( | ) |
Get the color format.
void * blace::RawMemoryObject::get_data_ptr | ( | ) | const |
Get the stored memory address.
ml_core::BlaceHash blace::RawMemoryObject::get_hash | ( | ) | const |
Get the memory hash.
int blace::RawMemoryObject::get_memory_size | ( | ) | const |
Get the memory size in bytes. Computed from the memory sizes and data type.
std::vector< int64_t > blace::RawMemoryObject::get_memory_sizes | ( | ) | const |
Get the vector of memory sizes. E.g. a blace::ml_core::BCHW blace::ml_core::RGB tensor with sizes 512x512 will return {1,3,512,512}.
RawMemoryMetadata blace::RawMemoryObject::get_meta_data | ( | ) | const |
Get meta data object.
ml_core::OrderEnum blace::RawMemoryObject::get_order | ( | ) |
Get the memory order.
ml_core::DataTypeEnum blace::RawMemoryObject::get_type | ( | ) |
Get the data type.
ml_core::ValueRangeEnum blace::RawMemoryObject::get_value_range | ( | ) |
Get the value range.
bool blace::RawMemoryObject::has_ownership | ( | ) |
Returns if the object has memory ownership or not.
RawMemoryObject & blace::RawMemoryObject::operator= | ( | const RawMemoryObject & | other | ) |
Copy assignment.
other | The other object. |
RawMemoryObject & blace::RawMemoryObject::operator= | ( | RawMemoryObject && | other | ) |
Move assignment.
other | The other object. |
|
inline |
Serializes the object for boost serialization.