Commit 19b2e90a authored by Jaikrishnan Menon's avatar Jaikrishnan Menon Committed by Robert Kimball

Force correct initialization order for ctors (#1666)

parent c671a2b7
...@@ -362,10 +362,15 @@ namespace ngraph ...@@ -362,10 +362,15 @@ namespace ngraph
#define TI(x) type_index(typeid(x)) #define TI(x) type_index(typeid(x))
BuildOpMap build_dispatcher{ BuildOpMap& GetGlobalBuildDispatcher()
{TI(ngraph::op::Parameter), &runtime::cpu::Builder::nop}, {
{TI(ngraph::runtime::cpu::op::ConvertLayout), static BuildOpMap build_dispatcher{
&runtime::cpu::Builder::build<ngraph::runtime::cpu::op::ConvertLayout>}}; {TI(ngraph::op::Parameter), &runtime::cpu::Builder::nop},
{TI(ngraph::runtime::cpu::op::ConvertLayout),
&runtime::cpu::Builder::build<ngraph::runtime::cpu::op::ConvertLayout>}};
return build_dispatcher;
}
REGISTER_OP_BUILDER(Constant); REGISTER_OP_BUILDER(Constant);
REGISTER_OP_BUILDER(Result); REGISTER_OP_BUILDER(Result);
......
...@@ -220,8 +220,8 @@ ...@@ -220,8 +220,8 @@
{ \ { \
__register_##OP##_builder() \ __register_##OP##_builder() \
{ \ { \
build_dispatcher.insert({type_index(typeid(ngraph::op::OP)), \ GetGlobalBuildDispatcher().insert({type_index(typeid(ngraph::op::OP)), \
&runtime::cpu::Builder::build<ngraph::op::OP>}); \ &runtime::cpu::Builder::build<ngraph::op::OP>}); \
} \ } \
} __register_##OP##_builder_instance; } __register_##OP##_builder_instance;
...@@ -239,7 +239,7 @@ namespace ngraph ...@@ -239,7 +239,7 @@ namespace ngraph
using BuildOpMap = std::unordered_map<std::type_index, BuildOpFunction>; using BuildOpMap = std::unordered_map<std::type_index, BuildOpFunction>;
extern BuildOpMap build_dispatcher; BuildOpMap& GetGlobalBuildDispatcher();
class Builder class Builder
{ {
......
...@@ -1257,8 +1257,8 @@ void runtime::cpu::CPU_ExternalFunction::build() ...@@ -1257,8 +1257,8 @@ void runtime::cpu::CPU_ExternalFunction::build()
} }
auto& n = *node; // Work around a compiler warning (*node inside typeid may have effects auto& n = *node; // Work around a compiler warning (*node inside typeid may have effects
// with shared pointers, which is fine here but clang doesn't like it.) // with shared pointers, which is fine here but clang doesn't like it.)
auto handler = build_dispatcher.find(type_index(typeid(n))); auto handler = GetGlobalBuildDispatcher().find(type_index(typeid(n)));
if (handler == build_dispatcher.end()) if (handler == GetGlobalBuildDispatcher().end())
{ {
throw unsupported_op(node->description()); throw unsupported_op(node->description());
} }
......
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