Introduce ov::ICompiledModel interface (#15276)
* Introduce ov::ICompiledModel interface * Fixed code style * Fixed mock * Fixed Inference Functional tests * Fixed typo * Fixed supported properties * Fixed tests * Changed API * Added comments * Fixed python build
This commit is contained in:
1 parent
c79f4cbb23
commit
635bfd848e
26 files changed
+801
-414
No files matched your search
@@ -185,7 +185,7 @@ void regclass_CompiledModel(py::module m) {
|
||||
)");
|
||||
|
||||
cls.def("input",
|
||||
(ov::Output<const ov::Node>(ov::CompiledModel::*)() const) & ov::CompiledModel::input,
|
||||
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)() const) & ov::CompiledModel::input,
|
||||
R"(
|
||||
Gets a single input of a compiled model.
|
||||
If a model has more than one input, this method throws an exception.
|
||||
@@ -195,7 +195,7 @@ void regclass_CompiledModel(py::module m) {
|
||||
)");
|
||||
|
||||
cls.def("input",
|
||||
(ov::Output<const ov::Node>(ov::CompiledModel::*)(size_t) const) & ov::CompiledModel::input,
|
||||
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(size_t) const) & ov::CompiledModel::input,
|
||||
py::arg("index"),
|
||||
R"(
|
||||
Gets input of a compiled model identified by an index.
|
||||
@@ -207,10 +207,11 @@ void regclass_CompiledModel(py::module m) {
|
||||
:rtype: openvino.runtime.ConstOutput
|
||||
)");
|
||||
|
||||
cls.def("input",
|
||||
(ov::Output<const ov::Node>(ov::CompiledModel::*)(const std::string&) const) & ov::CompiledModel::input,
|
||||
py::arg("tensor_name"),
|
||||
R"(
|
||||
cls.def(
|
||||
"input",
|
||||
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&)const) & ov::CompiledModel::input,
|
||||
py::arg("tensor_name"),
|
||||
R"(
|
||||
Gets input of a compiled model identified by a tensor_name.
|
||||
If the input with given tensor name is not found, this method throws an exception.
|
||||
|
||||
@@ -230,7 +231,7 @@ void regclass_CompiledModel(py::module m) {
|
||||
)");
|
||||
|
||||
cls.def("output",
|
||||
(ov::Output<const ov::Node>(ov::CompiledModel::*)() const) & ov::CompiledModel::output,
|
||||
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)() const) & ov::CompiledModel::output,
|
||||
R"(
|
||||
Gets a single output of a compiled model.
|
||||
If the model has more than one output, this method throws an exception.
|
||||
@@ -240,7 +241,7 @@ void regclass_CompiledModel(py::module m) {
|
||||
)");
|
||||
|
||||
cls.def("output",
|
||||
(ov::Output<const ov::Node>(ov::CompiledModel::*)(size_t) const) & ov::CompiledModel::output,
|
||||
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(size_t) const) & ov::CompiledModel::output,
|
||||
py::arg("index"),
|
||||
R"(
|
||||
Gets output of a compiled model identified by an index.
|
||||
@@ -252,10 +253,11 @@ void regclass_CompiledModel(py::module m) {
|
||||
:rtype: openvino.runtime.ConstOutput
|
||||
)");
|
||||
|
||||
cls.def("output",
|
||||
(ov::Output<const ov::Node>(ov::CompiledModel::*)(const std::string&) const) & ov::CompiledModel::output,
|
||||
py::arg("tensor_name"),
|
||||
R"(
|
||||
cls.def(
|
||||
"output",
|
||||
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&)const) & ov::CompiledModel::output,
|
||||
py::arg("tensor_name"),
|
||||
R"(
|
||||
Gets output of a compiled model identified by a tensor_name.
|
||||
If the output with given tensor name is not found, this method throws an exception.
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ class IInferencePlugin;
|
||||
class IInferRequestInternal;
|
||||
class RemoteContext;
|
||||
class IVariableStateInternal;
|
||||
class ICompiledModelWrapper;
|
||||
|
||||
/**
|
||||
* @interface IExecutableNetworkInternal
|
||||
@@ -213,6 +214,8 @@ protected:
|
||||
* @brief If true, it means that model was loaded from cache
|
||||
*/
|
||||
bool _loadedFromCache = false;
|
||||
|
||||
friend InferenceEngine::ICompiledModelWrapper;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief OpenVINO Runtime CompiledModel interface
|
||||
* @file openvino/runtime/icompiled_model.hpp
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
#include "cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp"
|
||||
#include "openvino/core/node_output.hpp"
|
||||
#include "openvino/runtime/common.hpp"
|
||||
#include "openvino/runtime/remote_context.hpp"
|
||||
#include "threading/ie_cpu_streams_executor.hpp"
|
||||
#include "threading/ie_itask_executor.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
class IInferRequestInternal;
|
||||
class ICompiledModelWrapper;
|
||||
} // namespace InferenceEngine
|
||||
|
||||
namespace ov {
|
||||
|
||||
class CoreImpl;
|
||||
class IPlugin;
|
||||
class IExecutableNetworkWrapper;
|
||||
|
||||
/**
|
||||
* @brief OpenVINO ICompiledModel interface
|
||||
*/
|
||||
class OPENVINO_RUNTIME_API ICompiledModel : public std::enable_shared_from_this<ICompiledModel> {
|
||||
public:
|
||||
/**
|
||||
* @brief Main constructor for ICompiledModel interface
|
||||
*
|
||||
* @param model OpenVINO model representation
|
||||
*
|
||||
* @param plugin Pointer to plugin
|
||||
*
|
||||
* @param task_executor Task executor (CPUStreamsExecutor by default)
|
||||
*
|
||||
* @param callback_executor Callback executor (CPUStreamsExecutor by default)
|
||||
*/
|
||||
ICompiledModel(const std::shared_ptr<const ov::Model>& model,
|
||||
const std::shared_ptr<const ov::IPlugin>& plugin,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& task_executor =
|
||||
std::make_shared<InferenceEngine::CPUStreamsExecutor>(InferenceEngine::IStreamsExecutor::Config{
|
||||
"Default"}),
|
||||
const InferenceEngine::ITaskExecutor::Ptr& callback_executor =
|
||||
std::make_shared<InferenceEngine::CPUStreamsExecutor>(InferenceEngine::IStreamsExecutor::Config{
|
||||
"Callback"}));
|
||||
|
||||
/**
|
||||
* @brief Gets all outputs from compiled model
|
||||
*
|
||||
* @return model outputs
|
||||
*/
|
||||
const std::vector<ov::Output<const ov::Node>>& outputs() const;
|
||||
|
||||
/**
|
||||
* @brief Gets all inputs from compiled model
|
||||
*
|
||||
* @return model inputs
|
||||
*/
|
||||
const std::vector<ov::Output<const ov::Node>>& inputs() const;
|
||||
|
||||
/**
|
||||
* @brief Create infer request
|
||||
*
|
||||
* @return Infer request interface
|
||||
*/
|
||||
virtual std::shared_ptr<InferenceEngine::IInferRequestInternal> create_infer_request() const;
|
||||
|
||||
/**
|
||||
* @brief Export compiled model to stream
|
||||
*
|
||||
* @param model output stream
|
||||
*/
|
||||
virtual void export_model(std::ostream& model) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns runtime model
|
||||
*
|
||||
* @return OpenVINO Model which represents runtime graph
|
||||
*/
|
||||
virtual std::shared_ptr<ov::Model> get_runtime_model() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Allows to set propertu
|
||||
*
|
||||
* @param properties new plugin properties
|
||||
*/
|
||||
virtual void set_property(const ov::AnyMap& properties) = 0;
|
||||
|
||||
/**
|
||||
* @brief Returns property
|
||||
*
|
||||
* @param name Property name
|
||||
*
|
||||
* @return Property value
|
||||
*/
|
||||
virtual ov::Any get_property(const std::string& name) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Creates device specific remote context
|
||||
*
|
||||
* @return OpenVINO RemoteContext
|
||||
*/
|
||||
virtual ov::RemoteContext get_context() const = 0;
|
||||
|
||||
private:
|
||||
std::shared_ptr<const ov::IPlugin> m_plugin;
|
||||
std::vector<ov::Output<const ov::Node>> m_inputs;
|
||||
std::vector<ov::Output<const ov::Node>> m_outputs;
|
||||
|
||||
InferenceEngine::ITaskExecutor::Ptr m_task_executor = nullptr; //!< Holds a task executor
|
||||
InferenceEngine::ITaskExecutor::Ptr m_callback_executor = nullptr; //!< Holds a callback executor
|
||||
|
||||
friend ov::CoreImpl;
|
||||
friend ov::IExecutableNetworkWrapper;
|
||||
friend InferenceEngine::ICompiledModelWrapper;
|
||||
|
||||
/**
|
||||
* @brief function allows to mark that model was loaded from cache
|
||||
*/
|
||||
void loaded_from_cache();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Method creates infer request implementation
|
||||
*
|
||||
* @return Sync infer request
|
||||
*/
|
||||
virtual std::shared_ptr<InferenceEngine::IInferRequestInternal> create_sync_infer_request() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Default imolementation of create async inter request method
|
||||
*
|
||||
* @tparam AsyncInferRequestType Async infer request type. InferenceEngine::AsyncInferRequestThreadSafeDefault by
|
||||
* default
|
||||
*
|
||||
* @return Async infer request
|
||||
*/
|
||||
template <typename AsyncInferRequestType = InferenceEngine::AsyncInferRequestThreadSafeDefault>
|
||||
std::shared_ptr<InferenceEngine::IInferRequestInternal> create_async_infer_request() const {
|
||||
std::shared_ptr<InferenceEngine::IInferRequestInternal> syncRequestImpl = this->create_sync_infer_request();
|
||||
return std::make_shared<AsyncInferRequestType>(syncRequestImpl, m_task_executor, m_callback_executor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns pointer to the plugin
|
||||
*
|
||||
* @return OpenVINO Plugin interface
|
||||
*/
|
||||
std::shared_ptr<const ov::IPlugin> get_plugin() const;
|
||||
};
|
||||
|
||||
} // namespace ov
|
||||
@@ -10,8 +10,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <openvino/runtime/compiled_model.hpp>
|
||||
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "openvino/runtime/tensor.hpp"
|
||||
#include "so_ptr.hpp"
|
||||
|
||||
@@ -56,10 +56,9 @@ public:
|
||||
* operation
|
||||
* @return An executable network reference
|
||||
*/
|
||||
virtual ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config = {}) const = 0;
|
||||
virtual ov::SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config = {}) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Creates an executable network from a network object.
|
||||
@@ -73,10 +72,9 @@ public:
|
||||
* operation
|
||||
* @return An executable network reference
|
||||
*/
|
||||
virtual ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config = {}) const = 0;
|
||||
virtual ov::SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config = {}) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Creates an executable network from a model file.
|
||||
@@ -90,9 +88,9 @@ public:
|
||||
* operation
|
||||
* @return An executable network reference
|
||||
*/
|
||||
virtual ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::string& model_path,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const = 0;
|
||||
virtual ov::SoPtr<ov::ICompiledModel> compile_model(const std::string& model_path,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Creates an executable network from a model memory.
|
||||
@@ -107,10 +105,10 @@ public:
|
||||
* operation
|
||||
* @return An executable network reference
|
||||
*/
|
||||
virtual ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::string& model_str,
|
||||
const ov::Tensor& weights,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const = 0;
|
||||
virtual ov::SoPtr<ov::ICompiledModel> compile_model(const std::string& model_str,
|
||||
const ov::Tensor& weights,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Creates an executable network from a previously exported network
|
||||
@@ -120,8 +118,9 @@ public:
|
||||
* operation*
|
||||
* @return An executable network reference
|
||||
*/
|
||||
virtual ov::SoPtr<InferenceEngine::IExecutableNetworkInternal>
|
||||
import_model(std::istream& model, const std::string& device_name, const ov::AnyMap& config = {}) const = 0;
|
||||
virtual ov::SoPtr<ov::ICompiledModel> import_model(std::istream& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config = {}) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Query device if it supports specified network with specified configuration
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/core/version.hpp"
|
||||
#include "openvino/runtime/common.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "openvino/runtime/icore.hpp"
|
||||
#include "openvino/runtime/remote_context.hpp"
|
||||
#include "threading/ie_executor_manager.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
|
||||
class IExecutableNetworkInternal;
|
||||
class IPluginWrapper;
|
||||
class IExtension;
|
||||
|
||||
@@ -69,9 +69,8 @@ public:
|
||||
* @param properties A ov::AnyMap of properties relevant only for this load operation
|
||||
* @return Created Compiled Model object
|
||||
*/
|
||||
virtual std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const = 0;
|
||||
virtual std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Compiles model from ov::Model object
|
||||
@@ -79,9 +78,8 @@ public:
|
||||
* @param properties A ov::AnyMap of properties relevant only for this load operation
|
||||
* @return Created Compiled Model object
|
||||
*/
|
||||
virtual std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::string& model_path,
|
||||
const ov::AnyMap& properties) const = 0;
|
||||
virtual std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,
|
||||
const ov::AnyMap& properties) const;
|
||||
|
||||
/**
|
||||
* @brief Compiles model from ov::Model object, on specified remote context
|
||||
@@ -91,10 +89,9 @@ public:
|
||||
* execute the model
|
||||
* @return Created Compiled Model object
|
||||
*/
|
||||
virtual std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties,
|
||||
const ov::RemoteContext& context) const = 0;
|
||||
virtual std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties,
|
||||
const ov::RemoteContext& context) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Sets properties for plugin, acceptable keys can be found in openvino/runtime/properties.hpp
|
||||
@@ -118,7 +115,7 @@ public:
|
||||
*
|
||||
* @return A remote context object
|
||||
*/
|
||||
virtual RemoteContext create_context(const ov::AnyMap& remote_properties) const = 0;
|
||||
virtual ov::RemoteContext create_context(const ov::AnyMap& remote_properties) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Provides a default remote context instance if supported by a plugin
|
||||
@@ -126,7 +123,7 @@ public:
|
||||
*
|
||||
* @return The default context.
|
||||
*/
|
||||
virtual RemoteContext get_default_context(const ov::AnyMap& remote_properties) const = 0;
|
||||
virtual ov::RemoteContext get_default_context(const ov::AnyMap& remote_properties) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Creates an compiled model from an previously exported model using plugin implementation
|
||||
@@ -135,9 +132,8 @@ public:
|
||||
* @param properties A ov::AnyMap of properties
|
||||
* @return An Compiled model
|
||||
*/
|
||||
virtual std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> import_model(
|
||||
std::istream& model,
|
||||
const ov::AnyMap& properties) const = 0;
|
||||
virtual std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
|
||||
const ov::AnyMap& properties) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Creates an compiled model from an previously exported model using plugin implementation
|
||||
@@ -148,8 +144,9 @@ public:
|
||||
* @param properties A ov::AnyMap of properties
|
||||
* @return An Compiled model
|
||||
*/
|
||||
virtual std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>
|
||||
import_model(std::istream& model, const ov::RemoteContext& context, const ov::AnyMap& properties) const = 0;
|
||||
virtual std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Queries a plugin about supported layers in model
|
||||
|
||||
@@ -48,8 +48,8 @@ struct SoPtr {
|
||||
* @param that copied SoPtr object
|
||||
*/
|
||||
template <typename U>
|
||||
SoPtr(const SoPtr<U>& that) : _so{that._so},
|
||||
_ptr{std::dynamic_pointer_cast<T>(that._ptr)} {
|
||||
SoPtr(const SoPtr<U>& that) : _ptr{std::dynamic_pointer_cast<T>(that._ptr)},
|
||||
_so{that._so} {
|
||||
IE_ASSERT(_ptr != nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,11 @@
|
||||
#include "openvino/runtime/properties.hpp"
|
||||
#include "openvino/runtime/remote_context.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
class IExecutableNetworkInternal;
|
||||
} // namespace InferenceEngine
|
||||
|
||||
namespace ov {
|
||||
|
||||
class Core;
|
||||
class InferRequest;
|
||||
class ICompiledModel;
|
||||
|
||||
/**
|
||||
* @brief This class represents a compiled model.
|
||||
@@ -37,7 +34,7 @@ class InferRequest;
|
||||
* transformations, then mapping to compute kernels.
|
||||
*/
|
||||
class OPENVINO_RUNTIME_API CompiledModel {
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> _impl;
|
||||
std::shared_ptr<ov::ICompiledModel> _impl;
|
||||
std::shared_ptr<void> _so;
|
||||
|
||||
/**
|
||||
@@ -46,8 +43,7 @@ class OPENVINO_RUNTIME_API CompiledModel {
|
||||
* @param so Plugin to use. This parameter is required to ensure that CompiledModel can work properly even if a
|
||||
* plugin object is destroyed.
|
||||
*/
|
||||
CompiledModel(const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& impl,
|
||||
const std::shared_ptr<void>& so);
|
||||
CompiledModel(const std::shared_ptr<ov::ICompiledModel>& impl, const std::shared_ptr<void>& so);
|
||||
friend class ov::Core;
|
||||
friend class ov::InferRequest;
|
||||
|
||||
@@ -79,7 +75,7 @@ public:
|
||||
* They contain information about input tensors such as tensor shape, names, and element type.
|
||||
* @return std::vector of model inputs.
|
||||
*/
|
||||
std::vector<ov::Output<const ov::Node>> inputs() const;
|
||||
const std::vector<ov::Output<const ov::Node>>& inputs() const;
|
||||
|
||||
/**
|
||||
* @brief Gets a single input of a compiled model.
|
||||
@@ -88,7 +84,7 @@ public:
|
||||
* @return Compiled model input.
|
||||
* @note If a model has more than one input, this method throws ov::Exception.
|
||||
*/
|
||||
ov::Output<const ov::Node> input() const;
|
||||
const ov::Output<const ov::Node>& input() const;
|
||||
|
||||
/**
|
||||
* @brief Gets input of a compiled model identified by @p i.
|
||||
@@ -97,7 +93,7 @@ public:
|
||||
* @return Compiled model input.
|
||||
* @note The method throws ov::Exception if input with the specified index @p i is not found.
|
||||
*/
|
||||
ov::Output<const ov::Node> input(size_t i) const;
|
||||
const ov::Output<const ov::Node>& input(size_t i) const;
|
||||
|
||||
/**
|
||||
* @brief Gets input of a compiled model identified by @p tensor_name.
|
||||
@@ -106,7 +102,7 @@ public:
|
||||
* @return Compiled model input.
|
||||
* @note The method throws ov::Exception if input with the specified tensor name @p tensor_name is not found.
|
||||
*/
|
||||
ov::Output<const ov::Node> input(const std::string& tensor_name) const;
|
||||
const ov::Output<const ov::Node>& input(const std::string& tensor_name) const;
|
||||
|
||||
/**
|
||||
* @brief Get all outputs of a compiled model.
|
||||
@@ -114,7 +110,7 @@ public:
|
||||
* Outputs contain information about output tensors such as tensor shape, names, and element type.
|
||||
* @return std::vector of model outputs.
|
||||
*/
|
||||
std::vector<ov::Output<const ov::Node>> outputs() const;
|
||||
const std::vector<ov::Output<const ov::Node>>& outputs() const;
|
||||
|
||||
/**
|
||||
* @brief Gets a single output of a compiled model.
|
||||
@@ -123,7 +119,7 @@ public:
|
||||
* @return Compiled model output.
|
||||
* @note If a model has more than one output, this method throws ov::Exception.
|
||||
*/
|
||||
ov::Output<const ov::Node> output() const;
|
||||
const ov::Output<const ov::Node>& output() const;
|
||||
|
||||
/**
|
||||
* @brief Gets output of a compiled model identified by @p index.
|
||||
@@ -132,7 +128,7 @@ public:
|
||||
* @return Compiled model output.
|
||||
* @note The method throws ov::Exception if output with the specified index @p index is not found.
|
||||
*/
|
||||
ov::Output<const ov::Node> output(size_t i) const;
|
||||
const ov::Output<const ov::Node>& output(size_t i) const;
|
||||
|
||||
/**
|
||||
* @brief Gets output of a compiled model identified by @p tensor_name.
|
||||
@@ -141,7 +137,7 @@ public:
|
||||
* @return Compiled model output.
|
||||
* @note The method throws ov::Exception if output with the specified tensor name @p tensor_name is not found.
|
||||
*/
|
||||
ov::Output<const ov::Node> output(const std::string& tensor_name) const;
|
||||
const ov::Output<const ov::Node>& output(const std::string& tensor_name) const;
|
||||
|
||||
/**
|
||||
* @brief Creates an inference request object used to infer the compiled model.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
namespace InferenceEngine {
|
||||
class RemoteContext;
|
||||
class IPluginWrapper;
|
||||
class ICompiledModelWrapper;
|
||||
class Core;
|
||||
} // namespace InferenceEngine
|
||||
|
||||
@@ -31,6 +32,7 @@ class CoreImpl;
|
||||
class Plugin;
|
||||
class IPlugin;
|
||||
class IInferencePluginWrapper;
|
||||
class IExecutableNetworkWrapper;
|
||||
class CompiledModel;
|
||||
|
||||
/**
|
||||
@@ -55,11 +57,13 @@ protected:
|
||||
const std::vector<std::shared_ptr<void>>& so);
|
||||
friend class InferenceEngine::Core;
|
||||
friend class InferenceEngine::IPluginWrapper;
|
||||
friend class InferenceEngine::ICompiledModelWrapper;
|
||||
friend class ov::Core;
|
||||
friend class ov::CoreImpl;
|
||||
friend class ov::Plugin;
|
||||
friend class ov::IPlugin;
|
||||
friend class ov::IInferencePluginWrapper;
|
||||
friend class ov::IExecutableNetworkWrapper;
|
||||
friend class ov::CompiledModel;
|
||||
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "openvino/runtime/compiled_model.hpp"
|
||||
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
|
||||
#define OV_COMPILED_MODEL_CALL_STATEMENT(...) \
|
||||
OPENVINO_ASSERT(_impl != nullptr, "CompiledModel was not initialized."); \
|
||||
try { \
|
||||
__VA_ARGS__; \
|
||||
} catch (const std::exception& ex) { \
|
||||
throw ov::Exception(ex.what()); \
|
||||
} catch (...) { \
|
||||
OPENVINO_ASSERT(false, "Unexpected exception"); \
|
||||
}
|
||||
|
||||
namespace ov {
|
||||
|
||||
CompiledModel::~CompiledModel() {
|
||||
_impl = {};
|
||||
}
|
||||
|
||||
CompiledModel::CompiledModel(const std::shared_ptr<ov::ICompiledModel>& impl, const std::shared_ptr<void>& so)
|
||||
: _impl{impl},
|
||||
_so{so} {
|
||||
OPENVINO_ASSERT(_impl != nullptr, "CompiledModel was not initialized.");
|
||||
}
|
||||
|
||||
std::shared_ptr<const Model> CompiledModel::get_runtime_model() const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(return _impl->get_runtime_model());
|
||||
}
|
||||
|
||||
const std::vector<ov::Output<const ov::Node>>& CompiledModel::inputs() const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(return _impl->inputs());
|
||||
}
|
||||
|
||||
const ov::Output<const ov::Node>& CompiledModel::input() const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT({
|
||||
const auto& inputs = _impl->inputs();
|
||||
OPENVINO_ASSERT(inputs.size() == 1,
|
||||
"CompiledModel::input() must be called on a compiled model with exactly one parameter.");
|
||||
return inputs.at(0);
|
||||
});
|
||||
}
|
||||
|
||||
const ov::Output<const ov::Node>& CompiledModel::input(size_t i) const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT({
|
||||
OPENVINO_ASSERT(i < _impl->inputs().size(),
|
||||
"Cannot get input for index: ",
|
||||
i,
|
||||
" outputs size is ",
|
||||
_impl->inputs().size());
|
||||
return _impl->inputs().at(i);
|
||||
});
|
||||
}
|
||||
|
||||
const ov::Output<const ov::Node>& CompiledModel::input(const std::string& tensor_name) const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT({
|
||||
for (const auto& input : _impl->inputs()) {
|
||||
if (input.get_names().count(tensor_name)) {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
throw ov::Exception("Input for tensor name '" + tensor_name + "' is not found.");
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<ov::Output<const ov::Node>>& CompiledModel::outputs() const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(return _impl->outputs());
|
||||
}
|
||||
|
||||
const ov::Output<const ov::Node>& CompiledModel::output() const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT({
|
||||
const auto& outputs = _impl->outputs();
|
||||
OPENVINO_ASSERT(outputs.size() == 1,
|
||||
"CompiledModel::output() must be called on a compiled model with exactly one result.");
|
||||
return outputs.at(0);
|
||||
});
|
||||
}
|
||||
const ov::Output<const ov::Node>& CompiledModel::output(size_t i) const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT({
|
||||
OPENVINO_ASSERT(i < _impl->outputs().size(),
|
||||
"Cannot get output for index: ",
|
||||
i,
|
||||
" outputs size is ",
|
||||
_impl->outputs().size());
|
||||
return _impl->outputs().at(i);
|
||||
});
|
||||
}
|
||||
const ov::Output<const ov::Node>& CompiledModel::output(const std::string& tensor_name) const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT({
|
||||
for (const auto& output : _impl->outputs()) {
|
||||
if (output.get_names().count(tensor_name)) {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
throw ov::Exception("Output for tensor name '" + tensor_name + "' is not found.");
|
||||
});
|
||||
}
|
||||
|
||||
InferRequest CompiledModel::create_infer_request() {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(return {_impl->create_infer_request(), _so});
|
||||
}
|
||||
|
||||
void CompiledModel::export_model(std::ostream& networkModel) {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(_impl->export_model(networkModel));
|
||||
}
|
||||
|
||||
void CompiledModel::set_property(const AnyMap& config) {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(_impl->set_property(config));
|
||||
}
|
||||
|
||||
Any CompiledModel::get_property(const std::string& name) const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(return {_impl->get_property(name), {_so}});
|
||||
}
|
||||
|
||||
RemoteContext CompiledModel::get_context() const {
|
||||
OV_COMPILED_MODEL_CALL_STATEMENT(return {_impl->get_context()._impl, {_so}});
|
||||
}
|
||||
|
||||
bool CompiledModel::operator!() const noexcept {
|
||||
return !_impl;
|
||||
}
|
||||
|
||||
CompiledModel::operator bool() const noexcept {
|
||||
return !!_impl;
|
||||
}
|
||||
|
||||
} // namespace ov
|
||||
@@ -25,16 +25,6 @@ namespace InferenceEngine {
|
||||
InferenceEngine::details::Rethrow(); \
|
||||
}
|
||||
|
||||
#define OV_EXEC_NET_CALL_STATEMENT(...) \
|
||||
OPENVINO_ASSERT(_impl != nullptr, "ExecutableNetwork was not initialized."); \
|
||||
try { \
|
||||
__VA_ARGS__; \
|
||||
} catch (const std::exception& ex) { \
|
||||
throw ov::Exception(ex.what()); \
|
||||
} catch (...) { \
|
||||
OPENVINO_ASSERT(false, "Unexpected exception"); \
|
||||
}
|
||||
|
||||
ExecutableNetwork::~ExecutableNetwork() {
|
||||
_impl = {};
|
||||
}
|
||||
@@ -115,155 +105,3 @@ ExecutableNetwork::operator bool() const noexcept {
|
||||
return !!_impl;
|
||||
}
|
||||
} // namespace InferenceEngine
|
||||
|
||||
namespace ov {
|
||||
|
||||
CompiledModel::~CompiledModel() {
|
||||
_impl = {};
|
||||
}
|
||||
|
||||
CompiledModel::CompiledModel(const std::shared_ptr<ie::IExecutableNetworkInternal>& impl,
|
||||
const std::shared_ptr<void>& so)
|
||||
: _impl{impl},
|
||||
_so{so} {
|
||||
OPENVINO_ASSERT(_impl != nullptr, "CompiledModel was not initialized.");
|
||||
}
|
||||
|
||||
std::shared_ptr<const Model> CompiledModel::get_runtime_model() const {
|
||||
OV_EXEC_NET_CALL_STATEMENT(return std::const_pointer_cast<const Model>(_impl->GetExecGraphInfo()));
|
||||
}
|
||||
|
||||
std::vector<ov::Output<const ov::Node>> CompiledModel::inputs() const {
|
||||
OV_EXEC_NET_CALL_STATEMENT({
|
||||
std::vector<ov::Output<const ov::Node>> inputs;
|
||||
for (const auto& input : _impl->getInputs()) {
|
||||
inputs.emplace_back(input);
|
||||
}
|
||||
return inputs;
|
||||
});
|
||||
}
|
||||
|
||||
ov::Output<const ov::Node> CompiledModel::input() const {
|
||||
OV_EXEC_NET_CALL_STATEMENT({
|
||||
const auto inputs = _impl->getInputs();
|
||||
if (inputs.size() != 1) {
|
||||
throw ov::Exception("input() must be called on a function with exactly one parameter.");
|
||||
}
|
||||
return inputs.at(0);
|
||||
});
|
||||
}
|
||||
|
||||
ov::Output<const ov::Node> CompiledModel::input(size_t i) const {
|
||||
OV_EXEC_NET_CALL_STATEMENT(return _impl->getInputs().at(i));
|
||||
}
|
||||
|
||||
ov::Output<const ov::Node> CompiledModel::input(const std::string& tensor_name) const {
|
||||
OV_EXEC_NET_CALL_STATEMENT({
|
||||
for (const auto& param : _impl->getInputs()) {
|
||||
if (param->get_output_tensor(0).get_names().count(tensor_name)) {
|
||||
return param;
|
||||
}
|
||||
}
|
||||
throw ov::Exception("Input for tensor name '" + tensor_name + "' is not found.");
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<ov::Output<const ov::Node>> CompiledModel::outputs() const {
|
||||
OV_EXEC_NET_CALL_STATEMENT({
|
||||
std::vector<ov::Output<const ov::Node>> outputs;
|
||||
for (const auto& output : _impl->getOutputs()) {
|
||||
outputs.emplace_back(output);
|
||||
}
|
||||
return outputs;
|
||||
});
|
||||
}
|
||||
ov::Output<const ov::Node> CompiledModel::output() const {
|
||||
OV_EXEC_NET_CALL_STATEMENT({
|
||||
const auto outputs = _impl->getOutputs();
|
||||
if (outputs.size() != 1) {
|
||||
throw ov::Exception("output() must be called on a function with exactly one result.");
|
||||
}
|
||||
return outputs.at(0);
|
||||
});
|
||||
}
|
||||
ov::Output<const ov::Node> CompiledModel::output(size_t i) const {
|
||||
OV_EXEC_NET_CALL_STATEMENT(return _impl->getOutputs().at(i));
|
||||
}
|
||||
ov::Output<const ov::Node> CompiledModel::output(const std::string& tensor_name) const {
|
||||
OV_EXEC_NET_CALL_STATEMENT({
|
||||
for (const auto& result : _impl->getOutputs()) {
|
||||
if (result->get_output_tensor(0).get_names().count(tensor_name)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
throw ov::Exception("Output for tensor name '" + tensor_name + "' is not found.");
|
||||
});
|
||||
}
|
||||
|
||||
InferRequest CompiledModel::create_infer_request() {
|
||||
OV_EXEC_NET_CALL_STATEMENT(return {_impl->CreateInferRequest(), _so});
|
||||
}
|
||||
|
||||
void CompiledModel::export_model(std::ostream& networkModel) {
|
||||
OV_EXEC_NET_CALL_STATEMENT(_impl->Export(networkModel));
|
||||
}
|
||||
|
||||
void CompiledModel::set_property(const AnyMap& config) {
|
||||
OV_EXEC_NET_CALL_STATEMENT(_impl->SetConfig(config));
|
||||
}
|
||||
|
||||
Any CompiledModel::get_property(const std::string& name) const {
|
||||
OV_EXEC_NET_CALL_STATEMENT({
|
||||
if (ov::loaded_from_cache == name) {
|
||||
return _impl->isLoadedFromCache();
|
||||
}
|
||||
if (ov::supported_properties == name) {
|
||||
try {
|
||||
auto supported_properties = _impl->GetMetric(name).as<std::vector<PropertyName>>();
|
||||
supported_properties.erase(std::remove_if(supported_properties.begin(),
|
||||
supported_properties.end(),
|
||||
[](const ov::PropertyName& name) {
|
||||
return name == METRIC_KEY(SUPPORTED_METRICS) ||
|
||||
name == METRIC_KEY(SUPPORTED_CONFIG_KEYS);
|
||||
}),
|
||||
supported_properties.end());
|
||||
return supported_properties;
|
||||
} catch (ie::Exception&) {
|
||||
auto ro_properties = _impl->GetMetric(METRIC_KEY(SUPPORTED_METRICS)).as<std::vector<std::string>>();
|
||||
auto rw_properties = _impl->GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS)).as<std::vector<std::string>>();
|
||||
std::vector<ov::PropertyName> supported_properties;
|
||||
for (auto&& ro_property : ro_properties) {
|
||||
if (ro_property != METRIC_KEY(SUPPORTED_METRICS) &&
|
||||
ro_property != METRIC_KEY(SUPPORTED_CONFIG_KEYS)) {
|
||||
supported_properties.emplace_back(ro_property, PropertyMutability::RO);
|
||||
}
|
||||
}
|
||||
for (auto&& rw_property : rw_properties) {
|
||||
supported_properties.emplace_back(rw_property, PropertyMutability::RW);
|
||||
}
|
||||
supported_properties.emplace_back(ov::supported_properties.name(), PropertyMutability::RO);
|
||||
supported_properties.emplace_back(ov::loaded_from_cache.name(), PropertyMutability::RO);
|
||||
return supported_properties;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return {_impl->GetMetric(name), {_so}};
|
||||
} catch (ie::Exception&) {
|
||||
return {_impl->GetConfig(name), {_so}};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RemoteContext CompiledModel::get_context() const {
|
||||
OV_EXEC_NET_CALL_STATEMENT(return {_impl->GetContext(), {_so}});
|
||||
}
|
||||
|
||||
bool CompiledModel::operator!() const noexcept {
|
||||
return !_impl;
|
||||
}
|
||||
|
||||
CompiledModel::operator bool() const noexcept {
|
||||
return !!_impl;
|
||||
}
|
||||
|
||||
} // namespace ov
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp"
|
||||
#include "cpp_interfaces/interface/ie_iinfer_request_internal.hpp"
|
||||
#include "dev/converter_utils.hpp"
|
||||
#include "ie_infer_async_request_base.hpp"
|
||||
#include "ie_ngraph_utils.hpp"
|
||||
#include "ie_remote_context.hpp"
|
||||
@@ -506,7 +507,8 @@ std::vector<VariableState> InferRequest::query_state() {
|
||||
}
|
||||
|
||||
CompiledModel InferRequest::get_compiled_model() {
|
||||
OV_INFER_REQ_CALL_STATEMENT(return {_impl->getPointerToExecutableNetworkInternal(), _so});
|
||||
OV_INFER_REQ_CALL_STATEMENT(
|
||||
return {ov::legacy_convert::convert_compiled_model(_impl->getPointerToExecutableNetworkInternal()), _so});
|
||||
}
|
||||
|
||||
bool InferRequest::operator!() const noexcept {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <ie_input_info.hpp>
|
||||
#include <ie_plugin_config.hpp>
|
||||
#include <ie_version.hpp>
|
||||
#include <memory>
|
||||
#include <openvino/core/except.hpp>
|
||||
@@ -23,6 +24,7 @@
|
||||
#include "cnn_network_ngraph_impl.hpp"
|
||||
#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp"
|
||||
#include "cpp_interfaces/interface/ie_iplugin_internal.hpp"
|
||||
#include "icompiled_model_wrapper.hpp"
|
||||
#include "ie_icore.hpp"
|
||||
#include "ie_ngraph_utils.hpp"
|
||||
#include "iplugin_wrapper.hpp"
|
||||
@@ -190,24 +192,26 @@ public:
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> LoadNetwork(
|
||||
const InferenceEngine::CNNNetwork& network,
|
||||
const std::map<std::string, std::string>& config) override {
|
||||
return m_plugin->compile_model(ov::legacy_convert::convert_model(network, m_plugin->is_new_api()),
|
||||
ov::any_copy(config));
|
||||
return ov::legacy_convert::convert_compiled_model(
|
||||
m_plugin->compile_model(ov::legacy_convert::convert_model(network, m_plugin->is_new_api()),
|
||||
ov::any_copy(config)));
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> LoadNetwork(
|
||||
const InferenceEngine::CNNNetwork& network,
|
||||
const std::map<std::string, std::string>& config,
|
||||
const std::shared_ptr<InferenceEngine::RemoteContext>& context) override {
|
||||
return m_plugin->compile_model(ov::legacy_convert::convert_model(network, m_plugin->is_new_api()),
|
||||
ov::any_copy(config),
|
||||
ov::RemoteContext{context, {}});
|
||||
return ov::legacy_convert::convert_compiled_model(
|
||||
m_plugin->compile_model(ov::legacy_convert::convert_model(network, m_plugin->is_new_api()),
|
||||
ov::any_copy(config),
|
||||
ov::RemoteContext{context, {}}));
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> LoadNetwork(
|
||||
const std::string& modelPath,
|
||||
const std::map<std::string, std::string>& config) override {
|
||||
return ov::SoPtr<InferenceEngine::IExecutableNetworkInternal>(
|
||||
m_plugin->compile_model(modelPath, ov::any_copy(config)),
|
||||
ov::legacy_convert::convert_compiled_model(m_plugin->compile_model(modelPath, ov::any_copy(config))),
|
||||
{});
|
||||
}
|
||||
|
||||
@@ -248,20 +252,21 @@ public:
|
||||
const std::string& modelFileName,
|
||||
const std::map<std::string, std::string>& config) override {
|
||||
std::ifstream model(modelFileName, std::ios::binary);
|
||||
return m_plugin->import_model(model, ov::any_copy(config));
|
||||
return ov::legacy_convert::convert_compiled_model(m_plugin->import_model(model, ov::any_copy(config)));
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> ImportNetwork(
|
||||
std::istream& networkModel,
|
||||
const std::map<std::string, std::string>& config) override {
|
||||
return m_plugin->import_model(networkModel, ov::any_copy(config));
|
||||
return ov::legacy_convert::convert_compiled_model(m_plugin->import_model(networkModel, ov::any_copy(config)));
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> ImportNetwork(
|
||||
std::istream& networkModel,
|
||||
const std::shared_ptr<InferenceEngine::RemoteContext>& context,
|
||||
const std::map<std::string, std::string>& config) override {
|
||||
return m_plugin->import_model(networkModel, ov::RemoteContext{context, {}}, ov::any_copy(config));
|
||||
return ov::legacy_convert::convert_compiled_model(
|
||||
m_plugin->import_model(networkModel, ov::RemoteContext{context, {}}, ov::any_copy(config)));
|
||||
}
|
||||
|
||||
void SetCore(std::weak_ptr<InferenceEngine::ICore> core) override {
|
||||
@@ -309,3 +314,81 @@ std::shared_ptr<::ov::IPlugin> ov::legacy_convert::convert_plugin(
|
||||
std::shared_ptr<::ov::IPlugin> ov_plugin(new ::InferenceEngine::IPluginWrapper(plugin));
|
||||
return ov_plugin;
|
||||
}
|
||||
|
||||
namespace ov {
|
||||
|
||||
class IExecutableNetworkWrapper : public InferenceEngine::IExecutableNetworkInternal {
|
||||
public:
|
||||
IExecutableNetworkWrapper(const std::shared_ptr<ov::ICompiledModel>& model) : m_model(model) {
|
||||
for (const auto& input : m_model->inputs()) {
|
||||
InferenceEngine::InputInfo::Ptr input_info;
|
||||
ov::legacy_convert::fill_input_info(input, input_info);
|
||||
_networkInputs[input_info->name()] = input_info;
|
||||
_parameters.emplace_back(input.get_node_shared_ptr());
|
||||
}
|
||||
for (const auto& output : m_model->outputs()) {
|
||||
InferenceEngine::DataPtr output_info;
|
||||
ov::legacy_convert::fill_output_info(output, output_info);
|
||||
_networkOutputs[output_info->getName()] = output_info;
|
||||
_results.emplace_back(output.get_node_shared_ptr());
|
||||
}
|
||||
_plugin = ov::legacy_convert::convert_plugin(std::const_pointer_cast<ov::IPlugin>(m_model->m_plugin));
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IInferRequestInternal> CreateInferRequest() override {
|
||||
return m_model->create_infer_request();
|
||||
}
|
||||
|
||||
void Export(std::ostream& model) override {
|
||||
m_model->export_model(model);
|
||||
}
|
||||
|
||||
void Export(const std::string& modelFileName) override {
|
||||
std::ofstream ostream(modelFileName, std::ios::out | std::ios::binary);
|
||||
Export(ostream);
|
||||
}
|
||||
|
||||
std::shared_ptr<ngraph::Function> GetExecGraphInfo() override {
|
||||
return m_model->get_runtime_model();
|
||||
}
|
||||
|
||||
void SetConfig(const std::map<std::string, InferenceEngine::Parameter>& config) override {
|
||||
m_model->set_property(config);
|
||||
}
|
||||
|
||||
InferenceEngine::Parameter GetConfig(const std::string& name) const override {
|
||||
return m_model->get_property(name);
|
||||
}
|
||||
|
||||
InferenceEngine::Parameter GetMetric(const std::string& name) const override {
|
||||
return m_model->get_property(name);
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::RemoteContext> GetContext() const override {
|
||||
return m_model->get_context()._impl;
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::ICompiledModel> get_model() {
|
||||
return m_model;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<ov::ICompiledModel> m_model;
|
||||
};
|
||||
} // namespace ov
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> ov::legacy_convert::convert_compiled_model(
|
||||
const std::shared_ptr<ov::ICompiledModel>& model) {
|
||||
if (auto comp_model = std::dynamic_pointer_cast<InferenceEngine::ICompiledModelWrapper>(model)) {
|
||||
return comp_model->get_model();
|
||||
}
|
||||
return std::make_shared<ov::IExecutableNetworkWrapper>(model);
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::ICompiledModel> ov::legacy_convert::convert_compiled_model(
|
||||
const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& model) {
|
||||
if (auto comp_model = std::dynamic_pointer_cast<ov::IExecutableNetworkWrapper>(model)) {
|
||||
return comp_model->get_model();
|
||||
}
|
||||
return std::make_shared<InferenceEngine::ICompiledModelWrapper>(model);
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "cpp/ie_cnn_network.h"
|
||||
#include "cpp_interfaces/interface/ie_iplugin_internal.hpp"
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "openvino/runtime/iplugin.hpp"
|
||||
|
||||
namespace ov {
|
||||
@@ -21,6 +22,11 @@ std::shared_ptr<const ov::Model> convert_model(const InferenceEngine::CNNNetwork
|
||||
std::shared_ptr<::InferenceEngine::IInferencePlugin> convert_plugin(const std::shared_ptr<::ov::IPlugin>& plugin);
|
||||
std::shared_ptr<::ov::IPlugin> convert_plugin(const std::shared_ptr<::InferenceEngine::IInferencePlugin>& plugin);
|
||||
|
||||
std::shared_ptr<::InferenceEngine::IExecutableNetworkInternal> convert_compiled_model(
|
||||
const std::shared_ptr<::ov::ICompiledModel>& model);
|
||||
std::shared_ptr<::ov::ICompiledModel> convert_compiled_model(
|
||||
const std::shared_ptr<::InferenceEngine::IExecutableNetworkInternal>& model);
|
||||
|
||||
} // namespace legacy_convert
|
||||
} // namespace ov
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "openvino/core/op_extension.hpp"
|
||||
#include "openvino/core/preprocess/pre_post_process.hpp"
|
||||
#include "openvino/core/version.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "openvino/runtime/remote_context.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "openvino/util/shared_object.hpp"
|
||||
@@ -306,10 +307,9 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& pluginName) const {
|
||||
}
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
OV_ITT_SCOPE(FIRST_INFERENCE, ie::itt::domains::IE_LT, "Core::compile_model::model");
|
||||
std::string deviceName = device_name;
|
||||
ov::AnyMap config_with_batch = config;
|
||||
@@ -324,7 +324,7 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
parsed._config.erase(CONFIG_KEY_INTERNAL(FORCE_DISABLE_CACHE));
|
||||
}
|
||||
auto plugin = get_plugin(parsed._deviceName);
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> res;
|
||||
ov::SoPtr<ov::ICompiledModel> res;
|
||||
auto cacheManager =
|
||||
coreConfig.get_cache_config_for_device(parsed._deviceName, device_supports_cache_dir(plugin), parsed._config)
|
||||
._cacheManager;
|
||||
@@ -338,9 +338,6 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
res = load_model_from_cache(cacheContent, plugin, parsed._config, {}, loadedFromCache);
|
||||
if (!loadedFromCache) {
|
||||
res = compile_model_impl(model, plugin, parsed._config, {}, cacheContent, forceDisableCache);
|
||||
} else {
|
||||
// Temporary workaround until all plugins support caching of original model inputs
|
||||
InferenceEngine::SetExeNetworkInfo(res._ptr, model, is_new_api());
|
||||
}
|
||||
} else {
|
||||
res = compile_model_impl(model, plugin, parsed._config, {}, cacheContent, forceDisableCache);
|
||||
@@ -348,10 +345,9 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
return {res._ptr, res._so};
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const {
|
||||
OV_ITT_SCOPE(FIRST_INFERENCE, ie::itt::domains::IE_LT, "Core::compile_model::RemoteContext");
|
||||
if (context._impl == nullptr) {
|
||||
IE_THROW() << "Remote context is null";
|
||||
@@ -366,7 +362,7 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
parsed = parseDeviceNameIntoConfig(deviceName, config_with_batch);
|
||||
|
||||
auto plugin = get_plugin(parsed._deviceName);
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> res;
|
||||
ov::SoPtr<ov::ICompiledModel> res;
|
||||
auto cacheManager =
|
||||
coreConfig.get_cache_config_for_device(parsed._deviceName, device_supports_cache_dir(plugin), parsed._config)
|
||||
._cacheManager;
|
||||
@@ -380,21 +376,17 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
res = load_model_from_cache(cacheContent, plugin, parsed._config, context, loadedFromCache);
|
||||
if (!loadedFromCache) {
|
||||
res = compile_model_impl(model, plugin, parsed._config, context, cacheContent);
|
||||
} else {
|
||||
// Temporary workaround until all plugins support caching of original model inputs
|
||||
InferenceEngine::SetExeNetworkInfo(res._ptr, model, isNewAPI());
|
||||
}
|
||||
} else {
|
||||
res = compile_model_impl(model, plugin, parsed._config, context, cacheContent);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_model(
|
||||
ov::Plugin& plugin,
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compiled_model;
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(ov::Plugin& plugin,
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<ov::ICompiledModel> compiled_model;
|
||||
|
||||
if (!is_new_api() && !std::dynamic_pointer_cast<InferenceEngine::IPluginWrapper>(plugin.m_ptr)) {
|
||||
OPENVINO_NOT_IMPLEMENTED;
|
||||
@@ -408,13 +400,13 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
return compiled_model;
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_model(const std::string& model_path,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& model_path,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
OV_ITT_SCOPE(FIRST_INFERENCE, ie::itt::domains::IE_LT, "Core::compile_model::Path");
|
||||
auto parsed = parseDeviceNameIntoConfig(device_name, config);
|
||||
auto plugin = get_plugin(parsed._deviceName);
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> res;
|
||||
ov::SoPtr<ov::ICompiledModel> res;
|
||||
auto cacheManager =
|
||||
coreConfig.get_cache_config_for_device(parsed._deviceName, device_supports_cache_dir(plugin), parsed._config)
|
||||
._cacheManager;
|
||||
@@ -439,13 +431,13 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
return {res._ptr, res._so};
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_model(const std::string& model_str,
|
||||
const ov::Tensor& weights,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& model_str,
|
||||
const ov::Tensor& weights,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
auto parsed = parseDeviceNameIntoConfig(device_name, config);
|
||||
auto plugin = get_plugin(parsed._deviceName);
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> res;
|
||||
ov::SoPtr<ov::ICompiledModel> res;
|
||||
|
||||
auto cacheManager =
|
||||
coreConfig.get_cache_config_for_device(parsed._deviceName, device_supports_cache_dir(plugin), parsed._config)
|
||||
@@ -470,9 +462,9 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
return {res._ptr, res._so};
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::import_model(std::istream& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::import_model(std::istream& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const {
|
||||
auto parsed = parseDeviceNameIntoConfig(device_name, config);
|
||||
auto exec = get_plugin(parsed._deviceName).import_model(model, config);
|
||||
|
||||
@@ -907,15 +899,14 @@ bool ov::CoreImpl::device_supports_cache_dir(const ov::Plugin& plugin) const {
|
||||
return util::contains(plugin.get_property(ov::supported_properties), ov::cache_dir);
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_model_impl(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& parsedConfig,
|
||||
const ov::RemoteContext& context,
|
||||
const CacheContent& cacheContent,
|
||||
bool forceDisableCache) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model_impl(const std::shared_ptr<const ov::Model>& model,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& parsedConfig,
|
||||
const ov::RemoteContext& context,
|
||||
const CacheContent& cacheContent,
|
||||
bool forceDisableCache) const {
|
||||
OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "CoreImpl::compile_model_impl");
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> execNetwork;
|
||||
ov::SoPtr<ov::ICompiledModel> execNetwork;
|
||||
execNetwork =
|
||||
context._impl ? plugin.compile_model(model, context, parsedConfig) : plugin.compile_model(model, parsedConfig);
|
||||
if (!forceDisableCache && cacheContent.cacheManager && device_supports_import_export(plugin)) {
|
||||
@@ -926,7 +917,7 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
networkStream << ov::CompiledBlobHeader(
|
||||
InferenceEngine::GetInferenceEngineVersion()->buildNumber,
|
||||
ov::NetworkCompilationContext::calculate_file_info(cacheContent.modelPath));
|
||||
execNetwork->Export(networkStream);
|
||||
execNetwork->export_model(networkStream);
|
||||
});
|
||||
} catch (...) {
|
||||
cacheContent.cacheManager->removeCacheEntry(cacheContent.blobId);
|
||||
@@ -936,13 +927,12 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::compile_mod
|
||||
return execNetwork;
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::load_model_from_cache(
|
||||
const CacheContent& cacheContent,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& config,
|
||||
const ov::RemoteContext& context,
|
||||
bool& networkIsImported) {
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> execNetwork;
|
||||
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::load_model_from_cache(const CacheContent& cacheContent,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& config,
|
||||
const ov::RemoteContext& context,
|
||||
bool& networkIsImported) {
|
||||
ov::SoPtr<ov::ICompiledModel> execNetwork;
|
||||
struct HeaderException {};
|
||||
|
||||
OPENVINO_ASSERT(cacheContent.cacheManager != nullptr);
|
||||
@@ -970,7 +960,7 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::load_model_
|
||||
execNetwork = context._impl ? plugin.import_model(networkStream, context, config)
|
||||
: plugin.import_model(networkStream, config);
|
||||
networkIsImported = true;
|
||||
execNetwork->loadedFromCache();
|
||||
execNetwork->loaded_from_cache();
|
||||
});
|
||||
} catch (const HeaderException&) {
|
||||
// For these exceptions just remove old cache and set that import didn't work
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "openvino/core/extension.hpp"
|
||||
#include "openvino/core/version.hpp"
|
||||
#include "openvino/runtime/common.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "threading/ie_executor_manager.hpp"
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
@@ -174,20 +175,18 @@ private:
|
||||
|
||||
const bool m_new_api;
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model_impl(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& parsedConfig,
|
||||
const ov::RemoteContext& context,
|
||||
const CacheContent& cacheContent,
|
||||
bool forceDisableCache = false) const;
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model_impl(const std::shared_ptr<const ov::Model>& model,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& parsedConfig,
|
||||
const ov::RemoteContext& context,
|
||||
const CacheContent& cacheContent,
|
||||
bool forceDisableCache = false) const;
|
||||
|
||||
static ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> load_model_from_cache(
|
||||
const CacheContent& cacheContent,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& config,
|
||||
const ov::RemoteContext& context,
|
||||
bool& networkIsImported);
|
||||
static ov::SoPtr<ov::ICompiledModel> load_model_from_cache(const CacheContent& cacheContent,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& config,
|
||||
const ov::RemoteContext& context,
|
||||
bool& networkIsImported);
|
||||
|
||||
bool device_supports_import_export(const ov::Plugin& plugin) const;
|
||||
|
||||
@@ -195,10 +194,10 @@ private:
|
||||
|
||||
bool device_supports_cache_dir(const ov::Plugin& plugin) const;
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(ov::Plugin& plugin,
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const;
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model(ov::Plugin& plugin,
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const;
|
||||
|
||||
ov::AnyMap create_compile_config(const ov::Plugin& plugin,
|
||||
const std::string& deviceFamily,
|
||||
@@ -402,26 +401,26 @@ public:
|
||||
|
||||
std::shared_ptr<ov::Model> read_model(const std::string& model_path, const std::string& bin_path) const override;
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config = {}) const override;
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config = {}) const override;
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config = {}) const override;
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config = {}) const override;
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::string& model_path,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const override;
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model(const std::string& model_path,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const override;
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::string& model_str,
|
||||
const ov::Tensor& weights,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const override;
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model(const std::string& model_str,
|
||||
const ov::Tensor& weights,
|
||||
const std::string& device_name,
|
||||
const ov::AnyMap& config) const override;
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> import_model(std::istream& model,
|
||||
const std::string& device_name = {},
|
||||
const ov::AnyMap& config = {}) const override;
|
||||
ov::SoPtr<ov::ICompiledModel> import_model(std::istream& model,
|
||||
const std::string& device_name = {},
|
||||
const ov::AnyMap& config = {}) const override;
|
||||
|
||||
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const std::string& device_name,
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "ngraph/op/constant.hpp"
|
||||
#include "ngraph/pass/constant_folding.hpp"
|
||||
#include "openvino/itt.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
|
||||
bool ov::CoreImpl::isNewAPI() const {
|
||||
@@ -26,7 +27,7 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::LoadNetwork
|
||||
ov::Plugin& plugin,
|
||||
const std::map<std::string, std::string>& parsedConfig,
|
||||
const InferenceEngine::RemoteContext::Ptr& context) {
|
||||
OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "CoreImpl::compile_model_impl");
|
||||
OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "CoreImpl::LoadNetworkImpl");
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> execNetwork;
|
||||
auto wrapper = std::dynamic_pointer_cast<InferenceEngine::IPluginWrapper>(plugin.m_ptr);
|
||||
OPENVINO_ASSERT(wrapper);
|
||||
@@ -62,7 +63,7 @@ ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::CoreImpl::LoadNetwork
|
||||
ov::RemoteContext ctx{context, {nullptr}};
|
||||
auto compiled_model =
|
||||
compile_model(ov::legacy_convert::convert_model(network, isNewAPI()), ctx, any_copy(config));
|
||||
return {compiled_model._ptr, compiled_model._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(compiled_model._ptr), compiled_model._so};
|
||||
}
|
||||
if (context == nullptr) {
|
||||
IE_THROW() << "Remote context is null";
|
||||
@@ -84,7 +85,7 @@ InferenceEngine::SoExecutableNetworkInternal ov::CoreImpl::LoadNetwork(
|
||||
if (network.getFunction()) {
|
||||
auto compiled_model =
|
||||
compile_model(ov::legacy_convert::convert_model(network, isNewAPI()), deviceName, any_copy(config));
|
||||
return {compiled_model._ptr, compiled_model._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(compiled_model._ptr), compiled_model._so};
|
||||
}
|
||||
auto parsed = parseDeviceNameIntoConfig(deviceName, config);
|
||||
auto plugin = get_plugin(parsed._deviceName);
|
||||
@@ -100,7 +101,7 @@ InferenceEngine::SoExecutableNetworkInternal ov::CoreImpl::LoadNetwork(
|
||||
OV_ITT_SCOPE(FIRST_INFERENCE, ie::itt::domains::IE_LT, "Core::LoadNetwork::Path");
|
||||
|
||||
auto compiled_model = compile_model(modelPath, deviceName, any_copy(config));
|
||||
return {compiled_model._ptr, compiled_model._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(compiled_model._ptr), compiled_model._so};
|
||||
}
|
||||
|
||||
InferenceEngine::SoExecutableNetworkInternal ov::CoreImpl::LoadNetwork(
|
||||
@@ -115,7 +116,7 @@ InferenceEngine::SoExecutableNetworkInternal ov::CoreImpl::LoadNetwork(
|
||||
ov::Tensor{std::const_pointer_cast<InferenceEngine::Blob>(weights), {}},
|
||||
deviceName,
|
||||
ov::any_copy(config));
|
||||
return {compiled_model._ptr, compiled_model._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(compiled_model._ptr), compiled_model._so};
|
||||
}
|
||||
|
||||
InferenceEngine::SoExecutableNetworkInternal ov::CoreImpl::ImportNetwork(
|
||||
@@ -123,7 +124,7 @@ InferenceEngine::SoExecutableNetworkInternal ov::CoreImpl::ImportNetwork(
|
||||
const std::string& deviceName,
|
||||
const std::map<std::string, std::string>& config) {
|
||||
auto compiled_model = import_model(networkModel, deviceName, any_copy(config));
|
||||
return {compiled_model._ptr, compiled_model._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(compiled_model._ptr), compiled_model._so};
|
||||
}
|
||||
|
||||
InferenceEngine::QueryNetworkResult ov::CoreImpl::QueryNetwork(const InferenceEngine::CNNNetwork& network,
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2018-2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
|
||||
#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp"
|
||||
#include "icompiled_model_wrapper.hpp"
|
||||
#include "openvino/core/model.hpp"
|
||||
|
||||
ov::ICompiledModel::ICompiledModel(const std::shared_ptr<const ov::Model>& model,
|
||||
const std::shared_ptr<const ov::IPlugin>& plugin,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& task_executor,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& callback_executor)
|
||||
: m_plugin(plugin),
|
||||
m_task_executor(task_executor),
|
||||
m_callback_executor(callback_executor) {
|
||||
if (model) {
|
||||
// Initialize inputs/outputs
|
||||
m_inputs = model->inputs();
|
||||
m_outputs = model->outputs();
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<ov::Output<const ov::Node>>& ov::ICompiledModel::outputs() const {
|
||||
return m_outputs;
|
||||
}
|
||||
|
||||
const std::vector<ov::Output<const ov::Node>>& ov::ICompiledModel::inputs() const {
|
||||
return m_inputs;
|
||||
}
|
||||
std::shared_ptr<InferenceEngine::IInferRequestInternal> ov::ICompiledModel::create_infer_request() const {
|
||||
if (m_task_executor && m_callback_executor) {
|
||||
return create_async_infer_request();
|
||||
}
|
||||
return create_sync_infer_request();
|
||||
}
|
||||
|
||||
std::shared_ptr<const ov::IPlugin> ov::ICompiledModel::get_plugin() const {
|
||||
return m_plugin;
|
||||
}
|
||||
|
||||
void ov::ICompiledModel::loaded_from_cache() {
|
||||
if (auto wrapper = dynamic_cast<InferenceEngine::ICompiledModelWrapper*>(this)) {
|
||||
wrapper->get_model()->loadedFromCache();
|
||||
return;
|
||||
}
|
||||
OPENVINO_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "icompiled_model_wrapper.hpp"
|
||||
|
||||
#include <ie_plugin_config.hpp>
|
||||
|
||||
InferenceEngine::ICompiledModelWrapper::ICompiledModelWrapper(
|
||||
const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& model)
|
||||
: ov::ICompiledModel(nullptr, ov::legacy_convert::convert_plugin(model->_plugin)),
|
||||
m_model(model) {
|
||||
std::vector<ov::Output<const ov::Node>> inputs, outputs;
|
||||
for (const auto& input : m_model->getInputs()) {
|
||||
inputs.emplace_back(input->output(0));
|
||||
}
|
||||
for (const auto& output : m_model->getOutputs()) {
|
||||
outputs.emplace_back(output->output(0));
|
||||
}
|
||||
m_inputs = inputs;
|
||||
m_outputs = outputs;
|
||||
}
|
||||
std::shared_ptr<InferenceEngine::IInferRequestInternal> InferenceEngine::ICompiledModelWrapper::create_infer_request()
|
||||
const {
|
||||
return m_model->CreateInferRequest();
|
||||
}
|
||||
|
||||
void InferenceEngine::ICompiledModelWrapper::export_model(std::ostream& model) const {
|
||||
m_model->Export(model);
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Model> InferenceEngine::ICompiledModelWrapper::get_runtime_model() const {
|
||||
return m_model->GetExecGraphInfo();
|
||||
}
|
||||
|
||||
void InferenceEngine::ICompiledModelWrapper::set_property(const ov::AnyMap& properties) {
|
||||
m_model->SetConfig(properties);
|
||||
}
|
||||
|
||||
ov::Any InferenceEngine::ICompiledModelWrapper::get_property(const std::string& name) const {
|
||||
if (ov::loaded_from_cache == name) {
|
||||
return m_model->isLoadedFromCache();
|
||||
}
|
||||
if (ov::supported_properties == name) {
|
||||
try {
|
||||
auto supported_properties = m_model->GetMetric(name).as<std::vector<ov::PropertyName>>();
|
||||
supported_properties.erase(std::remove_if(supported_properties.begin(),
|
||||
supported_properties.end(),
|
||||
[](const ov::PropertyName& name) {
|
||||
return name == METRIC_KEY(SUPPORTED_METRICS) ||
|
||||
name == METRIC_KEY(SUPPORTED_CONFIG_KEYS);
|
||||
}),
|
||||
supported_properties.end());
|
||||
return supported_properties;
|
||||
} catch (InferenceEngine::Exception&) {
|
||||
auto ro_properties = m_model->GetMetric(METRIC_KEY(SUPPORTED_METRICS)).as<std::vector<std::string>>();
|
||||
auto rw_properties = m_model->GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS)).as<std::vector<std::string>>();
|
||||
std::vector<ov::PropertyName> supported_properties;
|
||||
for (auto&& ro_property : ro_properties) {
|
||||
if (ro_property != METRIC_KEY(SUPPORTED_METRICS) && ro_property != METRIC_KEY(SUPPORTED_CONFIG_KEYS)) {
|
||||
supported_properties.emplace_back(ro_property, ov::PropertyMutability::RO);
|
||||
}
|
||||
}
|
||||
for (auto&& rw_property : rw_properties) {
|
||||
supported_properties.emplace_back(rw_property, ov::PropertyMutability::RW);
|
||||
}
|
||||
supported_properties.emplace_back(ov::supported_properties.name(), ov::PropertyMutability::RO);
|
||||
supported_properties.emplace_back(ov::loaded_from_cache.name(), ov::PropertyMutability::RO);
|
||||
return supported_properties;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return m_model->GetMetric(name);
|
||||
} catch (InferenceEngine::Exception&) {
|
||||
return m_model->GetConfig(name);
|
||||
}
|
||||
}
|
||||
|
||||
ov::RemoteContext InferenceEngine::ICompiledModelWrapper::get_context() const {
|
||||
return {m_model->GetContext(), {}};
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> InferenceEngine::ICompiledModelWrapper::get_model() {
|
||||
return m_model;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp"
|
||||
#include "dev/converter_utils.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
|
||||
class ICompiledModelWrapper : public ov::ICompiledModel {
|
||||
public:
|
||||
ICompiledModelWrapper(const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& model);
|
||||
std::shared_ptr<InferenceEngine::IInferRequestInternal> create_infer_request() const override;
|
||||
|
||||
void export_model(std::ostream& model) const override;
|
||||
|
||||
std::shared_ptr<ov::Model> get_runtime_model() const override;
|
||||
|
||||
void set_property(const ov::AnyMap& properties) override;
|
||||
|
||||
ov::Any get_property(const std::string& name) const override;
|
||||
|
||||
ov::RemoteContext get_context() const override;
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> get_model();
|
||||
|
||||
private:
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> m_model;
|
||||
|
||||
std::shared_ptr<InferenceEngine::IInferRequestInternal> create_sync_infer_request() const override {
|
||||
OPENVINO_NOT_IMPLEMENTED;
|
||||
}
|
||||
};
|
||||
} // namespace InferenceEngine
|
||||
@@ -45,3 +45,11 @@ bool ov::IPlugin::is_new_api() const {
|
||||
const std::shared_ptr<InferenceEngine::ExecutorManager>& ov::IPlugin::get_executor_manager() const {
|
||||
return m_executor_manager;
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::ICompiledModel> ov::IPlugin::compile_model(const std::string& model_path,
|
||||
const ov::AnyMap& properties) const {
|
||||
auto core = get_core();
|
||||
OPENVINO_ASSERT(core);
|
||||
auto model = core->read_model(model_path, std::string());
|
||||
return compile_model(model, properties);
|
||||
}
|
||||
@@ -23,29 +23,32 @@ IPluginWrapper::IPluginWrapper(const std::shared_ptr<InferenceEngine::IInference
|
||||
m_executor_manager = m_old_plugin->executorManager();
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> IPluginWrapper::compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const {
|
||||
const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& IPluginWrapper::update_exec_network(
|
||||
const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& network) const {
|
||||
network->SetPointerToPlugin(m_old_plugin);
|
||||
return network;
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::ICompiledModel> IPluginWrapper::compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const {
|
||||
auto exec_network =
|
||||
m_old_plugin->LoadNetwork(ov::legacy_convert::convert_model(model, is_new_api()), ov::any_copy(properties));
|
||||
return exec_network;
|
||||
return ov::legacy_convert::convert_compiled_model(update_exec_network(exec_network));
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> IPluginWrapper::compile_model(
|
||||
const std::string& model_path,
|
||||
const ov::AnyMap& properties) const {
|
||||
std::shared_ptr<ov::ICompiledModel> IPluginWrapper::compile_model(const std::string& model_path,
|
||||
const ov::AnyMap& properties) const {
|
||||
auto exec_network = m_old_plugin->LoadNetwork(model_path, any_copy(properties));
|
||||
return exec_network._ptr;
|
||||
return ov::legacy_convert::convert_compiled_model(update_exec_network(exec_network._ptr));
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> IPluginWrapper::compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties,
|
||||
const ov::RemoteContext& context) const {
|
||||
auto compiled_model = m_old_plugin->LoadNetwork(ov::legacy_convert::convert_model(model, is_new_api()),
|
||||
any_copy(properties),
|
||||
context._impl);
|
||||
return compiled_model;
|
||||
std::shared_ptr<ov::ICompiledModel> IPluginWrapper::compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties,
|
||||
const ov::RemoteContext& context) const {
|
||||
return ov::legacy_convert::convert_compiled_model(
|
||||
update_exec_network(m_old_plugin->LoadNetwork(ov::legacy_convert::convert_model(model, is_new_api()),
|
||||
any_copy(properties),
|
||||
context._impl)));
|
||||
}
|
||||
|
||||
void IPluginWrapper::set_property(const ov::AnyMap& properties) {
|
||||
@@ -68,17 +71,17 @@ ov::RemoteContext IPluginWrapper::get_default_context(const ov::AnyMap& remote_p
|
||||
return ov::RemoteContext{m_old_plugin->GetDefaultContext(remote_properties), {nullptr}};
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> IPluginWrapper::import_model(
|
||||
std::istream& model,
|
||||
const ov::AnyMap& properties) const {
|
||||
return m_old_plugin->ImportNetwork(model, any_copy(properties));
|
||||
std::shared_ptr<ov::ICompiledModel> IPluginWrapper::import_model(std::istream& model,
|
||||
const ov::AnyMap& properties) const {
|
||||
return ov::legacy_convert::convert_compiled_model(
|
||||
update_exec_network(m_old_plugin->ImportNetwork(model, any_copy(properties))));
|
||||
}
|
||||
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> IPluginWrapper::import_model(
|
||||
std::istream& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const {
|
||||
return m_old_plugin->ImportNetwork(model, context._impl, any_copy(properties));
|
||||
std::shared_ptr<ov::ICompiledModel> IPluginWrapper::import_model(std::istream& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const {
|
||||
return ov::legacy_convert::convert_compiled_model(
|
||||
update_exec_network(m_old_plugin->ImportNetwork(model, context._impl, any_copy(properties))));
|
||||
}
|
||||
|
||||
ov::SupportedOpsMap IPluginWrapper::query_model(const std::shared_ptr<const ov::Model>& model,
|
||||
|
||||
@@ -29,9 +29,8 @@ public:
|
||||
*
|
||||
* @return shared pointer to compiled model interface
|
||||
*/
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const override;
|
||||
std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const override;
|
||||
|
||||
/**
|
||||
* @brief Create compiled model based on model and properties
|
||||
@@ -41,9 +40,8 @@ public:
|
||||
*
|
||||
* @return shared pointer to compiled model interface
|
||||
*/
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::string& model_path,
|
||||
const ov::AnyMap& properties) const override;
|
||||
std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,
|
||||
const ov::AnyMap& properties) const override;
|
||||
|
||||
/**
|
||||
* @brief Create compiled model based on model and properties
|
||||
@@ -54,10 +52,9 @@ public:
|
||||
*
|
||||
* @return shared pointer to compiled model interface
|
||||
*/
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties,
|
||||
const ov::RemoteContext& context) const override;
|
||||
std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties,
|
||||
const ov::RemoteContext& context) const override;
|
||||
|
||||
/**
|
||||
* @brief Specifies some plugin properties
|
||||
@@ -102,9 +99,7 @@ public:
|
||||
*
|
||||
* @return shared pointer to compiled model interface
|
||||
*/
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> import_model(
|
||||
std::istream& model,
|
||||
const ov::AnyMap& properties) const override;
|
||||
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model, const ov::AnyMap& properties) const override;
|
||||
|
||||
/**
|
||||
* @brief Import model to the plugin
|
||||
@@ -115,8 +110,9 @@ public:
|
||||
*
|
||||
* @return shared pointer to compiled model interface
|
||||
*/
|
||||
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>
|
||||
import_model(std::istream& model, const ov::RemoteContext& context, const ov::AnyMap& properties) const override;
|
||||
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const override;
|
||||
|
||||
/**
|
||||
* @brief query model
|
||||
@@ -161,6 +157,9 @@ public:
|
||||
|
||||
private:
|
||||
std::shared_ptr<InferenceEngine::IInferencePlugin> m_old_plugin;
|
||||
|
||||
const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& update_exec_network(
|
||||
const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& network) const;
|
||||
};
|
||||
|
||||
} // namespace InferenceEngine
|
||||
@@ -55,21 +55,19 @@ void ov::Plugin::set_property(const ov::AnyMap& config) {
|
||||
OV_PLUGIN_CALL_STATEMENT(m_ptr->set_property(config));
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::Plugin::compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const {
|
||||
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->compile_model(model, properties), m_so});
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::Plugin::compile_model(const std::string& model_path,
|
||||
const ov::AnyMap& properties) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::string& model_path,
|
||||
const ov::AnyMap& properties) const {
|
||||
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->compile_model(model_path, properties), m_so});
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::Plugin::compile_model(
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const {
|
||||
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->compile_model(model, properties, context), m_so});
|
||||
}
|
||||
|
||||
@@ -78,14 +76,13 @@ ov::SupportedOpsMap ov::Plugin::query_model(const std::shared_ptr<const ov::Mode
|
||||
OV_PLUGIN_CALL_STATEMENT(return m_ptr->query_model(model, properties));
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::Plugin::import_model(std::istream& model,
|
||||
const ov::AnyMap& properties) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::Plugin::import_model(std::istream& model, const ov::AnyMap& properties) const {
|
||||
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->import_model(model, properties), m_so});
|
||||
}
|
||||
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal> ov::Plugin::import_model(std::istream& networkModel,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const {
|
||||
ov::SoPtr<ov::ICompiledModel> ov::Plugin::import_model(std::istream& networkModel,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const {
|
||||
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->import_model(networkModel, context, config), m_so});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp"
|
||||
#include "ie_iextension.h"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "openvino/runtime/iplugin.hpp"
|
||||
|
||||
namespace ov {
|
||||
@@ -42,24 +42,22 @@ public:
|
||||
|
||||
void set_property(const ov::AnyMap& config);
|
||||
|
||||
SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const;
|
||||
SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::AnyMap& properties) const;
|
||||
|
||||
SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::string& model_path,
|
||||
const ov::AnyMap& properties) const;
|
||||
SoPtr<ov::ICompiledModel> compile_model(const std::string& model_path, const ov::AnyMap& properties) const;
|
||||
|
||||
SoPtr<InferenceEngine::IExecutableNetworkInternal> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const;
|
||||
SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& properties) const;
|
||||
|
||||
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model, const ov::AnyMap& properties) const;
|
||||
|
||||
SoPtr<InferenceEngine::IExecutableNetworkInternal> import_model(std::istream& model,
|
||||
const ov::AnyMap& properties) const;
|
||||
SoPtr<ov::ICompiledModel> import_model(std::istream& model, const ov::AnyMap& properties) const;
|
||||
|
||||
SoPtr<InferenceEngine::IExecutableNetworkInternal> import_model(std::istream& networkModel,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const;
|
||||
SoPtr<ov::ICompiledModel> import_model(std::istream& networkModel,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const;
|
||||
|
||||
ov::RemoteContext create_context(const AnyMap& params) const;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "cpp/ie_cnn_network.h"
|
||||
#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp"
|
||||
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
|
||||
#include "dev/converter_utils.hpp"
|
||||
#include "dev/core_impl.hpp"
|
||||
#include "file_utils.h"
|
||||
#include "ie_cache_guard.hpp"
|
||||
@@ -181,7 +182,7 @@ ExecutableNetwork Core::ImportNetwork(const std::string& modelFileName,
|
||||
if (!modelStream.is_open())
|
||||
IE_THROW(NetworkNotRead) << "Model file " << modelFileName << " cannot be opened!";
|
||||
auto exec = _impl->get_plugin(parsed._deviceName).import_model(modelStream, ov::any_copy(parsed._config));
|
||||
return {exec._ptr, exec._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(exec._ptr), exec._so};
|
||||
}
|
||||
|
||||
ExecutableNetwork Core::ImportNetwork(std::istream& networkModel,
|
||||
@@ -211,7 +212,7 @@ ExecutableNetwork Core::ImportNetwork(std::istream& networkModel) {
|
||||
networkModel.seekg(currentPos, networkModel.beg);
|
||||
|
||||
auto exec = _impl->get_plugin(deviceName).import_model(networkModel, {});
|
||||
return {exec._ptr, exec._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(exec._ptr), exec._so};
|
||||
}
|
||||
|
||||
ExecutableNetwork Core::ImportNetwork(std::istream& networkModel,
|
||||
@@ -232,7 +233,7 @@ ExecutableNetwork Core::ImportNetwork(std::istream& networkModel,
|
||||
.import_model(networkModel,
|
||||
ov::RemoteContext{std::dynamic_pointer_cast<RemoteContext>(context), {}},
|
||||
ov::any_copy(parsed._config));
|
||||
return {exec._ptr, exec._so};
|
||||
return {ov::legacy_convert::convert_compiled_model(exec._ptr), exec._so};
|
||||
}
|
||||
|
||||
QueryNetworkResult Core::QueryNetwork(const CNNNetwork& network,
|
||||
|
||||
+12
-17
@@ -7,6 +7,7 @@
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include "ie_icore.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
|
||||
class MockICore : public InferenceEngine::ICore {
|
||||
public:
|
||||
@@ -72,26 +73,20 @@ public:
|
||||
const std::string&,
|
||||
const ov::AnyMap&));
|
||||
MOCK_CONST_METHOD3(import_model,
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal>(std::istream&,
|
||||
const std::string&,
|
||||
const ov::AnyMap&));
|
||||
ov::SoPtr<ov::ICompiledModel>(std::istream&, const std::string&, const ov::AnyMap&));
|
||||
MOCK_CONST_METHOD3(compile_model,
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal>(const std::shared_ptr<const ov::Model>&,
|
||||
const std::string&,
|
||||
const ov::AnyMap&));
|
||||
ov::SoPtr<ov::ICompiledModel>(const std::shared_ptr<const ov::Model>&,
|
||||
const std::string&,
|
||||
const ov::AnyMap&));
|
||||
MOCK_CONST_METHOD3(compile_model,
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal>(const std::shared_ptr<const ov::Model>&,
|
||||
const ov::RemoteContext&,
|
||||
const ov::AnyMap&));
|
||||
ov::SoPtr<ov::ICompiledModel>(const std::shared_ptr<const ov::Model>&,
|
||||
const ov::RemoteContext&,
|
||||
const ov::AnyMap&));
|
||||
MOCK_CONST_METHOD3(compile_model,
|
||||
ov::SoPtr<InferenceEngine::IExecutableNetworkInternal>(const std::string&,
|
||||
const std::string&,
|
||||
const ov::AnyMap&));
|
||||
MOCK_CONST_METHOD4(compile_model,
|
||||
InferenceEngine::SoExecutableNetworkInternal(const std::string&,
|
||||
const ov::Tensor&,
|
||||
const std::string&,
|
||||
const ov::AnyMap&));
|
||||
ov::SoPtr<ov::ICompiledModel>(const std::string&, const std::string&, const ov::AnyMap&));
|
||||
MOCK_CONST_METHOD4(
|
||||
compile_model,
|
||||
ov::SoPtr<ov::ICompiledModel>(const std::string&, const ov::Tensor&, const std::string&, const ov::AnyMap&));
|
||||
MOCK_CONST_METHOD3(read_model, std::shared_ptr<ov::Model>(const std::string&, const ov::Tensor&, bool));
|
||||
MOCK_CONST_METHOD2(read_model, std::shared_ptr<ov::Model>(const std::string&, const std::string&));
|
||||
MOCK_CONST_METHOD1(get_default_context, ov::RemoteContext(const std::string&));
|
||||
|
||||
Reference in new issue
Block a user