NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/gst-nvdstensor/nvdstensor.h File Reference

Detailed Description

NvDsTensor Interface

This file specifies the NvDsTensor management API.

The NvDsTensor API provides methods to allocate / deallocate, map / unmap and copy batched buffers.

Definition in file sources/libs/gst-nvdstensor/nvdstensor.h.

Go to the source code of this file.

Data Structures

struct  NvDsTensorCreateParams
 Holds parameters required to allocate an NvDsTensor. More...
 
struct  NvDsTensor
 Holds information about a single buffer in a batch. More...
 
struct  NvDsTensorArray
 Holds information about batched buffers. More...
 

NvDsTensor types and functions.

This section describes types and functions of NvDsTensor application programming interface.

#define STRUCTURE_PADDING   4
 Defines the default padding length for reserved fields of structures. More...
 
enum  NvDsTensorMemMapFlags {
  NVDSTENSOR_MAP_READ,
  NVDSTENSOR_MAP_WRITE,
  NVDSTENSOR_MAP_READ_WRITE,
  NVDSTENSOR_MAP_READ,
  NVDSTENSOR_MAP_WRITE,
  NVDSTENSOR_MAP_READ_WRITE
}
 Specifies mapping types for NvDsTensor. More...
 
enum  NvDsTensorFormat {
  NVDSTENSOR_NCHW,
  NVDSTENSOR_NCHW
}
 
enum  NvDsTensorMemType {
  NVDSTENSOR_MEM_DEFAULT,
  NVDSTENSOR_MEM_CUDA_PINNED,
  NVDSTENSOR_MEM_CUDA_DEVICE,
  NVDSTENSOR_MEM_CUDA_UNIFIED,
  NVDSTENSOR_MEM_SYSTEM,
  NVDSTENSOR_MEM_DEFAULT,
  NVDSTENSOR_MEM_CUDA_PINNED,
  NVDSTENSOR_MEM_CUDA_DEVICE,
  NVDSTENSOR_MEM_CUDA_UNIFIED,
  NVDSTENSOR_MEM_SYSTEM
}
 Specifies memory types for NvDsTensor. More...
 
enum  NvDsTensorPrecision {
  NVDSTENSOR_FP32,
  NVDSTENSOR_FP16,
  NVDSTENSOR_INT32,
  NVDSTENSOR_INT16,
  NVDSTENSOR_INT8,
  NVDSTENSOR_FP32,
  NVDSTENSOR_FP16,
  NVDSTENSOR_INT32,
  NVDSTENSOR_INT16,
  NVDSTENSOR_INT8
}
 
typedef struct NvDsTensorCreateParams NvDsTensorCreateParams
 Holds parameters required to allocate an NvDsTensor. More...
 
typedef struct NvDsTensor NvDsTensor
 Holds information about a single buffer in a batch. More...
 
typedef struct NvDsTensorArray NvDsTensorArray
 Holds information about batched buffers. More...
 
int NvDsTensorCreate (NvDsTensorArray **tensor, uint32_t arraySize, NvDsTensorCreateParams *params)
 Allocates a batch of tensor. More...
 
int NvDsTensorDestroy (NvDsTensorArray *tensor)
 Frees batched buffers previously allocated by NvDsTensorCreate(). More...
 
int NvDsTensorMap (NvDsTensorArray *tensors, int index, NvDsTensorMemMapFlags type)
 Maps hardware batched buffers to the HOST or CPU address space. More...
 
int NvDsTensorUnMap (NvDsTensorArray *tensors, int index)
 Unmaps previously mapped buffer(s). More...
 

Macro Definition Documentation

◆ STRUCTURE_PADDING

#define STRUCTURE_PADDING   4

Defines the default padding length for reserved fields of structures.

Definition at line 47 of file sources/libs/gst-nvdstensor/nvdstensor.h.

Typedef Documentation

◆ NvDsTensor

typedef struct NvDsTensor NvDsTensor

Holds information about a single buffer in a batch.

◆ NvDsTensorArray

Holds information about batched buffers.

◆ NvDsTensorCreateParams

Holds parameters required to allocate an NvDsTensor.

Enumeration Type Documentation

◆ NvDsTensorFormat

Enumerator
NVDSTENSOR_NCHW 
NVDSTENSOR_NCHW 

Definition at line 59 of file sources/libs/gst-nvdstensor/nvdstensor.h.

◆ NvDsTensorMemMapFlags

Specifies mapping types for NvDsTensor.

Enumerator
NVDSTENSOR_MAP_READ 

Specifies NvDsTensor mapping type "read.".

