23 class LockedMemoryBase {
24 IAllocator* _allocator =
nullptr;
25 void* _handle =
nullptr;
26 mutable T* _locked =
nullptr;
46 LockedMemoryBase(IAllocator* ptr,
void* handle,
LockOp lockFlag,
size_t offsetInBytes)
47 : _allocator(ptr), _handle(handle), _lockFlag(lockFlag), _offset(offsetInBytes) {}
54 LockedMemoryBase(LockedMemoryBase&& that)
55 : _allocator(that._allocator), _handle(that._handle), _lockFlag(that._lockFlag), _offset(that._offset) {
56 that._locked =
nullptr;
62 virtual ~LockedMemoryBase() {
63 if (_locked !=
nullptr) {
64 _allocator->unlock(_handle);
75 bool isEqualTo(
const T* pointer)
const {
76 if (pointer ==
nullptr && (_allocator ==
nullptr || _handle ==
nullptr)) {
79 return dereference() == pointer;
89 virtual T* dereference()
const {
90 if (_locked !=
nullptr)
return _locked;
92 if (_allocator ==
nullptr) {
96 if (_handle ==
nullptr) {
100 uint8_t* pBytes =
reinterpret_cast<uint8_t*
>(_allocator->lock(_handle, _lockFlag));
102 return _locked =
reinterpret_cast<T*
>(pBytes + _offset);
112 using base = details::LockedMemoryBase<T>;
155 return base::dereference();
164 operator const T*()
const {
165 return base::dereference();
175 return base::isEqualTo(pointer);
184 return lm.operator==(pointer);
195 template <class S, typename = std::enable_if<std::is_pointer<S>::value>>
197 return reinterpret_cast<S
>(base::dereference());
208 template <class S, typename = std::enable_if<std::is_pointer<S>::value>>
210 return reinterpret_cast<S
>(base::dereference());
219 using base = details::LockedMemoryBase<void>;
264 return reinterpret_cast<S*
>(base::dereference());
274 return base::isEqualTo(pointer);
283 return lm.operator==(pointer);
294 template <class S, typename = std::enable_if<std::is_pointer<S>::value>>
296 return reinterpret_cast<S
>(dereference());
307 template <class S, typename = std::enable_if<std::is_pointer<S>::value>>
309 return reinterpret_cast<S
>(dereference());
318 using base = details::LockedMemoryBase<T>;
359 operator const T*()
const {
360 return base::dereference();
370 return base::isEqualTo(pointer);
379 return lm.operator==(pointer);
390 template <class S, typename = std::enable_if<std::is_pointer<S>::value && std::is_const<S>::value>>
392 return reinterpret_cast<S
>(base::dereference());
LockedMemory(IAllocator *ptr, void *handle, size_t offsetInBytes=0)
A constructor.
Definition: ie_locked_memory.hpp:122
This class represents locked memory for read/write memory.
Definition: ie_locked_memory.hpp:111
LockOp
Allocator handle mapping type.
Definition: ie_allocator.hpp:21
std::vector< int > offset
A vector of offsets for each dimension.
Definition: ie_layers.h:1256
Inference Engine API.
Definition: ie_argmax_layer.hpp:15
friend bool operator==(const T *pointer, const LockedMemory< const T > &lm)
Compares the object with the one stored in the memory.
Definition: ie_locked_memory.hpp:378
bool operator==(const T *pointer) const
Compares stored object with the given one.
Definition: ie_locked_memory.hpp:368
friend bool operator==(const T *pointer, const LockedMemory< T > &lm)
Compares the object with the one stored in the memory.
Definition: ie_locked_memory.hpp:183
bool operator==(const void *pointer) const
Compares stored object with the given one.
Definition: ie_locked_memory.hpp:272
S as()
Casts stored object to any provided type.
Definition: ie_locked_memory.hpp:196
LockedMemory(LockedMemory< void > &&that, size_t offset)
A default copy constructor that accepts rvalue.
Definition: ie_locked_memory.hpp:245
This class is for <void*> data and allows casting to any pointers.
Definition: ie_locked_memory.hpp:218
S as() const
Casts stored object to any given type.
Definition: ie_locked_memory.hpp:391
This class is for read-only segments.
Definition: ie_locked_memory.hpp:317
LockedMemory(IAllocator *ptr, void *handle, size_t offset)
A constructor.
Definition: ie_locked_memory.hpp:328
const S as() const
Casts stored object to any given type.
Definition: ie_locked_memory.hpp:308
A header file that provides Allocator interface.
S as()
Casts stored object to any given type.
Definition: ie_locked_memory.hpp:295
LockedMemory(IAllocator *ptr, void *handle, size_t offsetInBytes)
A constructor.
Definition: ie_locked_memory.hpp:229
A flag to lock data for write.
Definition: ie_allocator.hpp:23
bool operator==(const T *pointer) const
Compares stored object with the given one.
Definition: ie_locked_memory.hpp:173
friend bool operator==(const void *pointer, const LockedMemory< void > &lm)
Compares the object with the one stored in the memory.
Definition: ie_locked_memory.hpp:282
Allocator concept to be used for memory management and is used as part of the Blob.
Definition: ie_allocator.hpp:30
LockedMemory(LockedMemory< T > &&that, size_t offset)
A default copy constructor that accepts rvalue.
Definition: ie_locked_memory.hpp:138
const S as() const
Casts stored object to any provided type.
Definition: ie_locked_memory.hpp:209
LockedMemory(LockedMemory< const T > &&that, size_t offset)
A default copy constructor that accepts rvalue.
Definition: ie_locked_memory.hpp:343
A flag to lock data for read.
Definition: ie_allocator.hpp:22