NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/gst-nvdstensor/nvdstensor.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 
28 #ifndef NVDSTENSOR_H_
29 #define NVDSTENSOR_H_
30 
31 #include <stdint.h>
32 #include <stdbool.h>
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
47 #define STRUCTURE_PADDING 4
48 
52 typedef enum
53 {
58 
59 typedef enum
60 {
63 
67 typedef enum
68 {
79 
80 typedef enum
81 {
88 
92 typedef struct NvDsTensorCreateParams {
94  uint32_t gpuId;
95 
96  uint32_t n;
97  uint32_t c;
98  uint32_t h;
99  uint32_t w;
100 
103  uint32_t size;
104 
108 
113 
115 
119 typedef struct NvDsTensor {
120  uint32_t n;
121  uint32_t c;
122  uint32_t w;
123  uint32_t h;
124 
126  void * dataPtr;
129  void * mappedAddr;
130 
132  uint32_t dataSize;
133 
135 } NvDsTensor;
136 
140 typedef struct NvDsTensorArray {
142  uint32_t gpuId;
143 
147 
154 
156  uint32_t arraySize;
159  uint32_t numFilled;
162 
165 
185 int NvDsTensorCreate (NvDsTensorArray **tensor, uint32_t arraySize,
186  NvDsTensorCreateParams *params);
187 
195 int NvDsTensorDestroy (NvDsTensorArray *tensor);
196 
217 int NvDsTensorMap (NvDsTensorArray *tensors, int index, NvDsTensorMemMapFlags type);
218 
228 int NvDsTensorUnMap (NvDsTensorArray *tensors, int index);
229 
232 #ifdef __cplusplus
233 }
234 #endif
235 #endif /* NVDSTENSOR_H_ */
NvDsTensorMap
int NvDsTensorMap(NvDsTensorArray *tensors, int index, NvDsTensorMemMapFlags type)
Maps hardware batched buffers to the HOST or CPU address space.
NvDsTensorUnMap
int NvDsTensorUnMap(NvDsTensorArray *tensors, int index)
Unmaps previously mapped buffer(s).
NvDsTensorCreateParams::w
uint32_t w
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:99
NVDSTENSOR_MAP_READ_WRITE
@ NVDSTENSOR_MAP_READ_WRITE
Specifies NvDsTensor mapping type "read/write.".
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:56
NVDSTENSOR_NCHW
@ NVDSTENSOR_NCHW
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:61
NVDSTENSOR_INT16
@ NVDSTENSOR_INT16
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:85
NvDsTensorFormat
NvDsTensorFormat
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:59
STRUCTURE_PADDING
#define STRUCTURE_PADDING
Defines the default padding length for reserved fields of structures.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:47
NvDsTensor
struct NvDsTensor NvDsTensor
Holds information about a single buffer in a batch.
NVDSTENSOR_MEM_DEFAULT
@ NVDSTENSOR_MEM_DEFAULT
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:69
NVDSTENSOR_MEM_CUDA_PINNED
@ NVDSTENSOR_MEM_CUDA_PINNED
Specifies CUDA Host memory type.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:71
NVDSTENSOR_MAP_WRITE
@ NVDSTENSOR_MAP_WRITE
Specifies NvDsTensor mapping type "write.".
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:55
NvDsTensorArray::format
NvDsTensorFormat format
Holds the tensor format for buffers in the batch.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:153
NvDsTensor::c
uint32_t c
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:121
NvDsTensorPrecision
NvDsTensorPrecision
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:80
NVDSTENSOR_FP16
@ NVDSTENSOR_FP16
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:83
NVDSTENSOR_INT8
@ NVDSTENSOR_INT8
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:86
NvDsTensorArray::gpuId
uint32_t gpuId
Holds a GPU ID.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:142
NvDsTensorCreateParams::c
uint32_t c
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:97
NvDsTensor
Holds information about a single buffer in a batch.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:119
NvDsTensorCreateParams::size
uint32_t size
Holds the amount of memory to be allocated.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:103
NvDsTensorCreateParams::isContiguous
bool isContiguous
Holds a "contiguous memory" flag.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:107
NvDsTensorArray::precision
NvDsTensorPrecision precision
Holds precision for buffers in the batch.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:151
NvDsTensor::h
uint32_t h
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:123
NvDsTensorCreateParams::n
uint32_t n
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:96
NvDsTensorArray::_reserved
void * _reserved[STRUCTURE_PADDING]
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:163
NVDSTENSOR_MAP_READ
@ NVDSTENSOR_MAP_READ
Specifies NvDsTensor mapping type "read.".
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:54
NvDsTensorDestroy
int NvDsTensorDestroy(NvDsTensorArray *tensor)
Frees batched buffers previously allocated by NvDsTensorCreate().
NvDsTensor::dataSize
uint32_t dataSize
Holds the amount of allocated memory.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:132
NvDsTensorArray::isContiguous
bool isContiguous
Holds an "is contiguous" flag.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:146
NvDsTensor::w
uint32_t w
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:122
NvDsTensorCreateParams::h
uint32_t h
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:98
NvDsTensorMemMapFlags
NvDsTensorMemMapFlags
Specifies mapping types for NvDsTensor.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:52
NvDsTensorCreateParams
struct NvDsTensorCreateParams NvDsTensorCreateParams
Holds parameters required to allocate an NvDsTensor.
NvDsTensorArray::arraySize
uint32_t arraySize
Holds the batch size.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:156
NvDsTensorCreateParams::gpuId
uint32_t gpuId
Holds the GPU ID.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:94
NVDSTENSOR_MEM_SYSTEM
@ NVDSTENSOR_MEM_SYSTEM
Specifies memory allocated by malloc().
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:77
NvDsTensorCreateParams
Holds parameters required to allocate an NvDsTensor.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:92
NvDsTensor::_reserved
void * _reserved[STRUCTURE_PADDING]
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:134
NvDsTensorMemType
NvDsTensorMemType
Specifies memory types for NvDsTensor.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:67
NvDsTensorArray
struct NvDsTensorArray NvDsTensorArray
Holds information about batched buffers.
NvDsTensorArray
Holds information about batched buffers.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:140
NVDSTENSOR_INT32
@ NVDSTENSOR_INT32
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:84
NvDsTensor::n
uint32_t n
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:120
NvDsTensorArray::numFilled
uint32_t numFilled
Holds the number valid and filled buffers.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:159
NVDSTENSOR_FP32
@ NVDSTENSOR_FP32
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:82
NVDSTENSOR_MEM_CUDA_UNIFIED
@ NVDSTENSOR_MEM_CUDA_UNIFIED
Specifies CUDA Unified memory type.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:75
NvDsTensorArray::memType
NvDsTensorMemType memType
Holds type of memory for buffers in the batch.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:149
NvDsTensorCreateParams::precision
NvDsTensorPrecision precision
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:112
NVDSTENSOR_MEM_CUDA_DEVICE
@ NVDSTENSOR_MEM_CUDA_DEVICE
Specifies CUDA Device memory type.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:73
NvDsTensor::dataPtr
void * dataPtr
Holds a pointer to allocated memory.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:126
NvDsTensor::mappedAddr
void * mappedAddr
Holds pointers to mapped buffers.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:129
NvDsTensorCreateParams::format
NvDsTensorFormat format
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:111
NvDsTensorCreate
int NvDsTensorCreate(NvDsTensorArray **tensor, uint32_t arraySize, NvDsTensorCreateParams *params)
Allocates a batch of tensor.
NvDsTensorArray::tensorArray
NvDsTensor * tensorArray
Holds a pointer to an array of batched buffers.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:161
NvDsTensorCreateParams::memType
NvDsTensorMemType memType
Holds the type of memory to be allocated.
Definition: sources/libs/gst-nvdstensor/nvdstensor.h:110