NVIDIA DriveOS Linux NSR SDK API Reference

7.0.3.0 Release
Tensor.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
29 #ifndef DW_DNN_TENSOR_H_
30 #define DW_DNN_TENSOR_H_
31 
32 #include <dw/core/context/Context.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
40 typedef struct dwDNNTensorObject* dwDNNTensorHandle_t;
41 typedef struct dwDNNTensorObject const* dwConstDNNTensorHandle_t;
42 
44 #define DW_DNN_TENSOR_MAX_DIMENSIONS 8U
45 
47 typedef enum {
53 
60 typedef enum {
70 
72 typedef enum {
77 
79 typedef struct
80 {
92  uint32_t numDimensions;
100  uint32_t dimensionSize[DW_DNN_TENSOR_MAX_DIMENSIONS];
104  float32_t dynamicRange[2];
106 
108 typedef struct
109 {
117  const void* ptr;
118 } dwDNNTensor;
119 
136  dwDNNTensorProperties const* const properties,
137  dwContextHandle_t const ctx);
138 
155  dwDNNTensorProperties const* const properties,
156  uint8_t* const extMem,
157  size_t const stride);
158 
174 
199 dwStatus dwDNNTensor_getLayoutView(size_t* const offset, size_t* const stride, size_t* const numElements,
200  const uint32_t* const indices, uint32_t const numIndices,
201  uint32_t const dimension, dwConstDNNTensorHandle_t const tensorHandle);
202 
217 
234 dwStatus dwDNNTensor_getTensor(dwDNNTensor* const tensor, dwDNNTensorHandle_t const tensorHandle);
235 
250 dwStatus dwDNNTensor_getTimestamp(dwTime_t* const time, dwDNNTensorHandle_t const tensorHandle);
251 
267 
285 dwStatus dwDNNTensor_lock(void** const data, dwDNNTensorHandle_t const tensorHandle);
286 
306 dwStatus dwDNNTensor_tryLock(bool* const isLocked, void** const data, dwDNNTensorHandle_t const tensorHandle);
307 
321 
322 #ifdef __cplusplus
323 }
324 #endif
325 
326 #endif // DW_DNN_TENSOR_H_
dwDNNTensorHandle_t
struct dwDNNTensorObject * dwDNNTensorHandle_t
Handles representing Deep Neural Network interface.
Definition: Tensor.h:40
dwDNNTensor::prop
dwDNNTensorProperties prop
Defines the properties of the tensor.
Definition: Tensor.h:111
dwDNNTensor_getProperties
DW_API_PUBLIC dwStatus dwDNNTensor_getProperties(dwDNNTensorProperties *const properties, dwConstDNNTensorHandle_t const tensorHandle)
Retrieves the properties of a dwDNNTensorHandle_t.
dwDNNTensorType
dwDNNTensorType
Speficies the type of a tensor.
Definition: Tensor.h:47
ctx
DW_API_PUBLIC dwPointCloudRangeImageCreatorParams const *const const dwContextHandle_t ctx
Definition: PointCloudRangeImageCreator.h:293
DW_DNN_TENSOR_COLORSPACE_UNKNOWN
@ DW_DNN_TENSOR_COLORSPACE_UNKNOWN
Definition: Tensor.h:73
dwDNNTensorProperties::dataType
dwTrivialDataType dataType
Data type of elements of the tensor.
Definition: Tensor.h:82
dwDNNTensor::ptr
const void * ptr
Pointer to the tensor content on CPU/GPU or NvMedia.
Definition: Tensor.h:117
dwDNNTensor_getTimestamp
DW_API_PUBLIC dwStatus dwDNNTensor_getTimestamp(dwTime_t *const time, dwDNNTensorHandle_t const tensorHandle)
Retrieves the timestamp of a dwDNNTensorHandle_t.
dwDNNTensorColorSpace
dwDNNTensorColorSpace
Represents the color space the data is represented in. If unknown, then its custom or non color data.
Definition: Tensor.h:72
dwDNNTensorProperties::tensorLayout
dwDNNTensorLayout tensorLayout
Tensor layout.
Definition: Tensor.h:86
dwTime_t
int64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: BasicTypes.h:54
float32_t
float float32_t
Specifies POD types.
Definition: BasicTypes.h:41
dwDNNTensor_setTimestamp
DW_API_PUBLIC dwStatus dwDNNTensor_setTimestamp(dwTime_t time, dwDNNTensorHandle_t const tensorHandle)
Set timestamp of a dwDNNTensorHandle_t.
dwDNNTensorProperties::colorSpace
dwDNNTensorColorSpace colorSpace
Color space of the data in the tensor.
Definition: Tensor.h:102
dwDNNTensorProperties
Specifies DNNTensor properties.
Definition: Tensor.h:79
dwDNNTensor_unlock
DW_API_PUBLIC dwStatus dwDNNTensor_unlock(dwDNNTensorHandle_t const tensorHandle)
Unlocks the tensor, enabling other threads to lock the tensor and modify the content.
DW_DNN_TENSOR_COLORSPACE_RGB
@ DW_DNN_TENSOR_COLORSPACE_RGB
Definition: Tensor.h:74
DW_DNN_TENSOR_LAYOUT_NHWC
@ DW_DNN_TENSOR_LAYOUT_NHWC
Interleaved tensor.
Definition: Tensor.h:64
dwDNNTensor_getLayoutView
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.
dwDNNTensor_createWithExtMem
DW_API_PUBLIC dwStatus dwDNNTensor_createWithExtMem(dwDNNTensorHandle_t *const tensorHandle, dwDNNTensorProperties const *const properties, uint8_t *const extMem, size_t const stride)
Creates a dwDNNTensorHandle_t with external memory resources based on the properties.
DW_DNN_TENSOR_LAYOUT_NCHW
@ DW_DNN_TENSOR_LAYOUT_NCHW
Planar tensor. This is the most common tensor layout.
Definition: Tensor.h:62
dwDNNTensorLayout
dwDNNTensorLayout
Specifies the layout of a tensor Here the letters in the suffix define:
Definition: Tensor.h:60
dwDNNTensorProperties::tensorType
dwDNNTensorType tensorType
Tensor type.
Definition: Tensor.h:84
DW_DNN_TENSOR_MAX_DIMENSIONS
#define DW_DNN_TENSOR_MAX_DIMENSIONS
Maximum number of dimensions a tensor can have including batch dimension (N).
Definition: Tensor.h:44
dwDNNTensor_destroy
DW_API_PUBLIC dwStatus dwDNNTensor_destroy(dwDNNTensorHandle_t const tensorHandle)
Destroys the tensor handle and frees any memory created by dwDNNTensor_create() or dwDNNTensor_create...
DW_DNN_TENSOR_TYPE_CPU
@ DW_DNN_TENSOR_TYPE_CPU
CPU tensor.
Definition: Tensor.h:49
dwDNNTensor_tryLock
DW_API_PUBLIC dwStatus dwDNNTensor_tryLock(bool *const isLocked, void **const data, dwDNNTensorHandle_t const tensorHandle)
Tries to lock the tensor.
dwContextHandle_t
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:74
DW_DNN_TENSOR_LAYOUT_NCHWx
@ DW_DNN_TENSOR_LAYOUT_NCHWx
Tensor with both interleaved and planar channels.
Definition: Tensor.h:68
dwDNNTensorProperties::isGPUMapped
bool isGPUMapped
Indicates whether the memory allocation should be mapped to GPU.
Definition: Tensor.h:90
dwConstDNNTensorHandle_t
struct dwDNNTensorObject const * dwConstDNNTensorHandle_t
Definition: Tensor.h:41
dwDNNTensor_lock
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.
dwStatus
dwStatus
Status definition.
Definition: ErrorDefs.h:27
dwDNNTensor
Exposes the content of a dwDNNTensorHandle_t.
Definition: Tensor.h:108
DW_API_PUBLIC
#define DW_API_PUBLIC
Definition: Exports.h:38
dwDNNTensor_create
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.
dwTrivialDataType
dwTrivialDataType
Specifies a type indicator of the underlying trivial data type.
Definition: TypesExtra.h:42
dwDNNTensorProperties::numDimensions
uint32_t numDimensions
Number of dimensions of the tensor.
Definition: Tensor.h:92
DW_DNN_TENSOR_TYPE_CUDA
@ DW_DNN_TENSOR_TYPE_CUDA
CUDA tensor.
Definition: Tensor.h:51
dwDNNTensor::timestamp_us
dwTime_t timestamp_us
Specifies a timestamp, in microseconds, corresponding to this tensor data.
Definition: Tensor.h:113
dwDNNTensor_getTensor
DW_API_PUBLIC dwStatus dwDNNTensor_getTensor(dwDNNTensor *const tensor, dwDNNTensorHandle_t const tensorHandle)
Retrieves the dwDNNTensor of a dwDNNTensorHandle_t.
DW_DNN_TENSOR_COLORSPACE_YUV
@ DW_DNN_TENSOR_COLORSPACE_YUV
Definition: Tensor.h:75