HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
to_tensor_proto_element_type.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License.
3 
4 #pragma once
5 
6 #include <cstdint>
7 #include <string>
8 
9 #ifndef SHARED_PROVIDER
10 #include "onnx/onnx_pb.h"
11 #endif
12 
13 #include "core/framework/float16.h"
14 
15 namespace onnxruntime {
16 namespace utils {
17 /** Gets the TensorProto_DataType corresponding to the template type `T`. */
18 template <typename T>
19 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType() {
20  return ONNX_NAMESPACE::TensorProto_DataType_UNDEFINED;
21 }
22 template <>
23 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<float>() {
24  return ONNX_NAMESPACE::TensorProto_DataType_FLOAT;
25 }
26 template <>
27 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<uint8_t>() {
28  return ONNX_NAMESPACE::TensorProto_DataType_UINT8;
29 }
30 template <>
31 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<int8_t>() {
32  return ONNX_NAMESPACE::TensorProto_DataType_INT8;
33 }
34 template <>
35 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<uint16_t>() {
36  return ONNX_NAMESPACE::TensorProto_DataType_UINT16;
37 }
38 template <>
39 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<int16_t>() {
40  return ONNX_NAMESPACE::TensorProto_DataType_INT16;
41 }
42 template <>
43 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<int32_t>() {
44  return ONNX_NAMESPACE::TensorProto_DataType_INT32;
45 }
46 template <>
47 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<int64_t>() {
48  return ONNX_NAMESPACE::TensorProto_DataType_INT64;
49 }
50 template <>
51 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<std::string>() {
52  return ONNX_NAMESPACE::TensorProto_DataType_STRING;
53 }
54 template <>
55 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<bool>() {
56  return ONNX_NAMESPACE::TensorProto_DataType_BOOL;
57 }
58 template <>
59 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<MLFloat16>() {
60  return ONNX_NAMESPACE::TensorProto_DataType_FLOAT16;
61 }
62 template <>
63 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<double>() {
64  return ONNX_NAMESPACE::TensorProto_DataType_DOUBLE;
65 }
66 template <>
67 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<uint32_t>() {
68  return ONNX_NAMESPACE::TensorProto_DataType_UINT32;
69 }
70 template <>
71 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<uint64_t>() {
72  return ONNX_NAMESPACE::TensorProto_DataType_UINT64;
73 }
74 template <>
75 constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType<BFloat16>() {
76  return ONNX_NAMESPACE::TensorProto_DataType_BFLOAT16;
77 }
78 } // namespace utils
79 } // namespace onnxruntime
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< uint8_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< uint32_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< bool >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< int32_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< uint16_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< uint64_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< int8_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< MLFloat16 >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< int64_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< int16_t >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< BFloat16 >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< double >()
constexpr ONNX_NAMESPACE::TensorProto_DataType ToTensorProtoElementType< float >()