Unverified Commit ab1e9aa2 authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Avoid static initialization issues (#3492)

Static type holders can be initialized after things that make copies of them
are run, leading to `undefined` as the type in the copies.
parent 8cde4078
......@@ -157,74 +157,74 @@ namespace ngraph
namespace element
{
template <>
const Type& from<char>()
Type from<char>()
{
return element::boolean;
return Type_t::boolean;
}
template <>
const Type& from<bool>()
Type from<bool>()
{
return boolean;
return Type_t::boolean;
}
template <>
const Type& from<ngraph::float16>()
Type from<ngraph::float16>()
{
return f16;
return Type_t::f16;
}
template <>
const Type& from<float>()
Type from<float>()
{
return f32;
return Type_t::f32;
}
template <>
const Type& from<double>()
Type from<double>()
{
return f64;
return Type_t::f64;
}
template <>
const Type& from<int8_t>()
Type from<int8_t>()
{
return i8;
return Type_t::i8;
}
template <>
const Type& from<int16_t>()
Type from<int16_t>()
{
return i16;
return Type_t::i16;
}
template <>
const Type& from<int32_t>()
Type from<int32_t>()
{
return i32;
return Type_t::i32;
}
template <>
const Type& from<int64_t>()
Type from<int64_t>()
{
return i64;
return Type_t::i64;
}
template <>
const Type& from<uint8_t>()
Type from<uint8_t>()
{
return u8;
return Type_t::u8;
}
template <>
const Type& from<uint16_t>()
Type from<uint16_t>()
{
return u16;
return Type_t::u16;
}
template <>
const Type& from<uint32_t>()
Type from<uint32_t>()
{
return u32;
return Type_t::u32;
}
template <>
const Type& from<uint64_t>()
Type from<uint64_t>()
{
return u64;
return Type_t::u64;
}
template <>
const Type& from<ngraph::bfloat16>()
Type from<ngraph::bfloat16>()
{
return bf16;
return Type_t::bf16;
}
}
}
......
......@@ -145,38 +145,38 @@ namespace ngraph
extern NGRAPH_API const Type u64;
template <typename T>
const Type& from()
Type from()
{
throw std::invalid_argument("Unknown type");
}
template <>
const Type& from<char>();
Type from<char>();
template <>
const Type& from<bool>();
Type from<bool>();
template <>
const Type& from<float>();
Type from<float>();
template <>
const Type& from<double>();
Type from<double>();
template <>
const Type& from<int8_t>();
Type from<int8_t>();
template <>
const Type& from<int16_t>();
Type from<int16_t>();
template <>
const Type& from<int32_t>();
Type from<int32_t>();
template <>
const Type& from<int64_t>();
Type from<int64_t>();
template <>
const Type& from<uint8_t>();
Type from<uint8_t>();
template <>
const Type& from<uint16_t>();
Type from<uint16_t>();
template <>
const Type& from<uint32_t>();
Type from<uint32_t>();
template <>
const Type& from<uint64_t>();
Type from<uint64_t>();
template <>
const Type& from<ngraph::bfloat16>();
Type from<ngraph::bfloat16>();
template <>
const Type& from<ngraph::float16>();
Type from<ngraph::float16>();
std::ostream& operator<<(std::ostream& out, const ngraph::element::Type& obj);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment