diff --git a/src/common/conditional_compilation/include/openvino/cc/factory.h b/src/common/conditional_compilation/include/openvino/cc/factory.h index 532c6916f4e..ea49fde2896 100644 --- a/src/common/conditional_compilation/include/openvino/cc/factory.h +++ b/src/common/conditional_compilation/include/openvino/cc/factory.h @@ -3,7 +3,9 @@ // #pragma once +#include #include +#include #include #include #include @@ -57,6 +59,7 @@ public: template void registerImpl(const Key& key, const char* typeName) { + validate_type(typeName); const std::string task_name = "REG$" + name + "$" + to_string(key) + "$" + typeName; openvino::itt::ScopedTask task(openvino::itt::handle(task_name)); builders[key] = [](Args... args) -> T { @@ -109,6 +112,14 @@ public: } private: + void validate_type(const char* name) const { + for (const char* ch = name; *ch; ++ch) { + if (!std::isalnum(*ch) && *ch != '_') + throw std::runtime_error(std::string("Invalid identifier name: '") + name + + "'. Allowed characters should be alphanumeric or '_'"); + } + } + const std::string& to_string(const std::string& str) const noexcept { return str; } diff --git a/src/plugins/intel_cpu/src/nodes_factory.cpp b/src/plugins/intel_cpu/src/nodes_factory.cpp index 2e2b0990fab..12b1c528149 100644 --- a/src/plugins/intel_cpu/src/nodes_factory.cpp +++ b/src/plugins/intel_cpu/src/nodes_factory.cpp @@ -86,10 +86,13 @@ #include "nodes/priorbox.h" #include "nodes/priorbox_clustered.h" +namespace ov { +namespace intel_cpu { + #define INTEL_CPU_NODE(__prim, __type) \ registerNodeIfRequired(intel_cpu, __prim, __type, NodeImpl<__prim>) -ov::intel_cpu::Node::NodesFactory::NodesFactory() +Node::NodesFactory::NodesFactory() : Factory("NodesFactory") { using namespace node; INTEL_CPU_NODE(Generic, Type::Generic); @@ -112,8 +115,8 @@ ov::intel_cpu::Node::NodesFactory::NodesFactory() INTEL_CPU_NODE(Eltwise, Type::Eltwise); INTEL_CPU_NODE(SoftMax, Type::Softmax); INTEL_CPU_NODE(EmbeddingBagPackedSum, Type::EmbeddingBagPackedSum); - INTEL_CPU_NODE(node::Input, Type::Input); - INTEL_CPU_NODE(node::Input, Type::Output); + INTEL_CPU_NODE(Input, Type::Input); + INTEL_CPU_NODE(Input, Type::Output); INTEL_CPU_NODE(MemoryInput, Type::MemoryInput); INTEL_CPU_NODE(MemoryOutput, Type::MemoryOutput); INTEL_CPU_NODE(Tile, Type::Tile); @@ -182,3 +185,6 @@ ov::intel_cpu::Node::NodesFactory::NodesFactory() } #undef INTEL_CPU_NODE + +} // namespace intel_cpu +} // namespace ov