Skip to content

Commit

Permalink
Add explicit impl to all plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
olpipi committed Dec 4, 2024
1 parent 1e72a49 commit 5d582fe
Show file tree
Hide file tree
Showing 27 changed files with 339 additions and 88 deletions.
4 changes: 2 additions & 2 deletions src/inference/dev_api/openvino/runtime/iplugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class OPENVINO_RUNTIME_API IPlugin : public std::enable_shared_from_this<IPlugin
*/
virtual std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const;
const ov::AnyMap& properties) const = 0;

/**
* @brief Creates an compiled model from an previously exported model using plugin implementation
Expand All @@ -210,7 +210,7 @@ class OPENVINO_RUNTIME_API IPlugin : public std::enable_shared_from_this<IPlugin
virtual std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const;
const ov::AnyMap& properties) const = 0;

/**
* @brief Queries a plugin about supported layers in model
Expand Down
13 changes: 0 additions & 13 deletions src/inference/src/dev/iplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,6 @@ const std::string& ov::IPlugin::get_device_name() const {
return m_plugin_name;
}

std::shared_ptr<ov::ICompiledModel> ov::IPlugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const {
OPENVINO_THROW_NOT_IMPLEMENTED("This method is not implemented");
}

std::shared_ptr<ov::ICompiledModel> ov::IPlugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const {
OPENVINO_THROW_NOT_IMPLEMENTED("This method is not implemented");
}

void ov::IPlugin::set_core(const std::weak_ptr<ov::ICore>& core) {
OPENVINO_ASSERT(!core.expired());
m_core = core;
Expand Down
140 changes: 70 additions & 70 deletions src/inference/tests/functional/caching_test.cpp

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/plugins/auto/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::vector<DeviceInformation> Plugin::parse_meta_devices(const std::string& priorities,
const ov::AnyMap& properties) const {
std::vector<DeviceInformation> meta_devices;
Expand Down
9 changes: 9 additions & 0 deletions src/plugins/auto/src/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ class Plugin : public ov::IPlugin {
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

private:
std::shared_ptr<ov::ICompiledModel> compile_model_impl(const std::string& model_path,
const std::shared_ptr<const ov::Model>& model,
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/auto/tests/functional/behavior/auto_func_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,18 @@ class MockPluginBase : public ov::IPlugin {
auto ov_model = core.read_model(xmlString, weights);
return compile_model(ov_model, properties, context);
}
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const override {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override {
OPENVINO_NOT_IMPLEMENTED;
}

ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override {
Expand Down
14 changes: 14 additions & 0 deletions src/plugins/auto_batch/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,19 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

} // namespace autobatch_plugin
} // namespace ov
9 changes: 9 additions & 0 deletions src/plugins/auto_batch/src/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ class Plugin : public ov::IPlugin {
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

#ifdef AUTOBATCH_UNITTEST

public:
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/auto_batch/tests/unit/mock_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class MockIPlugin : public ov::IPlugin {
import_model,
(std::istream&, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&),
(const, override));
MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>,
import_model,
(std::istream&, std::shared_ptr<ov::AlignedBuffer>, const ov::AnyMap&),
(const, override));
MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>,
import_model,
(std::istream&, std::shared_ptr<ov::AlignedBuffer>, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&),
(const, override));
MOCK_METHOD(ov::SupportedOpsMap,
query_model,
(const std::shared_ptr<const ov::Model>&, const ov::AnyMap&),
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/hetero/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(std::istrea
return compiled_model;
}

std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

ov::hetero::Plugin::DeviceProperties ov::hetero::Plugin::get_properties_per_device(const std::string& device_priorities,
const ov::AnyMap& properties) const {
auto device_names = ov::DeviceIDParser::get_hetero_devices(device_priorities);
Expand Down
9 changes: 9 additions & 0 deletions src/plugins/hetero/src/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ class Plugin : public ov::IPlugin {
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;

Expand Down
14 changes: 14 additions & 0 deletions src/plugins/hetero/tests/functional/hetero_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,20 @@ class MockPluginBase : public ov::IPlugin {
return res;
}

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const override {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override {
OPENVINO_NOT_IMPLEMENTED;
}


protected:
std::string m_default_device_id = "0";
std::unordered_set<std::string> m_supported_ops;
Expand Down
9 changes: 9 additions & 0 deletions src/plugins/intel_gpu/include/intel_gpu/plugin/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ class Plugin : public ov::IPlugin {
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;
ov::SoPtr<ov::IRemoteContext> create_context(const ov::AnyMap& remote_properties) const override;
Expand Down
16 changes: 15 additions & 1 deletion src/plugins/intel_gpu/src/plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,24 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
return res;
}


std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model, const ov::AnyMap& config) const {
std::string device_id = get_device_id(config);
auto context = get_default_context(device_id);
return import_model(model, { context, nullptr }, config);
return import_model(model, ov::SoPtr<ov::IRemoteContext>{ context, nullptr }, config);
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/intel_npu/src/plugin/include/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ class Plugin : public ov::IPlugin {
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const override;
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;

ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;

Expand Down
13 changes: 13 additions & 0 deletions src/plugins/intel_npu/src/plugin/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,19 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream,
return import_model(stream, properties);
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}

ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const {
OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::query_model");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,23 @@ void MockPluginBase<DeviceType>::create_implementation() {
.WillByDefault([](std::istream& model, const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {
OPENVINO_NOT_IMPLEMENTED;
});
ON_CALL(*this, import_model(testing::_, testing::_, testing::_))
ON_CALL(*this, import_model(testing::A<std::istream&>(), testing::A<const ov::SoPtr<ov::IRemoteContext>&>(), testing::A<const ov::AnyMap&>()))
.WillByDefault([](std::istream& model,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {
OPENVINO_NOT_IMPLEMENTED;
});
ON_CALL(*this, import_model(testing::A<std::istream&>(), testing::A<std::shared_ptr<ov::AlignedBuffer>>(), testing::A<const ov::AnyMap&>()))
.WillByDefault([](std::istream& model, std::shared_ptr<ov::AlignedBuffer> model_buffer, const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {
OPENVINO_NOT_IMPLEMENTED;
});
ON_CALL(*this, import_model(testing::_, testing::_, testing::_, testing::_))
.WillByDefault([](std::istream& model,
std::shared_ptr<ov::AlignedBuffer> model_buffer,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {
OPENVINO_NOT_IMPLEMENTED;
});
ON_CALL(*this, query_model)
.WillByDefault(
[](const std::shared_ptr<const ov::Model>& model, const ov::AnyMap& properties) -> ov::SupportedOpsMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ class MockPluginBase : public ov::IPlugin {
std::shared_ptr<ov::ICompiledModel>(std::istream& model,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties));
MOCK_CONST_METHOD3_T(import_model,
std::shared_ptr<ov::ICompiledModel>(std::istream& model,
std::shared_ptr<ov::AlignedBuffer>,
const ov::AnyMap& properties));
MOCK_CONST_METHOD4_T(import_model,
std::shared_ptr<ov::ICompiledModel>(std::istream& model,
std::shared_ptr<ov::AlignedBuffer>,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties));
MOCK_CONST_METHOD2_T(query_model,
ov::SupportedOpsMap(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties));
Expand Down
Loading

0 comments on commit 5d582fe

Please sign in to comment.