Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 388cd82

Browse files
jmenonAdam Procter
authored andcommitted
Force correct initialization order for ctors
1 parent 91c6cba commit 388cd82

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/ngraph/runtime/cpu/cpu_builder.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff 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);

src/ngraph/runtime/cpu/cpu_builder.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@
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
{

src/ngraph/runtime/cpu/cpu_external_function.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)