NVIDIA DeepStream SDK API Reference

6.4 Release
infer_datatypes.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
19 #ifndef __NVDSINFERSERVER_DATA_TYPES_H__
20 #define __NVDSINFERSERVER_DATA_TYPES_H__
21 
22 #include <infer_defines.h>
23 #include <infer_ioptions.h>
24 #include <nvdsinfer.h>
25 #include <stdarg.h>
26 
27 #include <condition_variable>
28 #include <functional>
29 #include <list>
30 #include <memory>
31 #include <mutex>
32 #include <queue>
33 #include <string>
34 #include <vector>
35 
36 namespace nvdsinferserver {
37 
41 enum class InferTensorOrder : int {
42  kNone = 0,
46  kLinear = 1,
50  kNHWC = 2,
51 };
52 
56 enum class InferMemType : int {
57  kNone = 0,
61  kGpuCuda = 1,
65  kCpu = 2,
69  kCpuCuda = 3,
73  kNvSurface = 5,
77  kNvSurfaceArray = 6,
78 };
79 
83 enum class InferDataType : int {
84  kFp32 = FLOAT, // 0
85  kFp16 = HALF, // 1
86  kInt8 = INT8, // 2
87  kInt32 = INT32, // 3
88  kInt16 = 7,
89  kUint8,
90  kUint16,
91  kUint32,
92  kFp64,
93  kInt64,
94  kUint64,
95  kString, // for text/bytes => str_len(4byte) + str('a\0')
96  kBool,
97  kNone = -1,
98 };
99 
103 enum class InferPostprocessType : int {
107  kDetector = 0,
111  kClassifier = 1,
115  kSegmentation = 2,
119  kTrtIsClassifier = 3,
123  kOther = 100,
124 };
125 
129 enum class InferMediaFormat : int {
131  kRGB = 0,
133  kBGR,
135  kGRAY,
137  kRGBA,
139  kBGRx,
140  kUnknown = -1,
141 };
142 
146 struct InferDims
147 {
149  unsigned int numDims = 0;
151  int d[NVDSINFER_MAX_DIMS] = {0};
153  unsigned int numElements = 0;
154 };
155 
160 {
161  int batchSize = 0;
163 };
164 
176  long int devId;
188  uint32_t elementSize;
192  std::string name;
196  bool isInput;
197 };
198 
199 // Common buffer interface [external]
200 class IBatchBuffer;
201 class IBatchArray;
202 class IOptions;
203 
204 using SharedIBatchBuffer = std::shared_ptr<IBatchBuffer>;
205 using SharedIBatchArray = std::shared_ptr<IBatchArray>;
206 using SharedIOptions = std::shared_ptr<IOptions>;
207 
212 public:
213  IBatchBuffer() = default;
214  virtual ~IBatchBuffer() = default;
215  virtual const InferBufferDescription& getBufDesc() const = 0;
216  virtual void* getBufPtr(uint32_t batchIdx) const = 0;
217  virtual uint32_t getBatchSize() const = 0;
218  virtual uint64_t getTotalBytes() const = 0;
219  virtual size_t getBufOffset(uint32_t batchIdx) const = 0;
220 
221 private:
222  DISABLE_CLASS_COPY(IBatchBuffer);
223 };
224 
228 class IBatchArray {
229 public:
230  IBatchArray() = default;
231  virtual ~IBatchArray() = default;
232  virtual uint32_t getSize() const = 0;
233  virtual const IBatchBuffer* getBuffer(uint32_t arrayIdx) const = 0;
234  virtual const IOptions* getOptions() const = 0;
235 
236  virtual SharedIBatchBuffer getSafeBuf(uint32_t arrayIdx) const = 0;
237 
238  // add values
239  virtual void appendIBatchBuf(SharedIBatchBuffer buf) = 0;
240  virtual void setIOptions(SharedIOptions o) = 0;
241 
242 private:
243  DISABLE_CLASS_COPY(IBatchArray);
244 };
245 
246 } // namespace nvdsinferserver
247 
248 #endif
nvdsinferserver::InferMediaFormat::kBGR
@ kBGR
24-bit interleaved B-G-R
nvdsinferserver
Copyright (c) 2021, NVIDIA CORPORATION.
Definition: infer_custom_process.h:28
nvdsinferserver::InferDataType
InferDataType
Datatype of the tensor buffer.
Definition: infer_datatypes.h:83
nvdsinferserver::InferDataType::kInt32
@ kInt32
nvdsinferserver::InferTensorOrder::kLinear
@ kLinear
NCHW (batch-channels-height-width) tensor order.
nvdsinferserver::InferMediaFormat
InferMediaFormat
Image formats.
Definition: infer_datatypes.h:129
nvdsinferserver::SharedIBatchBuffer
std::shared_ptr< IBatchBuffer > SharedIBatchBuffer
Definition: infer_datatypes.h:204
nvdsinferserver::InferMediaFormat::kBGRx
@ kBGRx
32-bit interleaved B-G-R-x
nvdsinferserver::InferPostprocessType
InferPostprocessType
Inference post processing types.
Definition: infer_datatypes.h:103
nvdsinferserver::InferDataType::kFp64
@ kFp64
nvdsinferserver::IBatchArray::getBuffer
virtual const IBatchBuffer * getBuffer(uint32_t arrayIdx) const =0
nvdsinferserver::IBatchArray::IBatchArray
IBatchArray()=default
nvdsinferserver::IBatchBuffer::IBatchBuffer
IBatchBuffer()=default
nvdsinferserver::InferTensorOrder
InferTensorOrder
The type of tensor order.
Definition: infer_datatypes.h:41
nvdsinferserver::InferDims::numDims
unsigned int numDims
Number of dimensions of the layer.
Definition: infer_datatypes.h:149
infer_defines.h
nvdsinferserver::IBatchBuffer::getBatchSize
virtual uint32_t getBatchSize() const =0
nvdsinferserver::InferPostprocessType::kDetector
@ kDetector
Post processing for object detection.
nvdsinferserver::InferDataType::kUint8
@ kUint8
nvdsinferserver::IBatchArray::getSafeBuf
virtual SharedIBatchBuffer getSafeBuf(uint32_t arrayIdx) const =0
nvdsinferserver::InferMediaFormat::kGRAY
@ kGRAY
8-bit Luma
nvdsinferserver::IBatchBuffer
Interface class for a batch buffer.
Definition: infer_datatypes.h:211
nvdsinferserver::InferDataType::kUint64
@ kUint64
nvdsinferserver::IBatchBuffer::getBufOffset
virtual size_t getBufOffset(uint32_t batchIdx) const =0
nvdsinferserver::InferBufferDescription::memType
InferMemType memType
Memory type of the buffer allocation.
Definition: infer_datatypes.h:172
nvdsinferserver::InferMediaFormat::kRGB
@ kRGB
24-bit interleaved R-G-B
nvdsinferserver::InferDataType::kBool
@ kBool
nvdsinferserver::IBatchArray::getOptions
virtual const IOptions * getOptions() const =0
nvdsinferserver::InferTensorOrder::kNHWC
@ kNHWC
NHWC (batch-height-width-channels) tensor order.
nvdsinferserver::InferBatchDims
Holds full dimensions (including batch size) for a layer.
Definition: infer_datatypes.h:159
nvdsinferserver::InferMediaFormat::kRGBA
@ kRGBA
32-bit interleaved R-G-B-A
nvdsinferserver::InferPostprocessType::kOther
@ kOther
Custom post processing.
FLOAT
@ FLOAT
Specifies FP32 format.
Definition: nvdsinfer.h:75
nvdsinferserver::InferMemType::kGpuCuda
@ kGpuCuda
GPU CUDA memory.
nvdsinferserver::InferDataType::kInt16
@ kInt16
NVDSINFER_MAX_DIMS
#define NVDSINFER_MAX_DIMS
Definition: nvdsinfer.h:39
nvdsinferserver::SharedIBatchArray
std::shared_ptr< IBatchArray > SharedIBatchArray
Definition: infer_datatypes.h:205
HALF
@ HALF
Specifies FP16 format.
Definition: nvdsinfer.h:77
INT32
@ INT32
Specifies INT32 format.
Definition: nvdsinfer.h:81
nvdsinferserver::IBatchBuffer::getBufDesc
virtual const InferBufferDescription & getBufDesc() const =0
INT8
@ INT8
Specifies INT8 format.
Definition: nvdsinfer.h:79
nvdsinferserver::InferBatchDims::dims
InferDims dims
Definition: infer_datatypes.h:162
nvdsinferserver::InferDataType::kFp32
@ kFp32
nvdsinferserver::InferPostprocessType::kClassifier
@ kClassifier
Post processing for object classification.
nvdsinferserver::InferPostprocessType::kTrtIsClassifier
@ kTrtIsClassifier
Post processing using Triton Classifier.
nvdsinferserver::InferMemType::kNvSurface
@ kNvSurface
NVRM surface memory.
nvdsinferserver::InferDataType::kInt64
@ kInt64
nvdsinferserver::InferDims::d
int d[NVDSINFER_MAX_DIMS]
Size of the layer in each dimension.
Definition: infer_datatypes.h:151
nvdsinferserver::InferBatchDims::batchSize
int batchSize
Definition: infer_datatypes.h:161
nvdsinferserver::InferBufferDescription::dataType
InferDataType dataType
Datatype associated with the buffer.
Definition: infer_datatypes.h:180
nvdsinferserver::InferTensorOrder::kNone
@ kNone
nvdsinferserver::InferDataType::kFp16
@ kFp16
nvdsinfer.h
nvdsinferserver::IOptions
Definition: infer_ioptions.h:57
nvdsinferserver::InferMemType
InferMemType
The memory types of inference buffers.
Definition: infer_datatypes.h:56
nvdsinferserver::InferDims
Holds the information about the dimensions of a neural network layer.
Definition: infer_datatypes.h:146
nvdsinferserver::SharedIOptions
std::shared_ptr< IOptions > SharedIOptions
Definition: infer_datatypes.h:206
nvdsinferserver::InferBufferDescription::isInput
bool isInput
Boolean indicating input or output buffer.
Definition: infer_datatypes.h:196
nvdsinferserver::IBatchBuffer::~IBatchBuffer
virtual ~IBatchBuffer()=default
nvdsinferserver::InferMemType::kNvSurfaceArray
@ kNvSurfaceArray
NVRM surface array memory.
nvdsinferserver::InferDataType::kNone
@ kNone
nvdsinferserver::InferDataType::kUint32
@ kUint32
nvdsinferserver::InferDims::numElements
unsigned int numElements
Number of elements in the layer including all dimensions.
Definition: infer_datatypes.h:153
nvdsinferserver::InferBufferDescription::dims
InferDims dims
Dimensions of the tensor.
Definition: infer_datatypes.h:184
nvdsinferserver::IBatchArray::appendIBatchBuf
virtual void appendIBatchBuf(SharedIBatchBuffer buf)=0
nvdsinferserver::InferDataType::kUint16
@ kUint16
nvdsinferserver::IBatchBuffer::getTotalBytes
virtual uint64_t getTotalBytes() const =0
nvdsinferserver::InferMemType::kCpu
@ kCpu
Host (CPU) memory.
nvdsinferserver::InferBufferDescription::elementSize
uint32_t elementSize
Per element bytes, except kString (with elementSize is 0)
Definition: infer_datatypes.h:188
nvdsinferserver::InferPostprocessType::kSegmentation
@ kSegmentation
Post processing for image segmentation.
nvdsinferserver::IBatchBuffer::getBufPtr
virtual void * getBufPtr(uint32_t batchIdx) const =0
nvdsinferserver::IBatchArray
Interface class for an array of batch buffers.
Definition: infer_datatypes.h:228
nvdsinferserver::InferDataType::kInt8
@ kInt8
nvdsinferserver::InferDataType::kString
@ kString
nvdsinferserver::IBatchArray::~IBatchArray
virtual ~IBatchArray()=default
nvdsinferserver::IBatchArray::setIOptions
virtual void setIOptions(SharedIOptions o)=0
nvdsinferserver::InferMemType::kCpuCuda
@ kCpuCuda
CUDA pinned memory.
nvdsinferserver::IBatchArray::getSize
virtual uint32_t getSize() const =0
nvdsinferserver::InferBufferDescription::devId
long int devId
Device (GPU) ID where the buffer is allocated.
Definition: infer_datatypes.h:176
nvdsinferserver::InferMediaFormat::kUnknown
@ kUnknown
nvdsinferserver::InferMemType::kNone
@ kNone
infer_ioptions.h
nvdsinferserver::InferBufferDescription::name
std::string name
Name of the buffer.
Definition: infer_datatypes.h:192
nvdsinferserver::InferBufferDescription
Holds the information about a inference buffer.
Definition: infer_datatypes.h:168