NVDSTENSOR_MAP_WRITE 

Specifies NvDsTensor mapping type "write.".

NVDSTENSOR_MAP_READ_WRITE 

Specifies NvDsTensor mapping type "read/write.".

NVDSTENSOR_MAP_READ 

Specifies NvDsTensor mapping type "read.".

NVDSTENSOR_MAP_WRITE 

Specifies NvDsTensor mapping type "write.".

NVDSTENSOR_MAP_READ_WRITE 

Specifies NvDsTensor mapping type "read/write.".

Definition at line 52 of file sources/libs/gst-nvdstensor/nvdstensor.h.

◆ NvDsTensorMemType

Specifies memory types for NvDsTensor.

Enumerator
NVDSTENSOR_MEM_DEFAULT 
NVDSTENSOR_MEM_CUDA_PINNED 

Specifies CUDA Host memory type.

NVDSTENSOR_MEM_CUDA_DEVICE 

Specifies CUDA Device memory type.

NVDSTENSOR_MEM_CUDA_UNIFIED 

Specifies CUDA Unified memory type.

NVDSTENSOR_MEM_SYSTEM 

Specifies memory allocated by malloc().

NVDSTENSOR_MEM_DEFAULT 
NVDSTENSOR_MEM_CUDA_PINNED 

Specifies CUDA Host memory type.

NVDSTENSOR_MEM_CUDA_DEVICE 

Specifies CUDA Device memory type.

NVDSTENSOR_MEM_CUDA_UNIFIED 

Specifies CUDA Unified memory type.

NVDSTENSOR_MEM_SYSTEM 

Specifies memory allocated by malloc().

Definition at line 67 of file sources/libs/gst-nvdstensor/nvdstensor.h.

◆ NvDsTensorPrecision

Enumerator
NVDSTENSOR_FP32 
NVDSTENSOR_FP16 
NVDSTENSOR_INT32 
NVDSTENSOR_INT16 
NVDSTENSOR_INT8 
NVDSTENSOR_FP32 
NVDSTENSOR_FP16 
NVDSTENSOR_INT32 
NVDSTENSOR_INT16 
NVDSTENSOR_INT8 

Definition at line 80 of file sources/libs/gst-nvdstensor/nvdstensor.h.

Function Documentation

◆ NvDsTensorCreate()

int NvDsTensorCreate ( NvDsTensorArray **  tensor,
uint32_t  arraySize,
NvDsTensorCreateParams *  params 
)

Allocates a batch of tensor.

Allocates memory for batchSize tensors and returns a pointer to an allocated NvDsTensorArray. The params structure must have the allocation parameters of a single buffer. If params.size is set, a buffer of that size is allocated, and all other parameters (width, height, tensor format, etc.) are ignored.

Call NvDsTensorDestroy() to free resources allocated by this function.

Parameters
[out]tensorarray An indirect pointer to the allocated batched buffers.
[in]arraySizeBatch size of buffers.
[in]paramsA pointer to an NvDsTensorCreateParams structure.
Returns
0 if successful, or -1 otherwise.

◆ NvDsTensorDestroy()

int NvDsTensorDestroy ( NvDsTensorArray *  tensor)

Frees batched buffers previously allocated by NvDsTensorCreate().

Parameters
[in]tensorsA pointer to an NvDsTensorArray to be freed.
Returns
0 if successful, or -1 otherwise.

◆ NvDsTensorMap()

int NvDsTensorMap ( NvDsTensorArray *  tensors,
int  index,
NvDsTensorMemMapFlags  type 
)

Maps hardware batched buffers to the HOST or CPU address space.

This function fills an array of pointers at tensors->tensorArray->mappedAddr tensors is a pointer to an NvDsTensorArray. tensorArray is a pointer to an NvDsTensor. mappedAddr holds pointer to buffer.

Use NvDsTensorUnMap() to unmap buffer(s) and release any resource.

Parameters
[in,out]tensorsA pointer to an NvDsTensorArray structure. The function stores pointers to the buffers in a descendant of this structure; see the notes above.
[in]indexIndex of a buffer in the batch. -1 refers to all buffers in the batch.
[in]typeA flag for mapping type.
Returns
0 if successful, or -1 otherwise.

◆ NvDsTensorUnMap()

int NvDsTensorUnMap ( NvDsTensorArray *  tensors,
int  index 
)

Unmaps previously mapped buffer(s).

Parameters
[in]tensorsA pointer to an NvDsTensorArray structure.
[in]indexIndex of a buffer in the batch. -1 indicates all buffers in the batch.
Returns
0 if successful, or -1 otherwise.