|
blace.ai
|
#include <raw_memory_object.h>
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, | ||
| ml_core::DeviceEnum | device, | ||
| 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. |
| device | The device the memory is on. |
| 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. |
|
noexcept |
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::DeviceEnum blace::RawMemoryObject::get_device | ( | ) |
Get the memory order.
| ml_core::BlaceHash blace::RawMemoryObject::get_hash | ( | ) | const |
Get the memory hash.
| blace::RawMemoryObjectImpl * blace::RawMemoryObject::get_impl | ( | ) |
Get the pointer to internal implementation. Do not use.
| 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.
| bool blace::RawMemoryObject::is_similar | ( | RawMemoryObject | obj | ) |
Checks if the other object is similar.
| RawMemoryObject & blace::RawMemoryObject::operator= | ( | const RawMemoryObject & | other | ) |
Copy assignment.
| other | The other object. |
|
noexcept |
Move assignment.
| other | The other object. |