NVIDIA DRIVE OS Linux SDK API Reference

5.1.9.0 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvmedia_tensor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 - 2019, NVIDIA CORPORATION. All rights reserved. All
3  * information contained herein is proprietary and confidential to NVIDIA
4  * Corporation. Any use, reproduction, or disclosure without the written
5  * permission of NVIDIA Corporation is prohibited.
6  */
7 
16 #ifndef NVMEDIA_TENSOR_H
17 #define NVMEDIA_TENSOR_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include "nvmedia_core.h"
24 #include "nvmedia_tensormetadata.h"
25 
45 #define NVMEDIA_TENSOR_VERSION_MAJOR (1u)
46 
47 #define NVMEDIA_TENSOR_VERSION_MINOR (3u)
48 
53 #define NVMEDIA_TENSOR_TIMEOUT_INFINITE (0xFFFFFFFFu)
54 
59 typedef struct {
63  uint32_t durationUs;
65 
70 
74 typedef enum {
96 
99 
101 
102 
103 
104 
108 #define NVM_TENSOR_ATTR_CPU_ACCESS_UNCACHED (0x00000001u)
109 
112 #define NVM_TENSOR_ATTR_CPU_ACCESS_CACHED (0x00000002u)
113 
117 #define NVM_TENSOR_ATTR_CPU_ACCESS_UNMAPPED (0x00000003u)
118 
122 #define NVM_TENSOR_ATTR_ALLOC_RESERVED (0x00000010u)
123 
126 #define NVM_TENSOR_ATTR_ALLOC_NONE (0x00000000u)
127 
131 typedef struct {
135  uint32_t value;
137 
138 
143 #define NVM_TENSOR_INIT_ATTR(x) \
144 { \
145  \
146  x[0].type = NVM_TENSOR_ATTR_DATA_TYPE; \
147  x[0].value = 0; \
148  \
149  x[1].type = NVM_TENSOR_ATTR_4D_N; \
150  x[1].value = 0; \
151  \
152  x[2].type = NVM_TENSOR_ATTR_4D_C; \
153  x[2].value = 0; \
154  \
155  x[3].type = NVM_TENSOR_ATTR_4D_H; \
156  x[3].value = 0; \
157  \
158  x[4].type = NVM_TENSOR_ATTR_4D_W; \
159  x[4].value = 0; \
160  \
161  x[5].type = NVM_TENSOR_ATTR_4D_X; \
162  x[5].value = 0; \
163  \
164  x[6].type = NVM_TENSOR_ATTR_BITS_PER_ELEMENT; \
165  x[6].value = 0; \
166  \
167  x[7].type = NVM_TENSOR_ATTR_DIMENSION_ORDER; \
168  x[7].value = 0; \
169  \
170  x[8].type = NVM_TENSOR_ATTR_CPU_ACCESS; \
171  x[8].value = 0; \
172  \
173  x[9].type = NVM_TENSOR_ATTR_ALLOC_TYPE; \
174  x[9].value = 0; \
175 }
176 
180 #define NVM_TENSOR_DEFINE_ATTR(x) \
181  NvMediaTensorAttr x[NVM_TENSOR_ATTR_MAX]; \
182  NVM_TENSOR_INIT_ATTR(x); \
183 
184 
205 #define NVM_TENSOR_SET_ATTR_4D(attr, N, C, H, W, order, datatype, bpe, accesstype, alloctype, X)\
206 { \
207  \
208  attr[0].type = NVM_TENSOR_ATTR_DATA_TYPE; \
209  attr[0].value = NVM_TENSOR_ATTR_DATA_TYPE_##datatype; \
210  \
211  attr[1].type = NVM_TENSOR_ATTR_4D_N; \
212  attr[1].value = N; \
213  \
214  attr[2].type = NVM_TENSOR_ATTR_4D_C; \
215  attr[2].value = C; \
216  \
217  attr[3].type = NVM_TENSOR_ATTR_4D_H; \
218  attr[3].value = H; \
219  \
220  attr[4].type = NVM_TENSOR_ATTR_4D_W; \
221  attr[4].value = W; \
222  \
223  attr[5].type = NVM_TENSOR_ATTR_4D_X; \
224  attr[5].value = X; \
225  \
226  attr[6].type = NVM_TENSOR_ATTR_BITS_PER_ELEMENT; \
227  attr[6].value = NVM_TENSOR_ATTR_BITS_PER_ELEMENT_##bpe; \
228  \
229  attr[7].type = NVM_TENSOR_ATTR_DIMENSION_ORDER; \
230  attr[7].value = NVM_TENSOR_ATTR_DIMENSION_ORDER_##order; \
231  \
232  attr[8].type = NVM_TENSOR_ATTR_CPU_ACCESS; \
233  attr[8].value = NVM_TENSOR_ATTR_CPU_ACCESS_##accesstype; \
234  \
235  attr[9].type = NVM_TENSOR_ATTR_ALLOC_TYPE; \
236  attr[9].value = NVM_TENSOR_ATTR_ALLOC_##alloctype; \
237 }
238 
246 void
248  NvMediaTensor *tensorDesc
249 );
250 
255 typedef enum {
263 
272 typedef struct {
274  uint32_t size;
276  void *mapping;
278 
305  NvMediaTensor *tensor,
306  uint32_t lockAccessType,
307  NvMediaTensorSurfaceMap *surfaceMap
308 );
309 
318 void
320  NvMediaTensor *tensor
321 );
322 
340  NvMediaTensor *tensor,
341  uint32_t millisecondWait,
343 );
344 
359  NvMediaTensor *tensor,
360  NvMediaTensorMetaData *tensormetadata
361 );
362 
365 /*
366  * \defgroup history_nvmedia_tensor History
367  * Provides change history for the NvMedia Tensor API.
368  *
369  * \section history_nvmedia_tensor Version History
370  *
371  * <b> Version 1.0 </b> May 22, 2017
372  * - Initial release
373  *
374  * <b> Version 1.2 </b> Jun 21, 2019
375  * - Fix Minor Misra Violations
376  *
377  * <b> Version 1.3 </b> Jun 22, 2019
378  * - Deprecate the NvMediaTensorCreate API
379  * in support of NvSciBuf APIs
380  *
381  **/
384 #ifdef __cplusplus
385 }; /* extern "C" */
386 #endif
387 
388 #endif /* NVMEDIA_TENSOR_H */
Defines the tensor surface map descriptor used by NvMediaTensorLock().
NvMediaStatus NvMediaTensorLock(NvMediaTensor *tensor, uint32_t lockAccessType, NvMediaTensorSurfaceMap *surfaceMap)
Locks a tensor and returns the associated mapped pointers pointing to the tensor surface data...
void * mapping
CPU accessible memory pointer of Tensor.
uint32_t size
Total size of the tensor.
NvMediaTensorAttrType
Defines attribute types for creating NvMedia Tensor.
Defines the number of channels of a 4D tensor.
Holds tensor creation attributes.
Specifies the tensor data type.
NvMediaStatus NvMediaTensorGetMetaData(NvMediaTensor *tensor, NvMediaTensorMetaData *tensormetadata)
Fills in the metadata information for the tensor.
NVIDIA Media Interface: Core
Attribute types for 4D tensors.
NvMediaStatus
Defines all possible error codes.
Definition: nvmedia_core.h:169
void NvMediaTensorUnlock(NvMediaTensor *tensor)
Unlocks a tensor.
Defines the x value of a 4D tensor.
void NvMediaTensorDestroy(NvMediaTensor *tensorDesc)
Destroys a tensor object previously created by NvMediaTensorCreateFromNvSciBuf(). ...
struct NvMediaTensor NvMediaTensor
A handle representing tensor objects.
NvMediaTensorLockAccess
Defines tensor lock access types.
NvMediaStatus NvMediaTensorGetStatus(NvMediaTensor *tensor, uint32_t millisecondWait, NvMediaTensorTaskStatus *status)
Gets the status of the current/last operation for the tensor, and optionally waits for the operation ...
Holds the tensor metadata.
Defines the CPU access to tensor (default: uncached).
NvMediaTensorAttrType type
Holds tensor creation attribute type.
Defines the tensor dimension order.
Defines the allocation type, reserved (default: none).
Defines the width of a 4D tensor.
Defines the maximum number of tensor creation attributes.
Defines the height of a 4D tensor.
NVIDIA Media Interface: Tensor Metadata Interface
uint32_t durationUs
Duration of the operation in microseconds.
Holds the status of the latest operation for a tensor.
Defines the tensor bits per element.
uint32_t value
Holds tensor creation attribute value.
NvMediaStatus status
Holds actual status - NvMediaStatus.