Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
InferenceEngine::Blob Class Referenceabstract

This class represents a universal container in the Inference Engine. More...

#include <ie_blob.h>

Inheritance diagram for InferenceEngine::Blob:
Inheritance graph
[legend]
Collaboration diagram for InferenceEngine::Blob:
Collaboration graph
[legend]

Public Types

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 ~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...
 
virtual const TensorDescgetTensorDesc () const noexcept
 Returns the tensor description. More...
 
virtual TensorDescgetTensorDesc () noexcept
 Returns the tensor description. More...
 
virtual size_t size () const noexcept
 By default, returns the total number of elements (a product of all the dims or 1 for scalar) More...
 
virtual size_t byteSize () const noexcept
 Returns the size of the current Blob in bytes. More...
 
virtual size_t element_size () const noexcept=0
 Provides the number of bytes per element. More...
 
virtual void allocate () noexcept=0
 Allocates memory to store the data. More...
 
virtual bool deallocate () noexcept=0
 Releases previously allocated data. More...
 
virtual LockedMemory< void > buffer () noexcept=0
 Gets access to the allocated memory. More...
 
virtual LockedMemory< const void > cbuffer () const noexcept=0
 Gets read-only access to the allocated memory. More...
 
virtual Blob::Ptr createROI (const ROI &roi) const
 Creates a blob describing given ROI object based on the current blob with memory sharing. More...
 

Static Public Member Functions

static Ptr CreateFromData (const DataPtr &data)
 Creates a TBlob<> object from a Data node. More...
 

Protected Member Functions

virtual const std::shared_ptr< IAllocator > & getAllocator () const noexcept=0
 Gets an allocator for allocator-based blobs. More...
 
virtual void * getHandle () const noexcept=0
 Gets a handle to allocated memory. More...
 

Static Protected Member Functions

static size_t product (const SizeVector &dims) noexcept
 Multiplies the dimension vector values. More...
 

Protected Attributes

TensorDesc tensorDesc
 The tensor descriptor of the given blob.
 

Friends

template<typename >
class TBlobProxy
 private
 

Detailed Description

This class represents a universal container in the Inference Engine.

Note
Each Blob implementation must be derived from this Blob class directly or indirectly

Constructor & Destructor Documentation

◆ Blob()

InferenceEngine::Blob::Blob ( const TensorDesc tensorDesc)
inlineexplicit

Constructor. Creates an empty Blob object with the specified precision.

Parameters
tensorDescDefines the layout and dims of the blob

Member Function Documentation

◆ allocate()

virtual void InferenceEngine::Blob::allocate ( )
pure virtualnoexcept

Allocates memory to store the data.

Abstract method.

Implemented in InferenceEngine::MemoryBlob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ as() [1/2]

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* InferenceEngine::Blob::as ( ) const
inlinenoexcept

Casts this Blob object to the type const T*.

Use InferenceEngine::as() to operate with shared Blob objects instead of raw pointers

Template Parameters
TType to cast to. Must represent a class derived from the Blob
Returns
Raw pointer to the object of the type const T or nullptr on error

◆ as() [2/2]

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* InferenceEngine::Blob::as ( )
inlinenoexcept

Casts this Blob object to the type T*.

Use InferenceEngine::as() to operate with shared Blob objects instead of raw pointers

Template Parameters
TType to cast to. Must represent a class derived from the Blob
Returns
Raw pointer to the object of the type T or nullptr on error

◆ buffer()

virtual LockedMemory<void> InferenceEngine::Blob::buffer ( )
pure virtualnoexcept

Gets access to the allocated memory.

Deprecated:
Cast to MemoryBlob and use new wlock/rwlock API instead. Blob class can represent compound blob, which do not refer to the only solid memory.

Abstract method.

Returns
A LockedMemory object

Implemented in InferenceEngine::MemoryBlob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ byteSize()

virtual size_t InferenceEngine::Blob::byteSize ( ) const
inlinevirtualnoexcept

Returns the size of the current Blob in bytes.

Returns
Blob's size in bytes

Reimplemented in InferenceEngine::CompoundBlob, and InferenceEngine::MemoryBlob.

◆ cbuffer()

virtual LockedMemory<const void> InferenceEngine::Blob::cbuffer ( ) const
pure virtualnoexcept

Gets read-only access to the allocated memory.

