diff --git a/cmake/developer_package/plugins/create_plugins_hpp.cmake b/cmake/developer_package/plugins/create_plugins_hpp.cmake index 1fedf858ce5..2c90da6cc9d 100644 --- a/cmake/developer_package/plugins/create_plugins_hpp.cmake +++ b/cmake/developer_package/plugins/create_plugins_hpp.cmake @@ -42,10 +42,10 @@ foreach(dev_map IN LISTS OV_DEVICE_MAPPING) # declarations set(OV_PLUGINS_DECLARATIONS "${OV_PLUGINS_DECLARATIONS} - IE_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(${_OV_CREATE_PLUGIN_FUNC});") + OV_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(${_OV_CREATE_PLUGIN_FUNC});") if(${actual_dev_name}_AS_EXTENSION) set(OV_PLUGINS_DECLARATIONS "${OV_PLUGINS_DECLARATIONS} - IE_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(${_OV_CREATE_EXTENSION_FUNC});") + OV_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(${_OV_CREATE_EXTENSION_FUNC});") else() set(_OV_CREATE_EXTENSION_FUNC "nullptr") endif() diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index 16a9e935a89..a8ee3e47d25 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -80,7 +80,7 @@ function(ov_add_plugin) if(OV_PLUGIN_AS_EXTENSION) # to distinguish functions creating extensions objects target_compile_definitions(${OV_PLUGIN_NAME} PRIVATE - IE_CREATE_EXTENSION=CreateExtensionShared${OV_PLUGIN_DEVICE_NAME}) + OV_CREATE_EXTENSION=CreateExtensionShared${OV_PLUGIN_DEVICE_NAME}) endif() endif() diff --git a/cmake/developer_package/plugins/plugins.hpp.in b/cmake/developer_package/plugins/plugins.hpp.in index 224f77c8cb9..2af0666e7b8 100644 --- a/cmake/developer_package/plugins/plugins.hpp.in +++ b/cmake/developer_package/plugins/plugins.hpp.in @@ -9,13 +9,23 @@ #ifdef OPENVINO_STATIC_LIBRARY -#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" +// The Macro used to create extensions for static library +#define OV_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(_OV_CREATE_EXTENSION_FUNC) \ + OPENVINO_EXTENSION_C_API void \ + _OV_CREATE_EXTENSION_FUNC(std::vector<::ov::Extension::Ptr>& ext) + +// The Macro used to create plugin for static library +#define OV_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(_OV_CREATE_PLUGIN_FUNC) \ + OPENVINO_PLUGIN_API void \ + _OV_CREATE_PLUGIN_FUNC(::std::shared_ptr<::ov::IPlugin> &plugin) noexcept(false) @OV_PLUGINS_DECLARATIONS@ +using CreateExtensionFunc = void(std::vector<::ov::Extension::Ptr>&); +using CreatePluginEngineFunc = void(std::shared_ptr<::ov::IPlugin>&); struct Value { - InferenceEngine::CreatePluginEngineFunc * m_create_plugin_func; - InferenceEngine::CreateExtensionFunc * m_create_extension_func; + CreatePluginEngineFunc * m_create_plugin_func; + CreateExtensionFunc * m_create_extension_func; std::map m_default_config; }; diff --git a/src/core/include/openvino/core/extension.hpp b/src/core/include/openvino/core/extension.hpp index 7e02703e628..a403675ad2e 100644 --- a/src/core/include/openvino/core/extension.hpp +++ b/src/core/include/openvino/core/extension.hpp @@ -28,24 +28,28 @@ public: virtual ~Extension(); }; +} // namespace ov +#ifndef OV_CREATE_EXTENSION /** * @brief The entry point for library with OpenVINO extensions * * @param vector of extensions */ OPENVINO_EXTENSION_C_API -void create_extensions(std::vector&); +void create_extensions(std::vector&); -} // namespace ov +# define OV_CREATE_EXTENSION create_extensions + +#endif /** * @brief Macro generates the entry point for the library * * @param vector of extensions */ -#define OPENVINO_CREATE_EXTENSIONS(extensions) \ - OPENVINO_EXTENSION_C_API \ - void ::ov::create_extensions(std::vector<::ov::Extension::Ptr>& ext) { \ - ext = extensions; \ +#define OPENVINO_CREATE_EXTENSIONS(extensions) \ + OPENVINO_EXTENSION_C_API void OV_CREATE_EXTENSION(std::vector& ext); \ + OPENVINO_EXTENSION_C_API void OV_CREATE_EXTENSION(std::vector& ext) { \ + ext = extensions; \ } diff --git a/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp b/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp index 859e56df154..eb0e8d38c46 100644 --- a/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp +++ b/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp @@ -19,6 +19,7 @@ #include "ie_iextension.h" #include "ie_input_info.hpp" #include "ie_parameter.hpp" +#include "openvino/core/extension.hpp" #include "openvino/runtime/iplugin.hpp" #include "openvino/util/pp.hpp" #include "so_ptr.hpp" @@ -377,16 +378,6 @@ protected: bool _isNewAPI; //!< A flag which shows used API }; -/** - * @private - */ -using CreatePluginEngineFunc = void(std::shared_ptr<::ov::IPlugin>&); - -/** - * @private - */ -using CreateExtensionFunc = void(std::shared_ptr&); - /** * @def IE_CREATE_PLUGIN * @brief Defines a name of a function creating plugin instance @@ -428,17 +419,3 @@ convert_plugin(const std::shared_ptr& from); ie_plugin->SetVersion(version); \ plugin = convert_plugin(ie_plugin); \ } - -/** - * @private - */ -#define IE_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(_IE_CREATE_PLUGIN_FUNC) \ - INFERENCE_PLUGIN_API(void) \ - _IE_CREATE_PLUGIN_FUNC(::std::shared_ptr<::ov::IPlugin>& plugin) noexcept(false) - -/** - * @private - */ -#define IE_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(_IE_CREATE_EXTENSION_FUNC) \ - INFERENCE_EXTENSION_API(void) \ - _IE_CREATE_EXTENSION_FUNC(::InferenceEngine::IExtensionPtr& ext) diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp index ced075a2d89..6489f7e4af8 100644 --- a/src/inference/src/dev/core_impl.cpp +++ b/src/inference/src/dev/core_impl.cpp @@ -703,9 +703,9 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& pluginName) const { if (desc.extensionCreateFunc) { // static OpenVINO case try { - InferenceEngine::IExtensionPtr ext; + std::vector ext; desc.extensionCreateFunc(ext); - AddExtensionUnsafe(ext); + add_extensions_unsafe(ext); } catch (const InferenceEngine::GeneralError&) { // the same extension can be registered multiple times - ignore it! } diff --git a/src/inference/src/dev/core_impl.hpp b/src/inference/src/dev/core_impl.hpp index 86365f891fc..2a4415ad941 100644 --- a/src/inference/src/dev/core_impl.hpp +++ b/src/inference/src/dev/core_impl.hpp @@ -26,6 +26,9 @@ namespace ov { +using CreateExtensionFunc = void(std::vector<::ov::Extension::Ptr>&); +using CreatePluginEngineFunc = void(std::shared_ptr<::ov::IPlugin>&); + const std::string DEFAULT_DEVICE_NAME = "DEFAULT_DEVICE"; struct Parsed { @@ -123,8 +126,8 @@ private: ov::util::FilePath libraryLocation; ov::AnyMap defaultConfig; std::vector listOfExtentions; - InferenceEngine::CreatePluginEngineFunc* pluginCreateFunc = nullptr; - InferenceEngine::CreateExtensionFunc* extensionCreateFunc = nullptr; + CreatePluginEngineFunc* pluginCreateFunc = nullptr; + CreateExtensionFunc* extensionCreateFunc = nullptr; PluginDescriptor() = default; @@ -136,9 +139,9 @@ private: this->listOfExtentions = listOfExtentions; } - PluginDescriptor(InferenceEngine::CreatePluginEngineFunc* pluginCreateFunc, + PluginDescriptor(CreatePluginEngineFunc* pluginCreateFunc, const ov::AnyMap& defaultConfig = {}, - InferenceEngine::CreateExtensionFunc* extensionCreateFunc = nullptr) { + CreateExtensionFunc* extensionCreateFunc = nullptr) { this->pluginCreateFunc = pluginCreateFunc; this->defaultConfig = defaultConfig; this->extensionCreateFunc = extensionCreateFunc; diff --git a/src/plugins/intel_cpu/src/compiled_model.cpp b/src/plugins/intel_cpu/src/compiled_model.cpp index f45f1e2a2b7..f81f59f94ae 100644 --- a/src/plugins/intel_cpu/src/compiled_model.cpp +++ b/src/plugins/intel_cpu/src/compiled_model.cpp @@ -40,13 +40,11 @@ struct ImmediateSerialExecutor : public ov::threading::ITaskExecutor { CompiledModel::CompiledModel(const std::shared_ptr& model, const std::shared_ptr& plugin, const Config& cfg, - const ExtensionManager::Ptr& extMgr, const bool loaded_from_cache) : ov::ICompiledModel::ICompiledModel(model, plugin), m_model(model), m_plugin(plugin), m_cfg{cfg}, - extensionManager(extMgr), m_name{model->get_name()}, m_loaded_from_cache(loaded_from_cache) { bool isFloatModel = !ov::op::util::has_op_with_type(m_model); @@ -125,7 +123,7 @@ CompiledModel::GraphGuard::Lock CompiledModel::get_graph() const { (m_cfg.lpTransformsMode == Config::On) && ov::pass::low_precision::LowPrecision::isFunctionQuantized(m_model); - ctx = std::make_shared(m_cfg, extensionManager, weightsCache, isQuantizedFlag); + ctx = std::make_shared(m_cfg, weightsCache, isQuantizedFlag); } const std::shared_ptr model = m_model; graphLock._graph.CreateGraph(model, ctx); @@ -306,7 +304,7 @@ ov::Any CompiledModel::get_property(const std::string& name) const { } void CompiledModel::export_model(std::ostream& modelStream) const { - ModelSerializer serializer(modelStream, extensionManager); + ModelSerializer serializer(modelStream); serializer << m_model; } diff --git a/src/plugins/intel_cpu/src/compiled_model.h b/src/plugins/intel_cpu/src/compiled_model.h index 0561d97e556..d11ece0e8c2 100644 --- a/src/plugins/intel_cpu/src/compiled_model.h +++ b/src/plugins/intel_cpu/src/compiled_model.h @@ -7,7 +7,6 @@ #include #include -#include "extension_mngr.h" #include "graph.h" #include "graph_context.h" #include "openvino/runtime/icompiled_model.hpp" @@ -26,7 +25,6 @@ public: CompiledModel(const std::shared_ptr& model, const std::shared_ptr& plugin, const Config& cfg, - const ExtensionManager::Ptr& extMgr, const bool loaded_from_cache = false); std::shared_ptr create_infer_request() const override; @@ -55,7 +53,6 @@ private: // Usage example: helps to avoid data races during CPU Graph initialization in multi-streams scenario std::shared_ptr m_mutex; Config m_cfg; - ExtensionManager::Ptr extensionManager; mutable std::atomic_int m_numRequests = {0}; std::string m_name; struct GraphGuard : public Graph { diff --git a/src/plugins/intel_cpu/src/extension.cpp b/src/plugins/intel_cpu/src/extension.cpp index 9cda1c4fa26..41d91bfc382 100644 --- a/src/plugins/intel_cpu/src/extension.cpp +++ b/src/plugins/intel_cpu/src/extension.cpp @@ -2,204 +2,137 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "extension.h" +#include "openvino/core/extension.hpp" + +#include "openvino/core/op_extension.hpp" +#include "ov_ops/augru_cell.hpp" +#include "ov_ops/augru_sequence.hpp" +#include "ov_ops/multiclass_nms_ie_internal.hpp" +#include "ov_ops/nms_ie_internal.hpp" +#include "ov_ops/nms_static_shape_ie.hpp" +#include "ov_ops/type_relaxed.hpp" +#include "snippets/op/subgraph.hpp" #include "transformations/cpu_opset/common/op/fully_connected.hpp" #include "transformations/cpu_opset/common/op/leaky_relu.hpp" +#include "transformations/cpu_opset/common/op/ngram.hpp" #include "transformations/cpu_opset/common/op/power_static.hpp" #include "transformations/cpu_opset/common/op/sdpa.hpp" #include "transformations/cpu_opset/common/op/swish_cpu.hpp" -#include "transformations/cpu_opset/common/op/ngram.hpp" -#include "transformations/cpu_opset/x64/op/mha.hpp" #include "transformations/cpu_opset/x64/op/interaction.hpp" -#include "transformations/snippets/x64/op/load_convert.hpp" -#include "transformations/snippets/x64/op/store_convert.hpp" -#include "transformations/snippets/x64/op/brgemm_cpu.hpp" +#include "transformations/cpu_opset/x64/op/mha.hpp" #include "transformations/snippets/x64/op/brgemm_copy_b.hpp" +#include "transformations/snippets/x64/op/brgemm_cpu.hpp" +#include "transformations/snippets/x64/op/load_convert.hpp" #include "transformations/snippets/x64/op/perf_count_rdtsc.hpp" +#include "transformations/snippets/x64/op/store_convert.hpp" -#include -#include -#include -#include -#include -#include - -#include "snippets/op/subgraph.hpp" - -#include - -namespace ov { -namespace intel_cpu { - -void Extension::GetVersion(const InferenceEngine::Version*& versionInfo) const noexcept { - static const InferenceEngine::Version version = { - {1, 0}, // extension API version - "1.0", - "Extension" // extension description message - }; - - versionInfo = &version; -} - -void Extension::Unload() noexcept {} - -std::map Extension::getOpSets() { - auto cpu_plugin_opset = []() { - ngraph::OpSet opset; +#define OP_EXTENSION(NAME) std::make_shared>(), #if defined(OPENVINO_ARCH_X86_64) -#define NGRAPH_OP_X64(NAME, NAMESPACE) NGRAPH_OP(NAME, NAMESPACE) +# define OP_EXTENSION_X64(NAME) OP_EXTENSION(NAME) #else -#define NGRAPH_OP_X64(NAME, NAMESPACE) +# define OP_EXTENSION_X64(NAME) #endif -#define NGRAPH_OP(NAME, NAMESPACE) opset.insert(); - NGRAPH_OP(FullyConnectedNode, ov::intel_cpu) - NGRAPH_OP(LeakyReluNode, ov::intel_cpu) - NGRAPH_OP(PowerStaticNode, ov::intel_cpu) - NGRAPH_OP(SwishNode, ov::intel_cpu) - NGRAPH_OP(NgramNode, ov::intel_cpu) - NGRAPH_OP_X64(MHANode, ov::intel_cpu) - NGRAPH_OP_X64(InteractionNode, ov::intel_cpu) - NGRAPH_OP_X64(ScaledDotProductAttentionWithKVCache, ov::intel_cpu) -#undef NGRAPH_OP +#define CPU_EXTENSIONS \ + OP_EXTENSION(ov::intel_cpu::FullyConnectedNode) \ + OP_EXTENSION(ov::intel_cpu::LeakyReluNode) \ + OP_EXTENSION(ov::intel_cpu::PowerStaticNode) \ + OP_EXTENSION(ov::intel_cpu::SwishNode) \ + OP_EXTENSION(ov::intel_cpu::NgramNode) \ + OP_EXTENSION(ov::op::internal::NonMaxSuppressionIEInternal) \ + OP_EXTENSION(ov::op::internal::MulticlassNmsIEInternal) \ + OP_EXTENSION(ov::op::internal::AUGRUCell) \ + OP_EXTENSION(ov::op::internal::AUGRUSequence) \ + OP_EXTENSION(ov::op::internal::NmsStaticShapeIE) \ + OP_EXTENSION_X64(ov::intel_cpu::MHANode) \ + OP_EXTENSION_X64(ov::intel_cpu::InteractionNode) \ + OP_EXTENSION_X64(ov::intel_cpu::ScaledDotProductAttentionWithKVCache) \ + OP_EXTENSION_X64(ov::intel_cpu::LoadConvertSaturation) \ + OP_EXTENSION_X64(ov::intel_cpu::LoadConvertTruncation) \ + OP_EXTENSION_X64(ov::intel_cpu::StoreConvertSaturation) \ + OP_EXTENSION_X64(ov::intel_cpu::StoreConvertTruncation) \ + OP_EXTENSION_X64(ov::intel_cpu::BrgemmCPU) \ + OP_EXTENSION_X64(ov::intel_cpu::BrgemmCopyB) - return opset; - }; +#define TYPE_RELAXED_EXTENSIONS \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) \ + OP_EXTENSION(ov::op::TypeRelaxed) - auto type_relaxed_opset = []() { - ngraph::OpSet opset; - -#define NGRAPH_OP(NAME, NAMESPACE) opset.insert>(); - NGRAPH_OP(Add, ov::op::v1) - NGRAPH_OP(AvgPool, ov::op::v1) - NGRAPH_OP(Clamp, ov::op::v0) - NGRAPH_OP(Concat, ov::op::v0) - NGRAPH_OP(Convolution, ov::op::v1) - NGRAPH_OP(ConvolutionBackpropData, ov::op::v1) - NGRAPH_OP(DepthToSpace, ov::op::v0) - NGRAPH_OP(Equal, ov::op::v1) - NGRAPH_OP(FakeQuantize, ov::op::v0) - NGRAPH_OP(Greater, ov::op::v1) - NGRAPH_OP(GreaterEqual, ov::op::v1) - NGRAPH_OP(GroupConvolution, ov::op::v1) - NGRAPH_OP(GroupConvolutionBackpropData, ov::op::v1) - NGRAPH_OP(Interpolate, ov::op::v0) - NGRAPH_OP(Interpolate, ov::op::v4) - NGRAPH_OP(Less, ov::op::v1) - NGRAPH_OP(LessEqual, ov::op::v1) - NGRAPH_OP(LogicalAnd, ov::op::v1) - NGRAPH_OP(LogicalNot, ov::op::v1) - NGRAPH_OP(LogicalOr, ov::op::v1) - NGRAPH_OP(LogicalXor, ov::op::v1) - NGRAPH_OP(MatMul, ov::op::v0) - NGRAPH_OP(MaxPool, ov::op::v1) - NGRAPH_OP(Multiply, ov::op::v1) - NGRAPH_OP(NormalizeL2, ov::op::v0) - NGRAPH_OP(NotEqual, ov::op::v1) - NGRAPH_OP(PRelu, ov::op::v0) - NGRAPH_OP(Relu, ov::op::v0) - NGRAPH_OP(ReduceMax, ov::op::v1) - NGRAPH_OP(ReduceLogicalAnd, ov::op::v1) - NGRAPH_OP(ReduceLogicalOr, ov::op::v1) - NGRAPH_OP(ReduceMean, ov::op::v1) - NGRAPH_OP(ReduceMin, ov::op::v1) - NGRAPH_OP(ReduceSum, ov::op::v1) - NGRAPH_OP(Reshape, ov::op::v1) - NGRAPH_OP(Select, ov::op::v1) - NGRAPH_OP(ShapeOf, ov::op::v0) - NGRAPH_OP(ShuffleChannels, ov::op::v0) - NGRAPH_OP(Squeeze, ov::op::v0) - NGRAPH_OP(Subtract, ov::op::v1) - NGRAPH_OP(Unsqueeze, ov::op::v0) - NGRAPH_OP(MVN, ov::op::v0) - NGRAPH_OP(MVN, ov::op::v6) - NGRAPH_OP(Select, ov::op::v1) - NGRAPH_OP(ConvolutionBackpropData, ov::op::v1) -#undef NGRAPH_OP - - return opset; - }; - - auto ie_internal_opset = []() { - ngraph::OpSet opset; - -#define NGRAPH_OP(NAME, NAMESPACE) opset.insert(); - NGRAPH_OP(NonMaxSuppressionIEInternal, ov::op::internal) - NGRAPH_OP(MulticlassNmsIEInternal, ov::op::internal) - NGRAPH_OP(AUGRUCell, ov::op::internal) - NGRAPH_OP(AUGRUSequence, ov::op::internal) - NGRAPH_OP(NmsStaticShapeIE, ov::op::internal) -#undef NGRAPH_OP - - return opset; - }; - - auto snippets_opset = []() { - ngraph::OpSet opset; - -#define NGRAPH_OP(NAME, NAMESPACE) opset.insert(); - NGRAPH_OP(Brgemm, ov::snippets::op) - NGRAPH_OP(BroadcastLoad, ov::snippets::op) - NGRAPH_OP(BroadcastMove, ov::snippets::op) - NGRAPH_OP(ConvertSaturation, ov::snippets::op) - NGRAPH_OP(ConvertTruncation, ov::snippets::op) - NGRAPH_OP(Fill, ov::snippets::op) - NGRAPH_OP(HorizonMax, ov::snippets::op) - NGRAPH_OP(HorizonSum, ov::snippets::op) - NGRAPH_OP(Kernel, ov::snippets::op) - NGRAPH_OP(IntermediateMemoryBuffer, ov::snippets::op) - NGRAPH_OP(Load, ov::snippets::op) - NGRAPH_OP(LoadReshape, ov::snippets::op) - NGRAPH_OP(LoopBegin, ov::snippets::op) - NGRAPH_OP(LoopEnd, ov::snippets::op) - NGRAPH_OP(NewMemoryBuffer, ov::snippets::op) - NGRAPH_OP(Nop, ov::snippets::op) - NGRAPH_OP(PowerStatic, ov::snippets::op) - NGRAPH_OP(Scalar, ov::snippets::op) - NGRAPH_OP(Store, ov::snippets::op) - NGRAPH_OP(Subgraph, ov::snippets::op) - NGRAPH_OP(VectorBuffer, ov::snippets::op) - NGRAPH_OP(RankNormalization, ov::snippets::op) #ifdef SNIPPETS_DEBUG_CAPS - NGRAPH_OP(PerfCountBegin, ov::snippets::op) - NGRAPH_OP(PerfCountEnd, ov::snippets::op) +# define SNIPPETS_DEBUG_CAPS_EXTENSIONS \ + OP_EXTENSION(ov::snippets::op::PerfCountBegin) \ + OP_EXTENSION(ov::snippets::op::PerfCountEnd) \ + OP_EXTENSION_X64(ov::intel_cpu::PerfCountRdtscBegin) \ + OP_EXTENSION_X64(ov::intel_cpu::PerfCountRdtscEnd) +#else +# define SNIPPETS_DEBUG_CAPS_EXTENSIONS #endif - NGRAPH_OP_X64(LoadConvertSaturation, ov::intel_cpu) - NGRAPH_OP_X64(LoadConvertTruncation, ov::intel_cpu) - NGRAPH_OP_X64(StoreConvertSaturation, ov::intel_cpu) - NGRAPH_OP_X64(StoreConvertTruncation, ov::intel_cpu) - NGRAPH_OP_X64(BrgemmCPU, ov::intel_cpu) - NGRAPH_OP_X64(BrgemmCopyB, ov::intel_cpu) -#ifdef SNIPPETS_DEBUG_CAPS - NGRAPH_OP_X64(PerfCountRdtscBegin, ov::intel_cpu) - NGRAPH_OP_X64(PerfCountRdtscEnd, ov::intel_cpu) -#endif -#undef NGRAPH_OP - return opset; - }; +#define SNIPPETS_EXTENSIONS \ + OP_EXTENSION(ov::snippets::op::Brgemm) \ + OP_EXTENSION(ov::snippets::op::BroadcastLoad) \ + OP_EXTENSION(ov::snippets::op::BroadcastMove) \ + OP_EXTENSION(ov::snippets::op::ConvertSaturation) \ + OP_EXTENSION(ov::snippets::op::ConvertTruncation) \ + OP_EXTENSION(ov::snippets::op::Fill) \ + OP_EXTENSION(ov::snippets::op::HorizonMax) \ + OP_EXTENSION(ov::snippets::op::HorizonSum) \ + OP_EXTENSION(ov::snippets::op::Kernel) \ + OP_EXTENSION(ov::snippets::op::IntermediateMemoryBuffer) \ + OP_EXTENSION(ov::snippets::op::Load) \ + OP_EXTENSION(ov::snippets::op::LoadReshape) \ + OP_EXTENSION(ov::snippets::op::LoopBegin) \ + OP_EXTENSION(ov::snippets::op::LoopEnd) \ + OP_EXTENSION(ov::snippets::op::NewMemoryBuffer) \ + OP_EXTENSION(ov::snippets::op::Nop) \ + OP_EXTENSION(ov::snippets::op::PowerStatic) \ + OP_EXTENSION(ov::snippets::op::Scalar) \ + OP_EXTENSION(ov::snippets::op::Store) \ + OP_EXTENSION(ov::snippets::op::Subgraph) \ + OP_EXTENSION(ov::snippets::op::VectorBuffer) \ + OP_EXTENSION(ov::snippets::op::RankNormalization) - static std::map opsets = { - { "cpu_plugin_opset", cpu_plugin_opset() }, - { "type_relaxed_opset", type_relaxed_opset() }, - { "ie_internal_opset", ie_internal_opset() }, - { "SnippetsOpset", snippets_opset() }, - }; - - return opsets; -} - -std::vector Extension::getImplTypes(const std::shared_ptr&) { - return {}; -} - -InferenceEngine::ILayerImpl::Ptr Extension::getImplementation(const std::shared_ptr& node, const std::string& implType) { - return nullptr; -} - -} // namespace intel_cpu -} // namespace ov - -// Generate exported function -IE_DEFINE_EXTENSION_CREATE_FUNCTION(ov::intel_cpu::Extension) +OPENVINO_CREATE_EXTENSIONS(std::vector( + {CPU_EXTENSIONS TYPE_RELAXED_EXTENSIONS SNIPPETS_EXTENSIONS SNIPPETS_DEBUG_CAPS_EXTENSIONS})); diff --git a/src/plugins/intel_cpu/src/extension.h b/src/plugins/intel_cpu/src/extension.h deleted file mode 100644 index 6d36a20b38a..00000000000 --- a/src/plugins/intel_cpu/src/extension.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace intel_cpu { - -class Extension : public InferenceEngine::IExtension { -public: - void GetVersion(const InferenceEngine::Version*& versionInfo) const noexcept override; - void Unload() noexcept override; - std::map getOpSets() override; - std::vector getImplTypes(const std::shared_ptr& node) override; - InferenceEngine::ILayerImpl::Ptr getImplementation(const std::shared_ptr& node, const std::string& implType) override; -}; - -} // namespace intel_cpu -} // namespace ov diff --git a/src/plugins/intel_cpu/src/extension_mngr.cpp b/src/plugins/intel_cpu/src/extension_mngr.cpp deleted file mode 100644 index d842f227fb5..00000000000 --- a/src/plugins/intel_cpu/src/extension_mngr.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include - -#include "extension_mngr.h" - -using namespace InferenceEngine; - -namespace ov { -namespace intel_cpu { - -void ExtensionManager::AddExtension(const IExtensionPtr& extension) { - _extensions.push_back(extension); -} - -InferenceEngine::ILayerImpl::Ptr ExtensionManager::CreateImplementation(const std::shared_ptr& op) { - if (!op) - OPENVINO_THROW("Cannot get nGraph operation!"); - for (const auto& ext : _extensions) { - auto implTypes = ext->getImplTypes(op); - for (const auto& type : implTypes) { - if (type != "CPU") - continue; - auto impl = ext->getImplementation(op, "CPU"); - if (impl) - return impl; - } - } - return nullptr; -} - -const std::vector & ExtensionManager::Extensions() const { - return _extensions; -} - -} // namespace intel_cpu -} // namespace ov diff --git a/src/plugins/intel_cpu/src/extension_mngr.h b/src/plugins/intel_cpu/src/extension_mngr.h deleted file mode 100644 index 67505861bcd..00000000000 --- a/src/plugins/intel_cpu/src/extension_mngr.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -namespace ov { -namespace intel_cpu { - -class ExtensionManager { -public: - using Ptr = std::shared_ptr; - ExtensionManager() = default; - InferenceEngine::ILayerImpl::Ptr CreateImplementation(const std::shared_ptr& op); - void AddExtension(const InferenceEngine::IExtensionPtr& extension); - const std::vector & Extensions() const; - -private: - std::vector _extensions; -}; - -} // namespace intel_cpu -} // namespace ov diff --git a/src/plugins/intel_cpu/src/graph_context.h b/src/plugins/intel_cpu/src/graph_context.h index 2d90d039ba1..3fc8f7e40fb 100644 --- a/src/plugins/intel_cpu/src/graph_context.h +++ b/src/plugins/intel_cpu/src/graph_context.h @@ -7,7 +7,6 @@ #include "cache/multi_cache.h" #include "config.h" #include "dnnl_scratch_pad.h" -#include "extension_mngr.h" #include "weights_cache.hpp" namespace ov { @@ -19,11 +18,9 @@ public: typedef std::shared_ptr CPtr; GraphContext(const Config& config, - ExtensionManager::Ptr extensionManager, WeightsSharing::Ptr w_cache, bool isGraphQuantized) : config(config), - extensionManager(extensionManager), weightsCache(w_cache), isGraphQuantizedFlag(isGraphQuantized) { rtParamsCache = std::make_shared(config.rtCacheCapacity); @@ -34,10 +31,6 @@ public: return config; } - ExtensionManager::Ptr getExtensionManager() const { - return extensionManager; - } - WeightsSharing::Ptr getWeightsCache() const { return weightsCache; } @@ -60,7 +53,6 @@ public: private: Config config; // network-level config - ExtensionManager::Ptr extensionManager; WeightsSharing::Ptr weightsCache; // per NUMA node caches for sharing weights data MultiCachePtr rtParamsCache; // primitive cache diff --git a/src/plugins/intel_cpu/src/node.cpp b/src/plugins/intel_cpu/src/node.cpp index de686d0ff31..660d2b8d6bd 100644 --- a/src/plugins/intel_cpu/src/node.cpp +++ b/src/plugins/intel_cpu/src/node.cpp @@ -10,7 +10,6 @@ #include "dnnl_extension_utils.h" #include "dnnl_types.h" #include "edge.h" -#include "extension_mngr.h" #include "itt.h" #include "memory_desc/cpu_memory_desc_utils.h" #include "memory_desc/dnnl_blocked_memory_desc.h" @@ -1295,7 +1294,7 @@ Node* Node::NodesFactory::create(const std::shared_ptr& op, const Grap if (newNode == nullptr) { try { std::unique_ptr ol(createNodeIfRegistered(intel_cpu, TypeFromName(op->get_type_name()), op, context)); - if (ol != nullptr && ol->created(context->getExtensionManager())) + if (ol != nullptr && ol->created()) newNode = ol.release(); } catch (const ov::Exception& ex) { if (dynamic_cast(&ex) != nullptr) { @@ -1309,7 +1308,7 @@ Node* Node::NodesFactory::create(const std::shared_ptr& op, const Grap if (newNode == nullptr) { try { std::unique_ptr ol(new Reference(op, context, errorMessage)); - if (ol != nullptr && ol->created(context->getExtensionManager())) + if (ol != nullptr && ol->created()) newNode = ol.release(); } catch (const ov::Exception& ex) { if (dynamic_cast(&ex) != nullptr) { diff --git a/src/plugins/intel_cpu/src/node.h b/src/plugins/intel_cpu/src/node.h index 7601d09c4cd..da529fbefac 100644 --- a/src/plugins/intel_cpu/src/node.h +++ b/src/plugins/intel_cpu/src/node.h @@ -12,8 +12,6 @@ #include "dnnl_postops_composer.h" #include "dnnl_scratch_pad.h" #include "edge.h" -#include "extension_mngr.h" -#include "graph_context.h" #include "nodes/common/blocked_desc_creator.h" #include "nodes/executors/executor.hpp" #include "nodes/executors/mvn_list.hpp" @@ -410,9 +408,6 @@ public: const std::vector& outputDesc) {} virtual void initDescriptor(const NodeConfig& config); virtual bool created() const = 0; - virtual bool created(const ExtensionManager::Ptr& extMgr) { - return created(); - } /** * @brief Performs Node initialization based on graph context. diff --git a/src/plugins/intel_cpu/src/nodes/if.h b/src/plugins/intel_cpu/src/nodes/if.h index 76a87874209..ff41bd2a8c6 100644 --- a/src/plugins/intel_cpu/src/nodes/if.h +++ b/src/plugins/intel_cpu/src/nodes/if.h @@ -59,7 +59,6 @@ private: ptrdiff_t size; }; - ExtensionManager::Ptr ext_mng; Graph subGraphThen; Graph subGraphElse; std::vector> inputMemThen, inputMemElse; diff --git a/src/plugins/intel_cpu/src/nodes/tensoriterator.h b/src/plugins/intel_cpu/src/nodes/tensoriterator.h index 104ee077f9a..07a1c0106b7 100644 --- a/src/plugins/intel_cpu/src/nodes/tensoriterator.h +++ b/src/plugins/intel_cpu/src/nodes/tensoriterator.h @@ -140,7 +140,6 @@ private: int getNumIteration(const std::vector& inputPortMap, const std::vector& outputPortMap) const; bool runAsDynamic() const; - ExtensionManager::Ptr ext_mng; Graph sub_graph; std::vector> input_mems; std::vector output_mem; diff --git a/src/plugins/intel_cpu/src/plugin.cpp b/src/plugins/intel_cpu/src/plugin.cpp index e9a64a82143..0313e5ed3c4 100644 --- a/src/plugins/intel_cpu/src/plugin.cpp +++ b/src/plugins/intel_cpu/src/plugin.cpp @@ -4,8 +4,6 @@ #include "plugin.h" -#include "extension.h" -#include "extension_mngr.h" #include "itt.h" #include "internal_properties.hpp" #include "openvino/runtime/intel_cpu/properties.hpp" @@ -171,7 +169,6 @@ Engine::Engine() : get_executor_manager()->execute_task_by_streams_executor(IStreamsExecutor::Config::PreferredCoreType::BIG, [] { dnnl::impl::cpu::x64::cpu(); }); - extensionManager->AddExtension(std::make_shared()); #if defined(OV_CPU_WITH_ACL) scheduler_guard = SchedulerGuard::instance(); #endif @@ -614,7 +611,7 @@ Engine::compile_model(const std::shared_ptr& model, const ov::A denormals_as_zero(false); } } - return std::make_shared(cloned_model, shared_from_this(), conf, extensionManager); + return std::make_shared(cloned_model, shared_from_this(), conf); } void Engine::set_property(const ov::AnyMap &config) { @@ -868,12 +865,6 @@ ov::Any Engine::get_ro_property(const std::string& name, const ov::AnyMap& optio OPENVINO_THROW("Cannot get unsupported property: ", name); } -OPENVINO_SUPPRESS_DEPRECATED_START -void Engine::add_extension(const InferenceEngine::IExtensionPtr& extension) { - extensionManager->AddExtension(extension); -} -OPENVINO_SUPPRESS_DEPRECATED_END - ov::SupportedOpsMap Engine::query_model(const std::shared_ptr& model, const ov::AnyMap& config) const { WeightsSharing::Ptr fake_w_cache; @@ -892,7 +883,7 @@ ov::SupportedOpsMap Engine::query_model(const std::shared_ptr& const Config::SnippetsMode snippetsMode = getSnippetsMode(config, conf); auto context = - std::make_shared(conf, extensionManager, fake_w_cache, false); + std::make_shared(conf, fake_w_cache, false); auto supported = ov::get_supported_nodes( model, @@ -945,7 +936,7 @@ std::shared_ptr Engine::import_model(std::istream& networkMo // import config props from caching model calculate_streams(conf, model, true); - auto compiled_model = std::make_shared(model, shared_from_this(), conf, extensionManager, true); + auto compiled_model = std::make_shared(model, shared_from_this(), conf, true); return compiled_model; } } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/plugin.h b/src/plugins/intel_cpu/src/plugin.h index 256eafdbadb..756387aa48a 100644 --- a/src/plugins/intel_cpu/src/plugin.h +++ b/src/plugins/intel_cpu/src/plugin.h @@ -43,10 +43,6 @@ public: OPENVINO_THROW_NOT_IMPLEMENTED("Not Implemented get_default_context is not supported by CPU plugin!"); }; - OPENVINO_SUPPRESS_DEPRECATED_START - void add_extension(const std::shared_ptr& extension) override; - OPENVINO_SUPPRESS_DEPRECATED_END - private: bool is_legacy_api() const; @@ -62,7 +58,6 @@ private: void calculate_streams(Config& conf, const std::shared_ptr& model, bool imported = false) const; Config engConfig; - ExtensionManager::Ptr extensionManager = std::make_shared(); /* Explicily configured streams have higher priority than performance hints. So track if streams is set explicitly (not auto-configured) */ bool streamsExplicitlySetForEngine = false; diff --git a/src/plugins/intel_cpu/src/serialize.cpp b/src/plugins/intel_cpu/src/serialize.cpp index ce7304de14a..777d7ea8a04 100644 --- a/src/plugins/intel_cpu/src/serialize.cpp +++ b/src/plugins/intel_cpu/src/serialize.cpp @@ -24,27 +24,10 @@ static void setInfo(pugi::xml_node& root, std::shared_ptr& model) { } } -ModelSerializer::ModelSerializer(std::ostream & ostream, ExtensionManager::Ptr extensionManager) - : _ostream(ostream) - , _extensionManager(extensionManager) { -} +ModelSerializer::ModelSerializer(std::ostream& ostream) : _ostream(ostream) {} void ModelSerializer::operator<<(const std::shared_ptr& model) { OPENVINO_SUPPRESS_DEPRECATED_START - auto getCustomOpSets = [this]() { - std::map custom_opsets; - - if (_extensionManager) { - auto extensions = _extensionManager->Extensions(); - for (const auto& extension : extensions) { - auto opset = extension->getOpSets(); - custom_opsets.insert(std::begin(opset), std::end(opset)); - } - } - - return custom_opsets; - }; - auto serializeInfo = [&](std::ostream& stream) { const std::string name = "cnndata"; pugi::xml_document xml_doc; @@ -59,7 +42,7 @@ void ModelSerializer::operator<<(const std::shared_ptr& model) { }; // Serialize to old representation in case of old API - ov::pass::StreamSerialize serializer(_ostream, getCustomOpSets(), serializeInfo); + ov::pass::StreamSerialize serializer(_ostream, serializeInfo); OPENVINO_SUPPRESS_DEPRECATED_END serializer.run_on_model(std::const_pointer_cast(model->clone())); } diff --git a/src/plugins/intel_cpu/src/serialize.h b/src/plugins/intel_cpu/src/serialize.h index 5bbb2266100..b0c57a7ea9d 100644 --- a/src/plugins/intel_cpu/src/serialize.h +++ b/src/plugins/intel_cpu/src/serialize.h @@ -6,19 +6,17 @@ #include #include "cpp/ie_cnn_network.h" -#include "extension_mngr.h" namespace ov { namespace intel_cpu { class ModelSerializer { public: - ModelSerializer(std::ostream& ostream, ExtensionManager::Ptr extensionManager); + ModelSerializer(std::ostream& ostream); void operator<<(const std::shared_ptr& model); private: std::ostream& _ostream; - ExtensionManager::Ptr _extensionManager; }; class ModelDeserializer { diff --git a/src/plugins/intel_cpu/src/utils/ngraph_transformation.hpp b/src/plugins/intel_cpu/src/utils/ngraph_transformation.hpp index 47466dbab52..f7e9ecf30db 100644 --- a/src/plugins/intel_cpu/src/utils/ngraph_transformation.hpp +++ b/src/plugins/intel_cpu/src/utils/ngraph_transformation.hpp @@ -4,7 +4,6 @@ #pragma once #ifdef CPU_DEBUG_CAPS -#include "extension.h" #include "debug_caps_config.h" #include "openvino/util/file_util.hpp" #include @@ -68,8 +67,7 @@ private: ov::pass::Manager serializer; if (config.dumpIR.format.filter[DebugCapsConfig::IrFormatFilter::XmlBin]) { - auto custom_opsets = std::make_shared()->getOpSets(); - serializer.register_pass(pathAndName + ".xml", "", custom_opsets); + serializer.register_pass(pathAndName + ".xml", ""); } if (config.dumpIR.format.filter[DebugCapsConfig::IrFormatFilter::Xml]) { diff --git a/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp b/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp index 3b2c070ac35..e98d5ba1f85 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp +++ b/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp @@ -79,7 +79,7 @@ TEST(MemStateGraphTest, smoke_Check_Memory_Modification_Guard) { Config conf; conf.rtCacheCapacity = 0; - auto context = std::make_shared(conf, nullptr, nullptr, false); + auto context = std::make_shared(conf, nullptr, false); auto input_node = std::make_shared(param, context); auto memory_input = std::make_shared(read, context); @@ -266,7 +266,7 @@ TEST(MemStateGraphTest, smoke_ShapeOf_no_Inplace_Conflicts) { Config conf; conf.rtCacheCapacity = 0; - auto context = std::make_shared(conf, nullptr, nullptr, false); + auto context = std::make_shared(conf, nullptr, false); auto input_node = std::make_shared(param, context); auto memory_input = std::make_shared(read, context); diff --git a/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp b/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp index b765c8e40e2..fe43a4301a0 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp @@ -60,7 +60,7 @@ protected: // Config conf; conf.rtCacheCapacity = 100; - auto context = std::make_shared(conf, nullptr, nullptr, false); + auto context = std::make_shared(conf, nullptr, false); const dnnl::engine cpuEngine = context->getEngine(); m_graph = std::unique_ptr(new Graph()); diff --git a/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp b/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp index 2c048e5e13b..1ca1558a0a3 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp @@ -36,7 +36,7 @@ TEST(ResolveEdgeConflictsCPUTest, smoke_Run_ResolveEdgeConflicts) { */ Config conf; conf.rtCacheCapacity = 100; - auto context = std::make_shared(conf, nullptr, nullptr, false); + auto context = std::make_shared(conf, nullptr, false); const dnnl::engine cpuEngine = context->getEngine(); std::unique_ptr graph = std::unique_ptr(new Graph()); diff --git a/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp b/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp index 5dd1e01f561..ff528d8e65d 100644 --- a/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp @@ -108,7 +108,6 @@ public: Config conf; conf.rtCacheCapacity = 100; auto context = std::make_shared(conf, - nullptr, std::make_shared(), false); const dnnl::engine cpuEngine = context->getEngine();