ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::core::Blob Class Reference

#include <Blob.h>

Collaboration diagram for cloudViewer::core::Blob:

Public Member Functions

 Blob (int64_t byte_size, const Device &device)
 
 Blob (const Device &device, void *data_ptr, const std::function< void(void *)> &deleter)
 
 ~Blob ()
 
Device GetDevice () const
 
void * GetDataPtr ()
 
const void * GetDataPtr () const
 

Protected Attributes

std::function< void(void *)> deleter_ = nullptr
 For externally managed memory, deleter != nullptr. More...
 
void * data_ptr_ = nullptr
 Device data pointer. More...
 
Device device_
 Device context for the blob. More...
 

Detailed Description

Blob class refers to a blob of memory in device or host.

Usually a Blob is constructed by specifying the blob size and device, memory allocation happens during the Blob's construction.

A Blob's buffer can also be managed by an external memory manager. In this case, a deleter function is needed to notify the external memory manager that the memory is no longer needed. It does not make sense to infer the total buffer size. For example, if a Tensor has a negative stride size, it is necessary to access memory addresses smaller than Blob's beginning memory address. The only responsibility for Blob is to hold the beginning memory address and it's up to the user to access any addresses around it.

In summary:

  • A Blob does not know about its memory size after construction.
  • A Blob cannot be deep-copied. However, the Tensor which owns the blob can be copied.

Definition at line 38 of file Blob.h.

Constructor & Destructor Documentation

◆ Blob() [1/2]

cloudViewer::core::Blob::Blob ( int64_t  byte_size,
const Device device 
)
inline

Construct Blob on a specified device.

Parameters
byte_sizeSize of the blob in bytes.
deviceDevice where the blob resides.

Definition at line 44 of file Blob.h.

◆ Blob() [2/2]

cloudViewer::core::Blob::Blob ( const Device device,
void *  data_ptr,
const std::function< void(void *)> &  deleter 
)
inline

Construct Blob with externally managed memory.

Parameters
deviceDevice where the blob resides.
data_ptrPointer the blob's beginning.
deleterThe deleter function is called at Blob's destruction to notify the external memory manager that the memory is no longer needed. It's up to the external manager to free the memory.

Definition at line 56 of file Blob.h.

◆ ~Blob()

cloudViewer::core::Blob::~Blob ( )
inline

Definition at line 61 of file Blob.h.

References data_ptr_, deleter_, device_, and cloudViewer::core::MemoryManager::Free().

Member Function Documentation

◆ GetDataPtr() [1/2]

◆ GetDataPtr() [2/2]

const void* cloudViewer::core::Blob::GetDataPtr ( ) const
inline

Definition at line 77 of file Blob.h.

References data_ptr_.

◆ GetDevice()

Device cloudViewer::core::Blob::GetDevice ( ) const
inline

Definition at line 73 of file Blob.h.

References device_.

Member Data Documentation

◆ data_ptr_

void* cloudViewer::core::Blob::data_ptr_ = nullptr
protected

Device data pointer.

Definition at line 84 of file Blob.h.

Referenced by GetDataPtr(), and ~Blob().

◆ deleter_

std::function<void(void*)> cloudViewer::core::Blob::deleter_ = nullptr
protected

For externally managed memory, deleter != nullptr.

Definition at line 81 of file Blob.h.

Referenced by ~Blob().

◆ device_

Device cloudViewer::core::Blob::device_
protected

Device context for the blob.

Definition at line 87 of file Blob.h.

Referenced by GetDevice(), and ~Blob().


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