Deprecated:
Cast to MemoryBlob and use new MemoryBlob::rmap() function instead. Blob class can represent compound blob, which do not refer to the only solid memory.

Abstract method.

Returns
A LockedMemory object

Implemented in InferenceEngine::MemoryBlob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ CreateFromData()

static Ptr InferenceEngine::Blob::CreateFromData ( const DataPtr data)
static

Creates a TBlob<> object from a Data node.

Parameters
dataA reference to a smart pointer of the Data node
Returns
Smart pointer to TBlob<> with the relevant C type to the precision of the data node

◆ createROI()

virtual Blob::Ptr InferenceEngine::Blob::createROI ( const ROI roi) const
virtual

Creates a blob describing given ROI object based on the current blob with memory sharing.

Note: default implementation throws "not implemented" exception.

Parameters
roiA ROI object inside of the current blob.
Returns
A shared pointer to the newly created ROI blob.

Reimplemented in InferenceEngine::I420Blob, InferenceEngine::NV12Blob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ deallocate()

virtual bool InferenceEngine::Blob::deallocate ( )
pure virtualnoexcept

Releases previously allocated data.

Abstract method.

Returns
True if deallocation happens successfully, false otherwise.

Implemented in InferenceEngine::MemoryBlob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ element_size()

virtual size_t InferenceEngine::Blob::element_size ( ) const
pure virtualnoexcept

Provides the number of bytes per element.

Deprecated:
Cast to MemoryBlob and use its API instead. Blob class can represent compound blob, which do not refer to the only solid memory.

The overall Blob capacity is size() * element_size(). Abstract method.

Returns
Returns the number of bytes per element

Implemented in InferenceEngine::MemoryBlob, InferenceEngine::RemoteBlob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ getAllocator()

virtual const std::shared_ptr<IAllocator>& InferenceEngine::Blob::getAllocator ( ) const
protectedpure virtualnoexcept

Gets an allocator for allocator-based blobs.

Returns
The allocator for allocator-based blobs or nullptr if there is none

Implemented in InferenceEngine::MemoryBlob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ getHandle()

virtual void* InferenceEngine::Blob::getHandle ( ) const
protectedpure virtualnoexcept

Gets a handle to allocated memory.

Returns
The handle to allocated memory for allocator-based blobs or nullptr if there is none

Implemented in InferenceEngine::MemoryBlob, InferenceEngine::CompoundBlob, and InferenceEngine::TBlob< T, typename >.

◆ getTensorDesc() [1/2]

virtual const TensorDesc& InferenceEngine::Blob::getTensorDesc ( ) const
inlinevirtualnoexcept

Returns the tensor description.

Returns
A const reference to a tensor descriptor

Reimplemented in InferenceEngine::MemoryBlob.

◆ getTensorDesc() [2/2]

virtual TensorDesc& InferenceEngine::Blob::getTensorDesc ( )
inlinevirtualnoexcept

Returns the tensor description.

Returns
A reference to a tensor descriptor

Reimplemented in InferenceEngine::MemoryBlob.

◆ is() [1/2]

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 InferenceEngine::Blob::is ( ) const
inlinenoexcept

Checks if the Blob object can be cast to the type const T*.

Template Parameters
TType to be checked. Must represent a class derived from the Blob
Returns
true if this object can be dynamically cast to the type const T*. Otherwise, false

◆ is() [2/2]

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 InferenceEngine::Blob::is ( )
inlinenoexcept

Checks if the Blob object can be cast to the type T*.

Template Parameters
TType to be checked. Must represent a class derived from the Blob
Returns
true if this object can be dynamically cast to the type T*. Otherwise, false

◆ product()

static size_t InferenceEngine::Blob::product ( const SizeVector dims)
inlinestaticprotectednoexcept

Multiplies the dimension vector values.

Deprecated:
Cast to MemoryBlob and use its API instead.
Parameters
dimsReference to a vector with dimension values of type size_t
Returns
Result of multiplication

◆ size()

virtual size_t InferenceEngine::Blob::size ( ) const
inlinevirtualnoexcept

By default, returns the total number of elements (a product of all the dims or 1 for scalar)

Return value and its interpretation heavily depend on the blob type

Returns
The total number of elements

Reimplemented in InferenceEngine::CompoundBlob, and InferenceEngine::MemoryBlob.


The documentation for this class was generated from the following file: