The GenericBuffer class is a templated class for buffers. More...
Public Member Functions | |
GenericBuffer (nvinfer1::DataType type=nvinfer1::DataType::kFLOAT) | |
Construct an empty buffer. More... | |
GenericBuffer (size_t size, nvinfer1::DataType type) | |
Construct a buffer with the specified allocation size in bytes. More... | |
GenericBuffer (GenericBuffer &&buf) | |
GenericBuffer & | operator= (GenericBuffer &&buf) |
void * | data () |
Returns pointer to underlying array. More... | |
const void * | data () const |
Returns pointer to underlying array. More... | |
size_t | size () const |
Returns the size (in number of elements) of the buffer. More... | |
size_t | nbBytes () const |
Returns the size (in bytes) of the buffer. More... | |
void | resize (size_t newSize) |
Resizes the buffer. More... | |
void | resize (const nvinfer1::Dims &dims) |
Overload of resize that accepts Dims. More... | |
~GenericBuffer () | |
Private Attributes | |
size_t | mSize {0} |
size_t | mCapacity {0} |
nvinfer1::DataType | mType |
void * | mBuffer |
AllocFunc | allocFn |
FreeFunc | freeFn |
The GenericBuffer class is a templated class for buffers.
This templated RAII (Resource Acquisition Is Initialization) class handles the allocation, deallocation, querying of buffers on both the device and the host. It can handle data of arbitrary types because it stores byte buffers. The template parameters AllocFunc and FreeFunc are used for the allocation and deallocation of the buffer. AllocFunc must be a functor that takes in (void** ptr, size_t size) and returns bool. ptr is a pointer to where the allocated buffer address should be stored. size is the amount of memory in bytes to allocate. The boolean indicates whether or not the memory allocation was successful. FreeFunc must be a functor that takes in (void* ptr) and returns void. ptr is the allocated buffer address. It must work with nullptr input.
|
inline |
Construct an empty buffer.
|
inline |
Construct a buffer with the specified allocation size in bytes.
|
inline |
|
inline |
|
inline |
|
inline |
Returns pointer to underlying array.
|
inline |
Returns pointer to underlying array.
|
inline |
Returns the size (in number of elements) of the buffer.
|
inline |
Returns the size (in bytes) of the buffer.
|
inline |
Resizes the buffer.
This is a no-op if the new size is smaller than or equal to the current capacity.
|
inline |
Overload of resize that accepts Dims.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |