1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * \brief inference engine plugin API wrapper, to be used by particular implementors
7 * \file ie_plugin_base.hpp
15 #include <ie_plugin.hpp>
16 #include <ie_ihetero_plugin.hpp>
17 #include "description_buffer.hpp"
18 #include "cpp_interfaces/exception2status.hpp"
20 namespace InferenceEngine {
23 * @brief cpp interface for plugin, to avoid dll boundaries ,and simplify internal development
24 * @tparam T Minimal CPP implementation of IInferencePlugin (e.g. IInferencePluginInternal)
25 * @details can be used to create external wrapper too
28 class HeteroPluginBase : public IHeteroInferencePlugin {
30 class VersionStore : public Version {
32 std::string _buildNumber;
34 explicit VersionStore(const Version &v) {
36 _buildNumber = v.buildNumber;
37 description = _dsc.c_str();
38 buildNumber = _buildNumber.c_str();
39 apiVersion = v.apiVersion;
43 std::shared_ptr<T> _impl;
48 * @param actualReported version that are to be reported
50 HeteroPluginBase(const Version &actualReported, std::shared_ptr<T> impl) : _version(actualReported) {
51 if (impl.get() == nullptr) {
52 THROW_IE_EXCEPTION << "implementation not defined";
58 * @brief return plugin's version information
59 * @param versionInfo pointer to version info, will be set by plugin
61 void GetVersion(const Version *&versionInfo) noexcept override {
62 versionInfo = &_version;
65 void SetLogCallback(IErrorListener &listener) noexcept override {
66 NO_EXCEPT_CALL_RETURN_VOID(_impl->SetLogCallback(listener));
69 StatusCode LoadNetwork(ICNNNetwork &network, ResponseDesc *resp) noexcept override {
70 TO_STATUS(_impl->LoadNetwork(network));
73 StatusCode LoadNetwork(IExecutableNetwork::Ptr &executableNetwork,
75 const std::map<std::string, std::string> &config,
76 ResponseDesc *resp)noexcept override {
77 TO_STATUS(_impl->LoadNetwork(executableNetwork, network, config));
80 StatusCode Infer(const Blob &input, Blob &result, ResponseDesc *resp) noexcept override {
81 TO_STATUS(_impl->Infer(input, result));
84 StatusCode Infer(const BlobMap &input, BlobMap &result, ResponseDesc *resp)noexcept override {
85 TO_STATUS(_impl->Infer(input, result));
88 StatusCode GetPerformanceCounts(std::map<std::string,
89 InferenceEngineProfileInfo> &perfMap, ResponseDesc *resp) const noexcept override {
90 TO_STATUS(_impl->GetPerformanceCounts(perfMap));
93 StatusCode AddExtension(InferenceEngine::IExtensionPtr extension,
94 InferenceEngine::ResponseDesc *resp) noexcept override {
95 TO_STATUS(_impl->AddExtension(extension));
98 StatusCode SetConfig(const std::map<std::string, std::string> &config, ResponseDesc *resp) noexcept override {
99 TO_STATUS(_impl->SetConfig(config));
102 StatusCode ImportNetwork(IExecutableNetwork::Ptr &ret, const std::string &modelFileName,
103 const std::map<std::string, std::string> &config, ResponseDesc *resp) noexcept override {
104 TO_STATUS(ret = _impl->ImportNetwork(modelFileName, config));
107 void Release() noexcept override {
111 void SetDeviceLoader(const std::string &device, IHeteroDeviceLoader::Ptr loader)noexcept override {
112 _impl->SetDeviceLoader(device, loader);
115 StatusCode SetAffinity(
116 ICNNNetwork& network,
117 const std::map<std::string, std::string> &config,
118 ResponseDesc *resp) noexcept override {
119 TO_STATUS(_impl->SetAffinity(network, config));
124 ~HeteroPluginBase() = default;
127 } // namespace InferenceEngine