This repository was archived by the owner on Jan 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -362,10 +362,15 @@ namespace ngraph
362362
363363#define TI (x ) type_index(typeid (x))
364364
365- BuildOpMap build_dispatcher{
366- {TI (ngraph::op::Parameter), &runtime::cpu::Builder::nop},
367- {TI (ngraph::runtime::cpu::op::ConvertLayout),
368- &runtime::cpu::Builder::build<ngraph::runtime::cpu::op::ConvertLayout>}};
365+ BuildOpMap& GetGlobalBuildDispatcher ()
366+ {
367+ static BuildOpMap build_dispatcher{
368+ {TI (ngraph::op::Parameter), &runtime::cpu::Builder::nop},
369+ {TI (ngraph::runtime::cpu::op::ConvertLayout),
370+ &runtime::cpu::Builder::build<ngraph::runtime::cpu::op::ConvertLayout>}};
371+
372+ return build_dispatcher;
373+ }
369374
370375 REGISTER_OP_BUILDER (Constant);
371376 REGISTER_OP_BUILDER (Result);
Original file line number Diff line number Diff line change 220220 { \
221221 __register_##OP##_builder() \
222222 { \
223- build_dispatcher .insert ({type_index (typeid (ngraph::op::OP)), \
224- &runtime::cpu::Builder::build<ngraph::op::OP>}); \
223+ GetGlobalBuildDispatcher () .insert ({type_index (typeid (ngraph::op::OP)), \
224+ &runtime::cpu::Builder::build<ngraph::op::OP>}); \
225225 } \
226226 } __register_##OP##_builder_instance;
227227
@@ -239,7 +239,7 @@ namespace ngraph
239239
240240 using BuildOpMap = std::unordered_map<std::type_index, BuildOpFunction>;
241241
242- extern BuildOpMap build_dispatcher ;
242+ BuildOpMap& GetGlobalBuildDispatcher () ;
243243
244244 class Builder
245245 {
Original file line number Diff line number Diff line change @@ -1253,8 +1253,8 @@ void runtime::cpu::CPU_ExternalFunction::build()
12531253 }
12541254 auto & n = *node; // Work around a compiler warning (*node inside typeid may have effects
12551255 // with shared pointers, which is fine here but clang doesn't like it.)
1256- auto handler = build_dispatcher .find (type_index (typeid (n)));
1257- if (handler == build_dispatcher .end ())
1256+ auto handler = GetGlobalBuildDispatcher () .find (type_index (typeid (n)));
1257+ if (handler == GetGlobalBuildDispatcher () .end ())
12581258 {
12591259 throw unsupported_op (node->description ());
12601260 }
You can’t perform that action at this time.
0 commit comments