DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

Tensor.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed
3 // under the Mutual Non-Disclosure Agreement.
4 //
5 // Notice
6 // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
7 // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
8 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
9 // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10 //
11 // NVIDIA Corporation assumes no responsibility for the consequences of use of such
12 // information or for any infringement of patents or other rights of third parties that may
13 // result from its use. No license is granted by implication or otherwise under any patent
14 // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
15 // expressly authorized by NVIDIA. Details are subject to change without notice.
16 // This code supersedes and replaces all information previously supplied.
17 // NVIDIA Corporation products are not authorized for use as critical
18 // components in life support devices or systems without express written approval of
19 // NVIDIA Corporation.
20 //
21 // Copyright (c) 2019-2020 NVIDIA Corporation. All rights reserved.
22 //
23 // NVIDIA Corporation and its licensors retain all intellectual property and proprietary
24 // rights in and to this software and related documentation and any modifications thereto.
25 // Any use, reproduction, disclosure or distribution of this software and related
26 // documentation without an express license agreement from NVIDIA Corporation is
27 // strictly prohibited.
28 //
30 
46 #ifndef DW_DNN_TENSOR_H_
47 #define DW_DNN_TENSOR_H_
48 
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
57 typedef struct dwDNNTensorObject* dwDNNTensorHandle_t;
58 typedef struct dwDNNTensorObject const* dwConstDNNTensorHandle_t;
59 
61 #define DW_DNN_TENSOR_MAX_DIMENSIONS 9U
62 
64 typedef enum {
72 
79 typedef enum {
89 
91 typedef struct
92 {
104  uint32_t numDimensions;
112  uint32_t dimensionSize[DW_DNN_TENSOR_MAX_DIMENSIONS];
114 
116 typedef struct
117 {
123  const void* ptr;
124 } dwDNNTensor;
125 
137 dwStatus dwDNNTensor_create(dwDNNTensorHandle_t* const tensorHandle,
138  dwDNNTensorProperties const* const properties,
139  dwContextHandle_t const ctx);
140 
150 dwStatus dwDNNTensor_destroy(dwDNNTensorHandle_t const tensorHandle);
151 
172 dwStatus dwDNNTensor_getLayoutView(size_t* const offset, size_t* const stride, size_t* const numElements,
173  const uint32_t* const indices, uint32_t const numIndices,
174  uint32_t const dimension, dwConstDNNTensorHandle_t const tensorHandle);
175 
185 dwStatus dwDNNTensor_getProperties(dwDNNTensorProperties* const properties, dwConstDNNTensorHandle_t const tensorHandle);
186 
199 dwStatus dwDNNTensor_getTensor(dwDNNTensor* const tensor, dwDNNTensorHandle_t const tensorHandle);
200 
214 dwStatus dwDNNTensor_lock(void** const data, dwDNNTensorHandle_t const tensorHandle);
215 
231 dwStatus dwDNNTensor_tryLock(bool* const isLocked, void** const data, dwDNNTensorHandle_t const tensorHandle);
232 
241 dwStatus dwDNNTensor_unlock(dwDNNTensorHandle_t const tensorHandle);
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 
247 #endif // DW_DNN_TENSOR_H_
DW_API_PUBLIC dwStatus dwDNNTensor_getLayoutView(size_t *const offset, size_t *const stride, size_t *const numElements, const uint32_t *const indices, uint32_t const numIndices, uint32_t const dimension, dwConstDNNTensorHandle_t const tensorHandle)
Returns coefficients to facilitate traversing the given dimension.
Exposes the content of a dwDNNTensorHandle_t.
Definition: Tensor.h:116
dwTrivialDataType
Specifies a type indicator of the underlying trivial data type.
Definition: Types.h:103
DW_API_PUBLIC dwStatus dwDNNTensor_getProperties(dwDNNTensorProperties *const properties, dwConstDNNTensorHandle_t const tensorHandle)
Retrieves the properties of a dwDNNTensorHandle_t.
bool isGPUMapped
Indicates whether the memory allocation should be mapped to GPU.
Definition: Tensor.h:102
dwDNNTensorLayout tensorLayout
Tensor layout.
Definition: Tensor.h:98
dwTrivialDataType dataType
Data type of elements of the tensor.
Definition: Tensor.h:94
DW_API_PUBLIC dwStatus dwDNNTensor_lock(void **const data, dwDNNTensorHandle_t const tensorHandle)
Locks the tensor and retrieves pointer to the data with write access.
dwDNNTensorProperties prop
Defines the properties of the tensor.
Definition: Tensor.h:119
DW_API_PUBLIC dwStatus dwDNNTensor_unlock(dwDNNTensorHandle_t const tensorHandle)
Unlocks the tensor, enabling other threads to lock the tensor and modify the content.
dwDNNTensorType
Speficies the type of a tensor.
Definition: Tensor.h:64
Interleaved tensor.
Definition: Tensor.h:83
dwStatus
Status definition.
Definition: Status.h:180
DW_API_PUBLIC dwStatus dwDNNTensor_getTensor(dwDNNTensor *const tensor, dwDNNTensorHandle_t const tensorHandle)
Retrieves the dwDNNTensor of a dwDNNTensorHandle_t.
dwDNNTensorType tensorType
Tensor type.
Definition: Tensor.h:96
DW_API_PUBLIC dwStatus dwDNNTensor_create(dwDNNTensorHandle_t *const tensorHandle, dwDNNTensorProperties const *const properties, dwContextHandle_t const ctx)
Creates and allocates resources for a dwDNNTensorHandle_t based on the properties.
#define DW_DNN_TENSOR_MAX_DIMENSIONS
Maximum number of dimensions a tensor can have including batch dimension (N).
Definition: Tensor.h:61
uint32_t numDimensions
Number of dimensions of the tensor.
Definition: Tensor.h:104
struct dwDNNTensorObject const * dwConstDNNTensorHandle_t
Definition: Tensor.h:58
DW_API_PUBLIC dwStatus dwDNNTensor_destroy(dwDNNTensorHandle_t const tensorHandle)
Destroys the tensor handle and frees any memory created by dwDNNTensor_create().
Specifies DNNTensor properties.
Definition: Tensor.h:91
CPU tensor.
Definition: Tensor.h:66
Tensor with both interleaved and planar channels.
Definition: Tensor.h:87
const void * ptr
Pointer to the tensor content on CPU/GPU or NvMedia.
Definition: Tensor.h:123
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:79
struct dwDNNTensorObject * dwDNNTensorHandle_t
Handles representing Deep Neural Network interface.
Definition: Tensor.h:57
NVIDIA DriveWorks API: Core Methods
Planar tensor. This is the most common tensor layout.
Definition: Tensor.h:81
DW_API_PUBLIC dwStatus dwDNNTensor_tryLock(bool *const isLocked, void **const data, dwDNNTensorHandle_t const tensorHandle)
Tries to lock the tensor.
dwDNNTensorLayout
Specifies the layout of a tensor Here the letters in the suffix define:
Definition: Tensor.h:79
CUDA tensor.
Definition: Tensor.h:68
#define DW_API_PUBLIC
Definition: Exports.h:54
NvMedia tensor.
Definition: Tensor.h:70