NVIDIA DeepStream SDK API Reference
9.2 Release
includes/ds3d/common/type_trait.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: Apache-2.0
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef _DS3D_COMMON_TYPE_TRAIT__H
19
#define _DS3D_COMMON_TYPE_TRAIT__H
20
#include <ds3d/common/common.h>
21
#include <ds3d/common/typeid.h>
22
#include <ds3d/common/idatatype.h>
23
24
#if ENABLE_HALF
25
#include <half.hpp>
26
#endif
27
28
namespace
ds3d
{
29
30
template
<
typename
Tp>
31
struct
TpId
{
32
static
constexpr
TIdType
__typeid
() {
return
Tp::__typeid(); }
33
};
34
35
template
<TIdType v>
36
struct
__TypeID
{
37
static
constexpr
TIdType
__typeid
() {
return
v; }
38
};
39
40
template
<DataType v>
41
struct
__DataTypeVal
{
42
static
constexpr
DataType
_data_type_value
() {
return
v; }
43
};
44
45
// define TypeId
46
template
<>
47
struct
TpId
<uint32_t> :
__TypeID
<DS3D_TYPEID_UINT32_T>,
__DataTypeVal
<DataType::kUint32> {
48
};
49
template
<>
50
struct
TpId
<int32_t> :
__TypeID
<DS3D_TYPEID_INT32_T>,
__DataTypeVal
<DataType::kInt32> {
51
};
52
template
<>
53
struct
TpId
<float> :
__TypeID
<DS3D_TYPEID_FLOAT>,
__DataTypeVal
<DataType::kFp32> {
54
};
55
template
<>
56
struct
TpId
<int8_t> :
__TypeID
<DS3D_TYPEID_INT8_T>,
__DataTypeVal
<DataType::kInt8> {
57
};
58
template
<>
59
struct
TpId
<uint8_t> :
__TypeID
<DS3D_TYPEID_UINT8_T>,
__DataTypeVal
<DataType::kUint8> {
60
};
61
template
<>
62
struct
TpId
<uint16_t> :
__TypeID
<DS3D_TYPEID_UINT16_T>,
__DataTypeVal
<DataType::kUint16> {
63
};
64
template
<>
65
struct
TpId
<int16_t> :
__TypeID
<DS3D_TYPEID_INT16_T>,
__DataTypeVal
<DataType::kInt16> {
66
};
67
68
template
<>
69
struct
TpId
<double> :
__TypeID
<DS3D_TYPEID_DOUBLE>,
__DataTypeVal
<DataType::kDouble> {
70
};
71
72
template
<>
73
struct
TpId
<bool> :
__TypeID
<DS3D_TYPEID_BOOL>,
__DataTypeVal
<DataType::kDouble> {
74
};
75
76
template
<>
77
struct
TpId
<int64_t> :
__TypeID
<DS3D_TYPEID_INT64_T>,
__DataTypeVal
<DataType::kInt64> {
78
};
79
80
template
<
typename
TP>
81
struct
__DataTypeTrait
{
82
static
constexpr
DataType
_data_type
() {
return
TpId<TP>::_data_type_value
(); }
83
};
84
85
template
<DataType t>
86
struct
NativeData
;
87
88
template
<>
89
struct
NativeData
<
DataType
::
kFp32
> {
90
using
type
= float;
91
};
92
93
template
<>
94
struct
NativeData
<
DataType
::
kFp16
> {
95
#if ENABLE_HALF
96
using
type
=
half_float::half
;
97
#else
98
using
type
= int16_t;
99
#endif
100
};
101
102
template
<>
103
struct
NativeData
<
DataType
::
kInt8
> {
104
using
type
= int8_t;
105
};
106
107
template
<>
108
struct
NativeData
<
DataType
::
kInt32
> {
109
using
type
= int32_t;
110
};
111
template
<>
112
struct
NativeData
<
DataType
::
kInt16
> {
113
using
type
= int16_t;
114
};
115
template
<>
116
struct
NativeData
<
DataType
::
kUint8
> {
117
using
type
= uint8_t;
118
};
119
template
<>
120
struct
NativeData
<
DataType
::
kUint16
> {
121
using
type
= uint16_t;
122
};
123
template
<>
124
struct
NativeData
<
DataType
::
kUint32
> {
125
using
type
= uint32_t;
126
};
127
template
<>
128
struct
NativeData
<
DataType
::
kDouble
> {
129
using
type
= double;
130
};
131
132
template
<>
133
struct
NativeData
<
DataType
::
kInt64
> {
134
using
type
= int64_t;
135
};
136
137
}
// namespace ds3d
138
139
#endif // _DS3D_COMMON_TYPE_TRAIT__H
ds3d::__DataTypeVal
Definition:
includes/ds3d/common/type_trait.h:41
ds3d::DataType::kUint32
@ kUint32
ds3d::TpId::__typeid
static constexpr TIdType __typeid()
Definition:
includes/ds3d/common/type_trait.h:32
ds3d::NativeData< DataType::kUint8 >::type
uint8_t type
Definition:
includes/ds3d/common/type_trait.h:117
ds3d::NativeData
Definition:
includes/ds3d/common/type_trait.h:86
ds3d::DataType::kFp32
@ kFp32
ds3d::DataType
DataType
Definition:
includes/ds3d/common/idatatype.h:82
ds3d::NativeData< DataType::kInt8 >::type
int8_t type
Definition:
includes/ds3d/common/type_trait.h:104
half_float::half
Half-precision floating-point type.
Definition:
includes/half.hpp:2072
ds3d::__TypeID::__typeid
static constexpr TIdType __typeid()
Definition:
includes/ds3d/common/type_trait.h:37
ds3d::DataType::kInt32
@ kInt32
ds3d::NativeData< DataType::kInt64 >::type
int64_t type
Definition:
includes/ds3d/common/type_trait.h:134
ds3d::NativeData< DataType::kFp16 >::type
int16_t type
Definition:
includes/ds3d/common/type_trait.h:98
ds3d::NativeData< DataType::kFp32 >::type
float type
Definition:
includes/ds3d/common/type_trait.h:90
ds3d::NativeData< DataType::kInt32 >::type
int32_t type
Definition:
includes/ds3d/common/type_trait.h:109
ds3d::__TypeID
Definition:
includes/ds3d/common/type_trait.h:36
ds3d::__DataTypeTrait::_data_type
static constexpr DataType _data_type()
Definition:
includes/ds3d/common/type_trait.h:82
ds3d::NativeData< DataType::kDouble >::type
double type
Definition:
includes/ds3d/common/type_trait.h:129
ds3d::NativeData< DataType::kUint32 >::type
uint32_t type
Definition:
includes/ds3d/common/type_trait.h:125
ds3d::__DataTypeTrait
Definition:
includes/ds3d/common/type_trait.h:81
ds3d::DataType::kInt64
@ kInt64
ds3d::DataType::kUint16
@ kUint16
ds3d::DataType::kDouble
@ kDouble
ds3d::DataType::kUint8
@ kUint8
ds3d::DataType::kFp16
@ kFp16
ds3d::TpId
Definition:
includes/ds3d/common/type_trait.h:31
ds3d::NativeData< DataType::kInt16 >::type
int16_t type
Definition:
includes/ds3d/common/type_trait.h:113
ds3d::NativeData< DataType::kUint16 >::type
uint16_t type
Definition:
includes/ds3d/common/type_trait.h:121
ds3d::DataType::kInt16
@ kInt16
ds3d
Definition:
includes/ds3d/common/abi_dataprocess.h:25
ds3d::__DataTypeVal::_data_type_value
static constexpr DataType _data_type_value()
Definition:
includes/ds3d/common/type_trait.h:42
ds3d::DataType::kInt8
@ kInt8
ds3d::TIdType
uint64_t TIdType
Definition:
includes/ds3d/common/common.h:73
Privacy Policy
|
Your Privacy Choices
|
Terms of Service
|
Accessibility
|
Corporate Policies
|
Product Security
|
Contact
© 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
NVIDIA Confidential | Subject to Change | For test and development only.
Wed Oct 28 2026 12:02:52 | PR-09318-R32