2 // Copyright (C) 2018-2019 Intel Corporation.
4 // This software and the related documents are Intel copyrighted materials,
5 // and your use of them is governed by the express license under which they
6 // were provided to you (End User License Agreement for the Intel(R) Software
7 // Development Products (Version May 2017)). Unless the License provides
8 // otherwise, you may not use, modify, copy, publish, distribute, disclose or
9 // transmit this software or the related documents without Intel's prior
10 // written permission.
12 // This software and the related documents are provided as is, with no
13 // express or implied warranties, other than those that are expressly
14 // stated in the License.
18 * \brief inference engine plugin API wrapper, to be used by particular implementors
19 * \file ie_plugin_base.hpp
27 #include <ie_plugin.hpp>
28 #include <ie_ihetero_plugin.hpp>
29 #include "description_buffer.hpp"
30 #include "cpp_interfaces/exception2status.hpp"
32 namespace InferenceEngine {
35 * @brief cpp interface for plugin, to avoid dll boundaries ,and simplify internal development
36 * @tparam T Minimal CPP implementation of IInferencePlugin (e.g. IInferencePluginInternal)
37 * @details can be used to create external wrapper too
40 class HeteroPluginBase : public IHeteroInferencePlugin {
42 class VersionStore : public Version {
44 std::string _buildNumber;
46 explicit VersionStore(const Version &v) {
48 _buildNumber = v.buildNumber;
49 description = _dsc.c_str();
50 buildNumber = _buildNumber.c_str();
51 apiVersion = v.apiVersion;
55 std::shared_ptr<T> _impl;
60 * @param actualReported version that are to be reported
62 HeteroPluginBase(const Version &actualReported, std::shared_ptr<T> impl) : _version(actualReported) {
63 if (impl.get() == nullptr) {
64 THROW_IE_EXCEPTION << "implementation not defined";
70 * @brief return plugin's version information
71 * @param versionInfo pointer to version info, will be set by plugin
73 void GetVersion(const Version *&versionInfo) noexcept override {
74 versionInfo = &_version;
77 void SetLogCallback(IErrorListener &listener) noexcept override {
78 NO_EXCEPT_CALL_RETURN_VOID(_impl->SetLogCallback(listener));
81 StatusCode LoadNetwork(ICNNNetwork &network, ResponseDesc *resp) noexcept override {
82 TO_STATUS(_impl->LoadNetwork(network));
85 StatusCode LoadNetwork(IExecutableNetwork::Ptr &executableNetwork,
87 const std::map<std::string, std::string> &config,
88 ResponseDesc *resp)noexcept override {
89 TO_STATUS(_impl->LoadNetwork(executableNetwork, network, config));
92 StatusCode Infer(const Blob &input, Blob &result, ResponseDesc *resp) noexcept override {
93 TO_STATUS(_impl->Infer(input, result));
96 StatusCode Infer(const BlobMap &input, BlobMap &result, ResponseDesc *resp)noexcept override {
97 TO_STATUS(_impl->Infer(input, result));
100 StatusCode GetPerformanceCounts(std::map<std::string,
101 InferenceEngineProfileInfo> &perfMap, ResponseDesc *resp) const noexcept override {
102 TO_STATUS(_impl->GetPerformanceCounts(perfMap));
105 StatusCode AddExtension(InferenceEngine::IExtensionPtr extension,
106 InferenceEngine::ResponseDesc *resp) noexcept override {
107 TO_STATUS(_impl->AddExtension(extension));
110 StatusCode SetConfig(const std::map<std::string, std::string> &config, ResponseDesc *resp) noexcept override {
111 TO_STATUS(_impl->SetConfig(config));
114 StatusCode ImportNetwork(IExecutableNetwork::Ptr &ret, const std::string &modelFileName,
115 const std::map<std::string, std::string> &config, ResponseDesc *resp) noexcept override {
116 TO_STATUS(ret = _impl->ImportNetwork(modelFileName, config));
119 void Release() noexcept override {
123 void SetDeviceLoader(const std::string &device, IHeteroDeviceLoader::Ptr loader)noexcept override {
124 _impl->SetDeviceLoader(device, loader);
127 StatusCode SetAffinity(
128 ICNNNetwork& network,
129 const std::map<std::string, std::string> &config,
130 ResponseDesc *resp) noexcept override {
131 TO_STATUS(_impl->SetAffinity(network, config));
136 ~HeteroPluginBase() = default;
139 } // namespace InferenceEngine