element_type_traits.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //*****************************************************************************
16 
17 #pragma once
18 
19 #include "ngraph/type/element_type.hpp"
20 
21 namespace ngraph
22 {
23  template <element::Type_t>
25  {
26  };
27 
28  template <>
29  struct element_type_traits<element::Type_t::boolean>
30  {
31  using value_type = char;
32  };
33 
34  template <>
35  struct element_type_traits<element::Type_t::bf16>
36  {
37  using value_type = bfloat16;
38  };
39 
40  template <>
41  struct element_type_traits<element::Type_t::f16>
42  {
43  using value_type = float16;
44  };
45 
46  template <>
47  struct element_type_traits<element::Type_t::f32>
48  {
49  using value_type = float;
50  };
51 
52  template <>
53  struct element_type_traits<element::Type_t::f64>
54  {
55  using value_type = double;
56  };
57 
58  template <>
59  struct element_type_traits<element::Type_t::i8>
60  {
61  using value_type = int8_t;
62  };
63 
64  template <>
65  struct element_type_traits<element::Type_t::i16>
66  {
67  using value_type = int16_t;
68  };
69 
70  template <>
71  struct element_type_traits<element::Type_t::i32>
72  {
73  using value_type = int32_t;
74  };
75 
76  template <>
77  struct element_type_traits<element::Type_t::i64>
78  {
79  using value_type = int64_t;
80  };
81 
82  template <>
83  struct element_type_traits<element::Type_t::u1>
84  {
85  using value_type = int8_t;
86  };
87 
88  template <>
89  struct element_type_traits<element::Type_t::u8>
90  {
91  using value_type = uint8_t;
92  };
93 
94  template <>
95  struct element_type_traits<element::Type_t::u16>
96  {
97  using value_type = uint16_t;
98  };
99 
100  template <>
101  struct element_type_traits<element::Type_t::u32>
102  {
103  using value_type = uint32_t;
104  };
105 
106  template <>
107  struct element_type_traits<element::Type_t::u64>
108  {
109  using value_type = uint64_t;
110  };
111 }
Definition: bfloat16.hpp:33
Definition: float16.hpp:33
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: element_type_traits.hpp:25