TensorRT 8.6.1
|
Application-implemented class for controlling allocation on the GPU. More...
#include <NvInferRuntimeBase.h>
Public Member Functions | |
virtual void * | allocate (uint64_t const size, uint64_t const alignment, AllocatorFlags const flags) noexcept=0 |
virtual TRT_DEPRECATED void | free (void *const memory) noexcept=0 |
virtual | ~IGpuAllocator ()=default |
IGpuAllocator ()=default | |
virtual void * | reallocate (void *, uint64_t, uint64_t) noexcept |
virtual bool | deallocate (void *const memory) noexcept |
Application-implemented class for controlling allocation on the GPU.
|
virtualdefault |
Destructor declared virtual as general good practice for a class with virtual methods. TensorRT never calls the destructor for an IGpuAllocator defined by the application.
|
default |
|
pure virtualnoexcept |
A thread-safe callback implemented by the application to handle acquisition of GPU memory.
size | The size of the memory required. |
alignment | The required alignment of memory. Alignment will be zero or a power of 2 not exceeding the alignment guaranteed by cudaMalloc. Thus this allocator can be safely implemented with cudaMalloc/cudaFree. An alignment value of zero indicates any alignment is acceptable. |
flags | Reserved for future use. In the current release, 0 will be passed. |
If an allocation request of size 0 is made, nullptr should be returned.
If an allocation request cannot be satisfied, nullptr should be returned.
Usage considerations
|
inlinevirtualnoexcept |
A thread-safe callback implemented by the application to handle release of GPU memory.
TensorRT may pass a nullptr to this function if it was previously returned by allocate().
memory | The acquired memory. |
Usage considerations
|
pure virtualnoexcept |
A thread-safe callback implemented by the application to handle release of GPU memory.
TensorRT may pass a nullptr to this function if it was previously returned by allocate().
memory | The acquired memory. |
Usage considerations
|
inlinevirtualnoexcept |
A thread-safe callback implemented by the application to resize an existing allocation.
Only allocations which were allocated with AllocatorFlag::kRESIZABLE will be resized.
Options are one of:
If nullptr is returned, TensorRT will assume that resize() is not implemented, and that the allocation at baseAddr is still valid.
This method is made available for use cases where delegating the resize strategy to the application provides an opportunity to improve memory management. One possible implementation is to allocate a large virtual device buffer and progressively commit physical memory with cuMemMap. CU_MEM_ALLOC_GRANULARITY_RECOMMENDED is suggested in this case.
TensorRT may call realloc to increase the buffer by relatively small amounts.
baseAddr | the address of the original allocation. |
alignment | The alignment used by the original allocation. |
newSize | The new memory size required. |
Usage considerations