DriveWorks SDK Reference
3.0.4260 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 
48 #ifndef DW_DNN_TENSOR_H_
49 #define DW_DNN_TENSOR_H_
50 
51 #include <dw/core/Context.h>
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
59 typedef struct dwDNNTensorObject* dwDNNTensorHandle_t;
60 typedef struct dwDNNTensorObject const* dwConstDNNTensorHandle_t;
61 
63 #define DW_DNN_TENSOR_MAX_DIMENSIONS 9
64 
66 typedef enum {
74 
81 typedef enum {
91 
93 typedef struct
94 {
106  uint32_t numDimensions;
114  uint32_t dimensionSize[DW_DNN_TENSOR_MAX_DIMENSIONS];
116 
118 typedef struct
119 {
125  const void* ptr;
126 } dwDNNTensor;
127 
139 dwStatus dwDNNTensor_create(dwDNNTensorHandle_t* tensorHandle,
140  dwDNNTensorProperties properties,
141  dwContextHandle_t ctx);
142 
152 dwStatus dwDNNTensor_destroy(dwDNNTensorHandle_t tensorHandle);
153 
174 dwStatus dwDNNTensor_getLayoutView(size_t* offset, size_t* stride, size_t* numElements,
175  const uint32_t* indices, uint32_t numIndices,
176  uint32_t dimension, const dwConstDNNTensorHandle_t tensorHandle);
177 
187 dwStatus dwDNNTensor_getProperties(dwDNNTensorProperties* properties, dwConstDNNTensorHandle_t tensorHandle);
188 
201 dwStatus dwDNNTensor_getTensor(dwDNNTensor* tensor, dwDNNTensorHandle_t tensorHandle);
202 
216 dwStatus dwDNNTensor_lock(void** data, dwDNNTensorHandle_t tensorHandle);
217 
233 dwStatus dwDNNTensor_tryLock(bool* isLocked, void** data, dwDNNTensorHandle_t tensorHandle);
234 
243 dwStatus dwDNNTensor_unlock(dwDNNTensorHandle_t tensorHandle);
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 
249 #endif // DW_DNN_TENSOR_H_
Exposes the content of a dwDNNTensorHandle_t.
Definition: Tensor.h:118
dwTrivialDataType
Specifies a type indicator of the underlying trivial data type.
Definition: Types.h:103
DW_API_PUBLIC dwStatus dwDNNTensor_tryLock(bool *isLocked, void **data, dwDNNTensorHandle_t tensorHandle)
Tries to lock the tensor.
DW_API_PUBLIC dwStatus dwDNNTensor_unlock(dwDNNTensorHandle_t tensorHandle)
Unlocks the tensor, enabling other threads to lock the tensor and modify the content.
bool isGPUMapped
Indicates whether the memory allocation should be mapped to GPU.
Definition: Tensor.h:104
dwDNNTensorLayout tensorLayout
Tensor layout.
Definition: Tensor.h:100
dwTrivialDataType dataType
Data type of elements of the tensor.
Definition: Tensor.h:96
dwDNNTensorProperties prop
Defines the properties of the tensor.
Definition: Tensor.h:121
NVIDIA DriveWorks API: Core Methods
DW_API_PUBLIC dwStatus dwDNNTensor_getLayoutView(size_t *offset, size_t *stride, size_t *numElements, const uint32_t *indices, uint32_t numIndices, uint32_t dimension, const dwConstDNNTensorHandle_t tensorHandle)
Returns coefficients to facilitate traversing the given dimension.
dwDNNTensorType
Speficies the type of a tensor.
Definition: Tensor.h:66
DW_API_PUBLIC dwStatus dwDNNTensor_lock(void **data, dwDNNTensorHandle_t tensorHandle)
Locks the tensor and retrieves pointer to the data with write access.
Interleaved tensor.
Definition: Tensor.h:85
dwStatus
Status definition.
Definition: Status.h:166
DW_API_PUBLIC dwStatus dwDNNTensor_create(dwDNNTensorHandle_t *tensorHandle, dwDNNTensorProperties properties, dwContextHandle_t ctx)
Creates and allocates resources for a dwDNNTensorHandle_t based on the properties.
dwDNNTensorType tensorType
Tensor type.
Definition: Tensor.h:98
#define DW_DNN_TENSOR_MAX_DIMENSIONS
Maximum number of dimensions a tensor can have including batch dimension (N).
Definition: Tensor.h:63
DW_API_PUBLIC dwStatus dwDNNTensor_getTensor(dwDNNTensor *tensor, dwDNNTensorHandle_t tensorHandle)
Retrieves the dwDNNTensor of a dwDNNTensorHandle_t.
uint32_t numDimensions
Number of dimensions of the tensor.
Definition: Tensor.h:106
DW_API_PUBLIC dwStatus dwDNNTensor_getProperties(dwDNNTensorProperties *properties, dwConstDNNTensorHandle_t tensorHandle)
Retrieves the properties of a dwDNNTensorHandle_t.
struct dwDNNTensorObject const * dwConstDNNTensorHandle_t
Definition: Tensor.h:60
Specifies DNNTensor properties.
Definition: Tensor.h:93
CPU tensor.
Definition: Tensor.h:68
Tensor with both interleaved and planar channels.
Definition: Tensor.h:89
const void * ptr
Pointer to the tensor content on CPU/GPU or NvMedia.
Definition: Tensor.h:125
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:80
struct dwDNNTensorObject * dwDNNTensorHandle_t
Handles representing Deep Neural Network interface.
Definition: Tensor.h:59
Planar tensor. This is the most common tensor layout.
Definition: Tensor.h:83
dwDNNTensorLayout
Specifies the layout of a tensor Here the letters in the suffix define:
Definition: Tensor.h:81
CUDA tensor.
Definition: Tensor.h:70
DW_API_PUBLIC dwStatus dwDNNTensor_destroy(dwDNNTensorHandle_t tensorHandle)
Destroys the tensor handle and frees any memory created by dwDNNTensor_create().
#define DW_API_PUBLIC
Definition: Exports.h:56
NvMedia tensor.
Definition: Tensor.h:72