NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/includes/nvdsinferserver/infer_datatypes.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
24 #ifndef __NVDSINFERSERVER_DATA_TYPES_H__
25 #define __NVDSINFERSERVER_DATA_TYPES_H__
26 
27 #include <infer_defines.h>
28 #include <infer_ioptions.h>
29 #include <nvdsinfer.h>
30 #include <stdarg.h>
31 
32 #include <condition_variable>
33 #include <functional>
34 #include <list>
35 #include <memory>
36 #include <mutex>
37 #include <queue>
38 #include <string>
39 #include <vector>
40 
41 namespace nvdsinferserver {
42 
46 enum class InferTensorOrder : int {
47  kNone = 0,
51  kLinear = 1,
55  kNHWC = 2,
56 };
57 
61 enum class InferMemType : int {
62  kNone = 0,
66  kGpuCuda = 1,
70  kCpu = 2,
74  kCpuCuda = 3,
78  kNvSurface = 5,
82  kNvSurfaceArray = 6,
83 };
84 
88 enum class InferDataType : int {
89  kFp32 = FLOAT, // 0
90  kFp16 = HALF, // 1
91  kInt8 = INT8, // 2
92  kInt32 = INT32, // 3
93  kInt16 = 7,
94  kUint8,
95  kUint16,
96  kUint32,
97  kFp64,
98  kInt64,
99  kUint64,
100  kString, // for text/bytes => str_len(4byte) + str('a\0')
101  kBool,
102  kNone = -1,
103 };
104 
108 enum class InferPostprocessType : int {
112  kDetector = 0,
116  kClassifier = 1,
120  kSegmentation = 2,
124  kTrtIsClassifier = 3,
128  kOther = 100,
129 };
130 
134 enum class InferMediaFormat : int {
136  kRGB = 0,
138  kBGR,
140  kGRAY,
142  kRGBA,
144  kBGRx,
145  kUnknown = -1,
146 };
147 
151 struct InferDims
152 {
154  unsigned int numDims = 0;
156  int d[NVDSINFER_MAX_DIMS] = {0};
158  unsigned int numElements = 0;
159 };
160 
164 struct InferBatchDims
165 {
166  int batchSize = 0;
167  InferDims dims;
168 };
169 
173 struct InferBufferDescription {
181  long int devId;
189  InferDims dims;
193  uint32_t elementSize;
197  std::string name;
201  bool isInput;
202 };
203 
204 // Common buffer interface [external]
205 class IBatchBuffer;
206 class IBatchArray;
207 class IOptions;
208 
209 using SharedIBatchBuffer = std::shared_ptr<IBatchBuffer>;
210 using SharedIBatchArray = std::shared_ptr<IBatchArray>;
211 using SharedIOptions = std::shared_ptr<IOptions>;
212 
216 class IBatchBuffer {
217 public:
218  IBatchBuffer() = default;
219  virtual ~IBatchBuffer() = default;
220  virtual const InferBufferDescription& getBufDesc() const = 0;
221  virtual void* getBufPtr(uint32_t batchIdx) const = 0;
222  virtual uint32_t getBatchSize() const = 0;
223  virtual uint64_t getTotalBytes() const = 0;
224  virtual size_t getBufOffset(uint32_t batchIdx) const = 0;
225 
226 private:
227  DISABLE_CLASS_COPY(IBatchBuffer);
228 };
229 
233 class IBatchArray {
234 public:
235  IBatchArray() = default;
236  virtual ~IBatchArray() = default;
237  virtual uint32_t getSize() const = 0;
238  virtual const IBatchBuffer* getBuffer(uint32_t arrayIdx) const = 0;
239  virtual const IOptions* getOptions() const = 0;
240 
241  virtual SharedIBatchBuffer getSafeBuf(uint32_t arrayIdx) const = 0;
242 
243  // add values
244  virtual void appendIBatchBuf(SharedIBatchBuffer buf) = 0;
245  virtual void setIOptions(SharedIOptions o) = 0;
246 
247 private:
248  DISABLE_CLASS_COPY(IBatchArray);
249 };
250 
251 } // namespace nvdsinferserver
252 
253 #endif
nvdsinferserver::InferMediaFormat::kBGR
@ kBGR
24-bit interleaved B-G-R
nvdsinferserver
This is a header file for pre-processing cuda kernels with normalization and mean subtraction require...
Definition: sources/gst-plugins/gst-nvinferserver/gstnvinferserver_impl.h:69
nvdsinferserver::InferDataType
InferDataType
Datatype of the tensor buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:88
nvdsinferserver::InferDataType::kInt32
@ kInt32
nvdsinferserver::InferTensorOrder::kLinear
@ kLinear
NCHW (batch-channels-height-width) tensor order.
nvdsinferserver::InferMediaFormat
InferMediaFormat
Image formats.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:134
nvdsinferserver::InferMediaFormat::kBGRx
@ kBGRx
32-bit interleaved B-G-R-x
nvdsinferserver::InferPostprocessType
InferPostprocessType
Inference post processing types.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:108
nvdsinferserver::SharedIOptions
std::shared_ptr< IOptions > SharedIOptions
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:211
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: sources/includes/nvdsinferserver/infer_datatypes.h:46
nvdsinferserver::InferDims::numDims
unsigned int numDims
Number of dimensions of the layer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:154
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::InferDataType::kUint64
@ kUint64
nvdsinferserver::IBatchBuffer::getBufOffset
virtual size_t getBufOffset(uint32_t batchIdx) const =0
nvdsinferserver::InferDims::d
int d[NVDSINFER_MAX_DIMS]
Size of the layer in each dimension.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:156
nvdsinferserver::InferBufferDescription::memType
InferMemType memType
Memory type of the buffer allocation.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:177
infer_ioptions.h
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::InferMediaFormat::kRGBA
@ kRGBA
32-bit interleaved R-G-B-A
nvdsinferserver::InferPostprocessType::kOther
@ kOther
Custom post processing.
FLOAT
@ FLOAT
Specifies FP32 format.
Definition: sources/includes/nvdsinfer.h:80
nvdsinferserver::InferMemType::kGpuCuda
@ kGpuCuda
GPU CUDA memory.
nvdsinferserver::InferDataType::kInt16
@ kInt16
NVDSINFER_MAX_DIMS
#define NVDSINFER_MAX_DIMS
Definition: sources/includes/nvdsinfer.h:44
infer_defines.h
HALF
@ HALF
Specifies FP16 format.
Definition: sources/includes/nvdsinfer.h:82
INT32
@ INT32
Specifies INT32 format.
Definition: sources/includes/nvdsinfer.h:86
nvdsinferserver::IBatchBuffer::getBufDesc
virtual const InferBufferDescription & getBufDesc() const =0
INT8
@ INT8
Specifies INT8 format.
Definition: sources/includes/nvdsinfer.h:84
nvdsinferserver::InferBatchDims::dims
InferDims dims
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:167
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::InferBatchDims::batchSize
int batchSize
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:166
nvdsinferserver::InferBufferDescription::dataType
InferDataType dataType
Datatype associated with the buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:185
nvdsinferserver::InferTensorOrder::kNone
@ kNone
nvdsinferserver::InferDataType::kFp16
@ kFp16
nvdsinferserver::InferMemType
InferMemType
The memory types of inference buffers.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:61
nvdsinferserver::InferBufferDescription::isInput
bool isInput
Boolean indicating input or output buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:201
nvdsinferserver::IBatchBuffer::~IBatchBuffer
virtual ~IBatchBuffer()=default
nvdsinferserver::InferMemType::kNvSurfaceArray
@ kNvSurfaceArray
NVRM surface array memory.
nvdsinferserver::InferDataType::kNone
@ kNone
nvdsinferserver::InferDataType::kUint32
@ kUint32
nvdsinferserver::SharedIBatchBuffer
std::shared_ptr< IBatchBuffer > SharedIBatchBuffer
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:209
nvdsinferserver::InferDims::numElements
unsigned int numElements
Number of elements in the layer including all dimensions.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:158
nvdsinferserver::InferBufferDescription::dims
InferDims dims
Dimensions of the tensor.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:189
nvdsinferserver::IBatchArray::appendIBatchBuf
virtual void appendIBatchBuf(SharedIBatchBuffer buf)=0
nvdsinferserver::SharedIBatchArray
std::shared_ptr< IBatchArray > SharedIBatchArray
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:210
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: sources/includes/nvdsinferserver/infer_datatypes.h:193
nvdsinferserver::InferPostprocessType::kSegmentation
@ kSegmentation
Post processing for image segmentation.
nvdsinferserver::IBatchBuffer::getBufPtr
virtual void * getBufPtr(uint32_t batchIdx) const =0
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: sources/includes/nvdsinferserver/infer_datatypes.h:181
nvdsinferserver::InferMediaFormat::kUnknown
@ kUnknown
nvdsinferserver::InferMemType::kNone
@ kNone
nvdsinferserver::InferBufferDescription::name
std::string name
Name of the buffer.
Definition: sources/includes/nvdsinferserver/infer_datatypes.h:197