openvx_extension.hpp
1 // Copyright (C) 2018 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * \brief Main MKL-DNN Extension API
7  * \file mkldnn_extension.hpp
8  */
9 #pragma once
10 
11 #include <VX/vx.h>
12 #include <VX/vx_intel_volatile.h>
13 #include <fstream>
14 #include <vector>
15 
16 #include <ie_icnn_network.hpp>
17 #include "details/ie_no_copy.hpp"
18 #include "ie_api.h"
19 #include "ie_error.hpp"
20 #include "ie_version.hpp"
21 
22 #if defined(_WIN32) && defined(IMPLEMENT_INFERENCE_EXTENSION_API)
23 #define INFERENCE_EXTENSION_API(TYPE) extern "C" __declspec(dllexport) TYPE
24 #else
25 #define INFERENCE_EXTENSION_API(TYPE) INFERENCE_ENGINE_API(TYPE)
26 #define INFERENCE_EXTENSION_CDECL INFERENCE_ENGINE_CDECL
27 #endif
28 
29 namespace OpenVXPlugin {
30 
32  vx_context ctx;
33  vx_graph grf;
34  InferenceEngine::TargetDevice targetDevice;
35  bool supports4D;
36  std::ofstream _graphFile;
37 };
38 
40 public:
41  enum DATA_MANIPULATION_TYPE {
42  NONE, INPUT_FROM_OUTPUT, OUTPUT_FROM_INPUT
43  };
44 
45  virtual ~IOVXExtensionLayer() {}
46 
47  // todo: virtual void BuildMdData(OpenVXGraphParams &ovxPrms) = 0;
48  virtual DATA_MANIPULATION_TYPE getDataManipulationType() { return NONE; } // default
49  virtual vx_node GetOpenVXNode(OpenVXGraphParams &ovxPrms, const std::vector<vx_tensor> &input,
50  const std::vector<vx_tensor> &output) {
51  return nullptr;
52  }
53 
54  virtual void GetInputDataFromOutput(std::vector<vx_tensor> &input, const std::vector<vx_tensor> &output) {}
55 
56  virtual void GetOutputDataFromInput(const std::vector<vx_tensor> &input, std::vector<vx_tensor> &output) {}
57 };
58 
59 
60 /**
61  * @class IMKLDNNExtension
62  * @brief Main extension interface
63  */
64 class IOpenVXExtension : public InferenceEngine::details::IRelease {
65 public:
66  /**
67  * @brief Gets the extension version information
68  * @param versionInfo Pointer to version info, set by plugin
69  */
70  virtual void GetVersion(const InferenceEngine::Version *&versionInfo) noexcept = 0;
71 
72  /**
73  * @brief Logging is used to track what is going on inside
74  * @param listener Logging listener
75  */
76  virtual void SetLogCallback(InferenceEngine::IErrorListener &listener) noexcept = 0;
77 
78  /**
79  * @brief Creates a generic layer and returns a pointer to an instance
80  * @param primitive Pointer to a newly created layer
81  * @param layer Layer parameters (source for name, type, precision, attr, weights etc.)
82  * @param resp Pointer to the response message that holds a description of an error if any occurred
83  * @return Status code of the operation. OK if succeeded
84  */
85  virtual InferenceEngine::StatusCode CreateOpenVXLayer(IOVXExtensionLayer **extLayer,
86  const InferenceEngine::CNNLayerPtr layer,
87  InferenceEngine::ResponseDesc *resp) noexcept = 0;
88 
89  /**
90  * @brief could be used to cleanup resources
91  */
92  virtual void Unload() noexcept = 0;
93 };
94 
95 
96 /**
97  * @brief Creator function to create the default instance of the extension
98  * @param ext - pointer to extension that will contain returned value
99  * @param resp Pointer to the response message that holds a description of an error if any occurred
100  * @return Status code of the operation. OK if succeeded
101  */
102 INFERENCE_EXTENSION_API(InferenceEngine::StatusCode) CreateOpenVXExtension(IOpenVXExtension *&ext,
103  InferenceEngine::ResponseDesc *resp) noexcept;
104 } // namespace OpenVXPlugin
TargetDevice
Describes known device types.
Definition: ie_device.hpp:23
A header file that provides versioning information for the inference engine shared library...
A header file for a plugin logging mechanism.
Represents version information that describes plugins and the inference engine runtime library...
Definition: ie_version.hpp:20
std::shared_ptr< CNNLayer > CNNLayerPtr
A smart pointer to the CNNLayer.
Definition: ie_common.h:36
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:172
This is a header file for the ICNNNetwork class.
Represents detailed information for an error.
Definition: ie_common.h:195
Definition: openvx_extension.hpp:31
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
Definition: openvx_extension.hpp:29
This class represents a custom error listener. Plugin consumers can provide it via InferenceEngine::S...
Definition: ie_error.hpp:16
header file for no_copy class
Definition: openvx_extension.hpp:39
Definition: openvx_extension.hpp:64