NVIDIA DeepStream SDK API Reference

7.0 Release
type_trait.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2022 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 
13 
14 #ifndef _DS3D_COMMON_TYPE_TRAIT__H
15 #define _DS3D_COMMON_TYPE_TRAIT__H
16 #include <ds3d/common/common.h>
17 #include <ds3d/common/typeid.h>
18 #include <ds3d/common/idatatype.h>
19 
20 #if ENABLE_HALF
21 #include <half.hpp>
22 #endif
23 
24 namespace ds3d {
25 
26 template <typename Tp>
27 struct TpId {
28  static constexpr TIdType __typeid() { return Tp::__typeid(); }
29 };
30 
31 template <TIdType v>
32 struct __TypeID {
33  static constexpr TIdType __typeid() { return v; }
34 };
35 
36 template <DataType v>
37 struct __DataTypeVal {
38  static constexpr DataType _data_type_value() { return v; }
39 };
40 
41 // define TypeId
42 template <>
43 struct TpId<uint32_t> : __TypeID<DS3D_TYPEID_UINT32_T>, __DataTypeVal<DataType::kUint32> {
44 };
45 template <>
46 struct TpId<int32_t> : __TypeID<DS3D_TYPEID_INT32_T>, __DataTypeVal<DataType::kInt32> {
47 };
48 template <>
49 struct TpId<float> : __TypeID<DS3D_TYPEID_FLOAT>, __DataTypeVal<DataType::kFp32> {
50 };
51 template <>
52 struct TpId<int8_t> : __TypeID<DS3D_TYPEID_INT8_T>, __DataTypeVal<DataType::kInt8> {
53 };
54 template <>
55 struct TpId<uint8_t> : __TypeID<DS3D_TYPEID_UINT8_T>, __DataTypeVal<DataType::kUint8> {
56 };
57 template <>
58 struct TpId<uint16_t> : __TypeID<DS3D_TYPEID_UINT16_T>, __DataTypeVal<DataType::kUint16> {
59 };
60 template <>
61 struct TpId<int16_t> : __TypeID<DS3D_TYPEID_INT16_T>, __DataTypeVal<DataType::kInt16> {
62 };
63 
64 template <>
65 struct TpId<double> : __TypeID<DS3D_TYPEID_DOUBLE>, __DataTypeVal<DataType::kDouble> {
66 };
67 
68 template <>
69 struct TpId<bool> : __TypeID<DS3D_TYPEID_BOOL>, __DataTypeVal<DataType::kDouble> {
70 };
71 
72 template <>
73 struct TpId<int64_t> : __TypeID<DS3D_TYPEID_INT64_T>, __DataTypeVal<DataType::kInt64> {
74 };
75 
76 template <typename TP>
78  static constexpr DataType _data_type() { return TpId<TP>::_data_type_value(); }
79 };
80 
81 template <DataType t>
82 struct NativeData;
83 
84 template <>
86  using type = float;
87 };
88 
89 template <>
91 #if ENABLE_HALF
92  using type = half_float::half;
93 #else
94  using type = int16_t;
95 #endif
96 };
97 
98 template <>
100  using type = int8_t;
101 };
102 
103 template <>
105  using type = int32_t;
106 };
107 template <>
109  using type = int16_t;
110 };
111 template <>
113  using type = uint8_t;
114 };
115 template <>
117  using type = uint16_t;
118 };
119 template <>
121  using type = uint32_t;
122 };
123 template <>
125  using type = double;
126 };
127 
128 template <>
130  using type = int64_t;
131 };
132 
133 } // namespace ds3d
134 
135 #endif // _DS3D_COMMON_TYPE_TRAIT__H
ds3d::__DataTypeVal
Definition: type_trait.h:37
nvdsinferserver::InferDataType::kInt32
@ kInt32
ds3d::TpId::__typeid
static constexpr TIdType __typeid()
Definition: type_trait.h:28
ds3d::NativeData< DataType::kUint8 >::type
uint8_t type
Definition: type_trait.h:113
ds3d::NativeData
Definition: type_trait.h:82
ds3d::DataType
DataType
Definition: idatatype.h:77
ds3d::NativeData< DataType::kInt8 >::type
int8_t type
Definition: type_trait.h:100
ds3d::__TypeID::__typeid
static constexpr TIdType __typeid()
Definition: type_trait.h:33
ds3d::NativeData< DataType::kInt64 >::type
int64_t type
Definition: type_trait.h:130
nvdsinferserver::InferDataType::kUint8
@ kUint8
ds3d::NativeData< DataType::kFp16 >::type
int16_t type
Definition: type_trait.h:94
ds3d::NativeData< DataType::kFp32 >::type
float type
Definition: type_trait.h:86
ds3d::NativeData< DataType::kInt32 >::type
int32_t type
Definition: type_trait.h:105
ds3d::__TypeID
Definition: type_trait.h:32
ds3d::__DataTypeTrait::_data_type
static constexpr DataType _data_type()
Definition: type_trait.h:78
typeid.h
nvdsinferserver::InferDataType::kInt16
@ kInt16
ds3d::NativeData< DataType::kDouble >::type
double type
Definition: type_trait.h:125
nvdsinferserver::InferDataType::kFp32
@ kFp32
nvdsinferserver::InferDataType::kInt64
@ kInt64
ds3d::NativeData< DataType::kUint32 >::type
uint32_t type
Definition: type_trait.h:121
ds3d::__DataTypeTrait
Definition: type_trait.h:77
nvdsinferserver::InferDataType::kFp16
@ kFp16
common.h
ds3d::DataType::kDouble
@ kDouble
ds3d::TpId
Definition: type_trait.h:27
idatatype.h
ds3d::NativeData< DataType::kInt16 >::type
int16_t type
Definition: type_trait.h:109
nvdsinferserver::InferDataType::kUint32
@ kUint32
ds3d::NativeData< DataType::kUint16 >::type
uint16_t type
Definition: type_trait.h:117
nvdsinferserver::InferDataType::kUint16
@ kUint16
ds3d::TIdType
uint64_t TIdType
Definition: common.h:69
nvdsinferserver::InferDataType::kInt8
@ kInt8
ds3d
Definition: lidar_3d_datatype.h:35
ds3d::__DataTypeVal::_data_type_value
static constexpr DataType _data_type_value()
Definition: type_trait.h:38
cvcore::half
std::uint16_t half
Definition: Tensor.h:22