This class implements a container object that represents a tensor in memory (host and remote/accelerated) More...
#include <ie_blob.h>
Public Types | |
using | Ptr = std::shared_ptr< MemoryBlob > |
A smart pointer to the MemoryBlob object. | |
using | CPtr = std::shared_ptr< const MemoryBlob > |
A smart pointer to the const MemoryBlob object. | |
![]() | |
using | Ptr = std::shared_ptr< Blob > |
A smart pointer containing Blob object. | |
using | CPtr = std::shared_ptr< const Blob > |
A smart pointer to the const Blob object. | |
Public Member Functions | |
virtual | ~MemoryBlob () |
MemoryBlob virtual destructor. | |
MemoryBlob (const TensorDesc &tensorDesc) | |
Constructor. Creates an empty MemoryBlob object with the specified precision. More... | |
const TensorDesc & | getTensorDesc () const noexcept override |
Returns the tensor description. | |
TensorDesc & | getTensorDesc () noexcept override |
Returns the tensor description. | |
size_t | size () const noexcept override |
Returns the total number of elements, which is a product of all the dimensions. | |
size_t | byteSize () const noexcept override |
Returns the size of the current Blob in bytes calculated as size() * element_size() . More... | |
size_t | element_size () const noexcept override=0 |
Provides the number of bytes per element. Abstract method. More... | |
void | allocate () noexcept override=0 |
Allocates memory to store the data. More... | |
bool | deallocate () noexcept override=0 |
Releases previously allocated data. More... | |
LockedMemory< void > | buffer () noexcept override=0 |
Gets access to the allocated memory. More... | |
LockedMemory< const void > | cbuffer () const noexcept override=0 |
Gets read-only access to the allocated memory. More... | |
virtual LockedMemory< void > | rwmap () noexcept=0 |
Gets read/write access to the memory in virtual space of the process. The function returns object which retains mapped memory. The memory been addressed in the MemoryBlob in general case can be allocated on remote device. This function maps remote memory to the memory in the virtual process space and after destruction of the LockedMemory will upload changed content to the accelerator. More... | |
virtual LockedMemory< const void > | rmap () const noexcept=0 |
Gets read only access to the memory in virtual space of the process. The function returns object which retains mapped memory. More... | |
virtual LockedMemory< void > | wmap () noexcept=0 |
Gets "write only direction" access to the memory in virtual space of the process. The function returns object which retains memory to be uploaded on device. More... | |
![]() | |
virtual | ~Blob () |
Blob virtual destructor. | |
template<typename T , typename std::enable_if<!std::is_pointer< T >::value &&!std::is_reference< T >::value, int >::type = 0, typename std::enable_if< std::is_base_of< Blob, T >::value, int >::type = 0> | |
bool | is () noexcept |
Checks if the Blob object can be cast to the type T*. More... | |
template<typename T , typename std::enable_if<!std::is_pointer< T >::value &&!std::is_reference< T >::value, int >::type = 0, typename std::enable_if< std::is_base_of< Blob, T >::value, int >::type = 0> | |
bool | is () const noexcept |
Checks if the Blob object can be cast to the type const T*. More... | |
template<typename T , typename std::enable_if<!std::is_pointer< T >::value &&!std::is_reference< T >::value, int >::type = 0, typename std::enable_if< std::is_base_of< Blob, T >::value, int >::type = 0> | |
T * | as () noexcept |
Casts this Blob object to the type T*. More... | |
template<typename T , typename std::enable_if<!std::is_pointer< T >::value &&!std::is_reference< T >::value, int >::type = 0, typename std::enable_if< std::is_base_of< Blob, T >::value, int >::type = 0> | |
const T * | as () const noexcept |
Casts this Blob object to the type const T*. More... | |
Blob (const TensorDesc &tensorDesc) | |
Constructor. Creates an empty Blob object with the specified precision. More... | |
Protected Member Functions | |
const std::shared_ptr< IAllocator > & | getAllocator () const noexcept override=0 |
Gets the allocator for allocator-based blobs. More... | |
void * | getHandle () const noexcept override=0 |
Gets the handle to allocated memory. More... | |
Friends | |
template<typename > | |
class | TBlobProxy |
Additional Inherited Members | |
![]() | |
static Ptr | CreateFromData (const DataPtr &data) |
Creates a TBlob<> object from a Data node. More... | |
![]() | |
static size_t | product (const SizeVector &dims) noexcept |
Multiplies the dimension vector values. More... | |
![]() | |
TensorDesc | tensorDesc |
The tensor descriptor of the given blob. | |
This class implements a container object that represents a tensor in memory (host and remote/accelerated)
|
inlineexplicit |
Constructor. Creates an empty MemoryBlob object with the specified precision.
tensorDesc | Defines the layout and dims of the blob |
|
overridepure virtualnoexcept |
Allocates memory to store the data.
Abstract method.
Implements InferenceEngine::Blob.
Implemented in InferenceEngine::TBlob< T, typename >.
|
overridepure virtualnoexcept |
Gets access to the allocated memory.
Abstract method.
Implements InferenceEngine::Blob.
Implemented in InferenceEngine::TBlob< T, typename >.
|
inlineoverridevirtualnoexcept |
Returns the size of the current Blob in bytes calculated as size() * element_size()
.
Reimplemented from InferenceEngine::Blob.
|
overridepure virtualnoexcept |
Gets read-only access to the allocated memory.
Abstract method.
Implements InferenceEngine::Blob.
Implemented in InferenceEngine::TBlob< T, typename >.
|
overridepure virtualnoexcept |
Releases previously allocated data.
Abstract method.
True
if deallocation happens successfully, false
otherwise. Implements InferenceEngine::Blob.
Implemented in InferenceEngine::TBlob< T, typename >.
|
overridepure virtualnoexcept |
Provides the number of bytes per element. Abstract method.
Implements InferenceEngine::Blob.
Implemented in InferenceEngine::TBlob< T, typename >, and InferenceEngine::RemoteBlob.
|
overrideprotectedpure virtualnoexcept |
Gets the allocator for allocator-based blobs.
Implements InferenceEngine::Blob.
Implemented in InferenceEngine::TBlob< T, typename >.
|
overrideprotectedpure virtualnoexcept |
Gets the handle to allocated memory.
Implements InferenceEngine::Blob.
Implemented in InferenceEngine::TBlob< T, typename >.
|
pure virtualnoexcept |
Gets read only access to the memory in virtual space of the process. The function returns object which retains mapped memory.
The memory been addressed in the MemoryBlob in general case can be allocated on remote device. This function copies remote memory to the memory in the virtual process space and after destruction of the LockedMemory it will not upload host memory back, bacause it is expected that content is not changed.
To have an ability change content, you can use rwmap() and wmap() functions.
In case of memory originally allocated on the host, this function returns LockedMemory which will transparently refer to original memory address. No extra copy will happen
In general case, pointer received from that LockedMemory becomes invalid just after destruction of LockedMemory instance. Keep Locked memory alive while you need to address memory in the process on the host.
Abstract method.
Implemented in InferenceEngine::TBlob< T, typename >.
|
pure virtualnoexcept |
Gets read/write access to the memory in virtual space of the process. The function returns object which retains mapped memory. The memory been addressed in the MemoryBlob in general case can be allocated on remote device. This function maps remote memory to the memory in the virtual process space and after destruction of the LockedMemory will upload changed content to the accelerator.
To avoid extra copy of data, you can use rmap() and wmap() functions.
In case of memory originally allocated on the host, this function returns LockedMemory which will transparently refer to original memory address. No extra copy will happen
In general case, pointer received from that LockedMemory becomes invalid just after destruction of LockedMemory instance. Keep Locked memory alive while you need to address memory in the process on the host.
Abstract method.
Implemented in InferenceEngine::TBlob< T, typename >.
|
pure virtualnoexcept |
Gets "write only direction" access to the memory in virtual space of the process. The function returns object which retains memory to be uploaded on device.
The memory been addressed in the MemoryBlob in general case can be allocated on remote device. This function does not copy of the content from the device to the memory in the virtual process space, the content of the memory just after calling of this functin is not specified. After destruction of the LockedMemory, content will be upload host memory. In the same time there is no abilities to restrict reading from the memory, you need to care of reading from memory got by wmap(), it might have sence in some cases like filling of content and before uploading to device
To access data stored in the blob, you can use rwmap() and rmap() functions.
In case of memory originally allocated on the host, this function returns LockedMemory which will transparently refer to original memory address. No extra copy will happen
In general case, pointer received from that LockedMemory becomes invalid just after destruction of LockedMemory instance. Keep Locked memory alive while you need to address memory in the process on the host.
Abstract method.
Implemented in InferenceEngine::TBlob< T, typename >.