29 #include "ngraph/attribute_adapter.hpp"
30 #include "ngraph/deprecated.hpp"
31 #include "ngraph/except.hpp"
32 #include "ngraph/ngraph_visibility.hpp"
33 #include "ngraph/type/bfloat16.hpp"
34 #include "ngraph/type/float16.hpp"
64 : m_type{element::Type_t::undefined}
68 constexpr
Type(
const Type_t t)
76 const std::string& cname);
77 Type& operator=(
const Type&) =
default;
78 const std::string& c_type_string()
const;
81 bool is_static()
const;
82 bool is_dynamic()
const {
return !is_static(); }
86 bool is_integral()
const {
return !is_real(); }
87 bool is_integral_number()
const;
88 bool is_signed()
const;
89 bool is_quantized()
const;
90 size_t bitwidth()
const;
92 const std::string& get_type_name()
const;
93 friend NGRAPH_API std::ostream& operator<<(std::ostream&,
const Type&);
94 static std::vector<const Type*> get_known_types();
122 constexpr
operator Type_t()
const {
return m_type; }
124 Type_t m_type{Type_t::undefined};
127 typedef std::vector<Type> TypeVector;
129 constexpr Type undefined(Type_t::undefined);
130 constexpr Type dynamic(Type_t::dynamic);
131 constexpr Type boolean(Type_t::boolean);
132 constexpr Type bf16(Type_t::bf16);
133 constexpr Type f16(Type_t::f16);
134 constexpr Type f32(Type_t::f32);
135 constexpr Type f64(Type_t::f64);
136 constexpr Type i8(Type_t::i8);
137 constexpr Type i16(Type_t::i16);
138 constexpr Type i32(Type_t::i32);
139 constexpr Type i64(Type_t::i64);
140 constexpr Type u1(Type_t::u1);
141 constexpr Type u8(Type_t::u8);
142 constexpr Type u16(Type_t::u16);
143 constexpr Type u32(Type_t::u32);
144 constexpr Type u64(Type_t::u64);
146 template <
typename T>
149 throw std::invalid_argument(
"Unknown type");
152 NGRAPH_API Type from<char>();
154 NGRAPH_API Type from<bool>();
156 NGRAPH_API Type from<float>();
158 NGRAPH_API Type from<double>();
160 NGRAPH_API Type from<int8_t>();
162 NGRAPH_API Type from<int16_t>();
164 NGRAPH_API Type from<int32_t>();
166 NGRAPH_API Type from<int64_t>();
168 NGRAPH_API Type from<uint8_t>();
170 NGRAPH_API Type from<uint16_t>();
172 NGRAPH_API Type from<uint32_t>();
174 NGRAPH_API Type from<uint64_t>();
176 NGRAPH_API Type from<ngraph::bfloat16>();
178 NGRAPH_API Type from<ngraph::float16>();
194 static constexpr
DiscreteTypeInfo type_info{
"AttributeAdapter<element::Type_t>", 0};
195 const DiscreteTypeInfo& get_type_info()
const override {
return type_info; }
207 const std::string&
get()
override;
208 void set(
const std::string& value)
override;
210 static constexpr
DiscreteTypeInfo type_info{
"AttributeAdapter<element::Type>", 0};
211 const DiscreteTypeInfo& get_type_info()
const override {
return type_info; }
212 operator element::Type&() {
return m_ref; }
214 element::Type& m_ref;
const std::string & get() override
Returns the value.
void set(const std::string &value) override
Sets the value.
An AttributeAdapter "captures" an attribute as an AT& and makes it available as a ValueAccessor<VAT>.
Definition: attribute_adapter.hpp:171
Access an enum via a string.
Definition: attribute_adapter.hpp:178
Provides access to an attribute of type AT as a value accessor type VAT.
Definition: attribute_adapter.hpp:61
Definition: element_type.hpp:61
static bool merge(element::Type &dst, const element::Type &t1, const element::Type &t2)
Merges two element types t1 and t2, writing the result into dst and returning true if successful,...
bool compatible(const element::Type &t) const
Checks whether this element type is merge-compatible with t.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
size_t compiler_byte_size(element::Type_t et)
Return the number of bytes in the compile-time representation of the element type.