|
NVIDIA DeepStream SDK API Reference
|
6.2 Release
|
Go to the documentation of this file.
19 #ifndef __NVDSINFERSERVER_BATCH_BUFFER_H__
20 #define __NVDSINFERSERVER_BATCH_BUFFER_H__
24 #include <unordered_map>
45 assert(m_Desc.elementSize >= 0);
46 uint32_t b = getBatchSize();
47 return m_Desc.elementSize * m_Desc.dims.numElements * (b ? b : 1);
69 m_Attaches.emplace_back(std::move(buf));
70 assert(!hasAttachLoop());
72 void detach() { m_Attaches.clear(); }
81 std::set<BaseBatchBuffer*> allAttached;
82 for (
auto const& buf : m_Attaches) {
84 if (allAttached.count(buf.get())) {
87 allAttached.emplace(buf.get());
93 uint64_t
bufId()
const {
return m_BufId; }
98 uint32_t m_BatchSize = 0;
100 std::vector<SharedBatchBuf> m_Attaches;
101 uint64_t m_BufId = UINT64_C(0);
113 uint32_t
getSize() const final {
return m_Bufs.size(); }
116 assert(arrayIdx < (uint32_t)m_Bufs.size());
117 assert(m_Bufs.at(arrayIdx).get());
118 return m_Bufs.at(arrayIdx).get();
122 assert(arrayIdx < (uint32_t)m_Bufs.size());
123 assert(m_Bufs.at(arrayIdx).get());
124 return buf(arrayIdx);
129 std::dynamic_pointer_cast<BaseBatchBuffer>(
buf);
137 const std::vector<SharedBatchBuf>&
bufs()
const {
return m_Bufs; }
142 assert(idx < (uint32_t)m_Bufs.size());
143 return m_Bufs.at(idx);
147 assert(idx < (uint32_t)m_Bufs.size());
148 return m_Bufs.at(idx);
154 auto iter = std::find_if(m_Bufs.cbegin(), m_Bufs.cend(),
157 const InferBufferDescription& desc = buf->getBufDesc();
158 if (desc.memType == InferMemType::kGpuCuda) {
166 assert((iter != m_Bufs.cend() && gpuId >= 0) ||
167 (iter == m_Bufs.cend() && gpuId == -1));
172 uint64_t
bufId()
const {
return m_BufId; }
178 std::vector<SharedBatchBuf> m_Bufs;
180 uint64_t m_BufId = UINT64_C(0);
201 assert(batchIdx == 0 || batchIdx < getBatchSize());
203 assert(batchIdx <= 0 || desc.
dataType != InferDataType::kString);
204 batchIdx = std::max(batchIdx, 0U);
205 return (
void*)((uint8_t*)m_BufBase +
212 mutable void* m_BufBase =
nullptr;
213 size_t m_BufBytes = 0;
218 template <
typename BufPtr>
225 return m_Impl->getBufDesc();
228 return m_Impl->getBufPtr(batchIdx);
const SharedBatchBuf & buf(uint32_t idx) const
Copyright (c) 2021, NVIDIA CORPORATION.
uint32_t getBatchSize() const final
uint32_t getSize() const final
~BaseBatchArray() override=default
void setBufId(uint64_t id)
std::shared_ptr< BaseBatchBuffer > SharedBatchBuf
Common buffer interfaces (internal).
const IOptions * getOptions() const final
struct NvBufSurfTransformSyncObj * NvBufSurfTransformSyncObj_t
Holds the information about synchronization objects for asynchronous transform/composite APIs.
std::shared_ptr< IBatchBuffer > SharedIBatchBuffer
Header file for the data types used in the inference processing.
void setBufId(uint64_t id)
NvBufSurfTransform_Error NvBufSurfTransformSyncObjDestroy(NvBufSurfTransformSyncObj_t *sync_obj)
Destroy the synchroization object.
A batch buffer with allocated memory.
const SharedCuEvent & cuEvent() const
RefBatchBuffer(void *bufBase, size_t bufBytes, const InferBufferDescription &desc, uint32_t batchSize)
NvBufSurfTransformSyncObj_t & getSyncObj()
void normalizeDims(InferDims &dims)
void setIOptions(SharedIOptions o) final
const IBatchBuffer * getBuffer(uint32_t arrayIdx) const final
const std::vector< SharedBatchBuf > & attachedBufs() const
uint64_t getTotalBytes() const final
Interface class for a batch buffer.
void setCuEvent(SharedCuEvent e)
virtual void setBatchSize(uint32_t size)
const SharedCuEvent & cuEvent() const
void addBuf(SharedBatchBuf buf)
Header file of the common declarations for the nvinferserver library.
std::vector< SharedBatchBuf > & mutableBufs()
SharedIBatchBuffer getSafeBuf(uint32_t arrayIdx) const final
void setOptions(SharedIOptions o)
const InferBufferDescription & getBufDesc() const final
uint32_t getBatchSize() const final
std::shared_ptr< IOptions > SharedOptions
uint64_t getTotalBytes() const override
WrapCBatchBuffer(BufPtr buf)
void * getBufPtr(uint32_t batchIdx) const final
NvBufSurfTransform_Error NvBufSurfTransformSyncObjWait(NvBufSurfTransformSyncObj_t sync_obj, uint32_t time_out)
Wait on the synchroization object.
uint64_t getTotalBytes() const final
void setSyncObj(NvBufSurfTransformSyncObj_t SyncObj)
std::vector< SharedBatchBuf > & mutableAttachedBufs()
InferDataType dataType
Datatype associated with the buffer.
BaseBatchBuffer(uint32_t batchSize)
bool hasAttachedBufs() const
void * getBufPtr(uint32_t batchIdx) const override
void appendIBatchBuf(SharedIBatchBuffer buf) final
void setBufDesc(const InferBufferDescription &desc)
std::shared_ptr< IOptions > SharedIOptions
The base class for array of batch buffers.
void setCuEvent(SharedCuEvent e)
unsigned int numElements
Number of elements in the layer including all dimensions.
SharedBatchBuf & buf(uint32_t idx)
InferDims dims
Dimensions of the tensor.
SharedIOptions getSafeOptions() const
std::shared_ptr< CudaEvent > SharedCuEvent
The base class for batch buffers.
uint32_t elementSize
Per element bytes, except kString (with elementSize is 0)
void attach(SharedBatchBuf buf)
int findFirstGpuId() const
Interface class for an array of batch buffers.
InferBufferDescription & mutableBufDesc()
bool hasAttachLoop() const
const std::vector< SharedBatchBuf > & bufs() const
Holds the information about a inference buffer.