Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / hetero_plugin / hetero_infer_request.h
1 //
2 // Copyright 2017-2018 Intel Corporation.
3 //
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.
11 //
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.
15 //
16
17 /**
18  * @brief a header file for IInferRequest interface
19  * @file ie_iinfer_request.hpp
20  */
21
22 #pragma once
23
24 #include <map>
25 #include <string>
26 #include <vector>
27 #include <memory>
28 #include <unordered_set>
29 #include <ie_common.h>
30 #include <cpp_interfaces/impl/ie_infer_request_internal.hpp>
31 #include <cpp_interfaces/impl/ie_executable_network_internal.hpp>
32 #include <cpp/ie_infer_request.hpp>
33 #include <cpp/ie_executable_network.hpp>
34
35 namespace HeteroPlugin {
36
37 class HeteroInferRequest : public InferenceEngine::InferRequestInternal {
38 public:
39     typedef std::shared_ptr<HeteroInferRequest> Ptr;
40
41     struct SubRequestDesc {
42         InferenceEngine::ExecutableNetwork::Ptr _network;
43         InferenceEngine::InferRequest::Ptr _request;
44         std::unordered_set<std::string> _iNames;
45         std::unordered_set<std::string> _oNames;
46         InferenceEngine::ProfilingTask _profilingTask;
47     };
48     using SubRequestsList = std::vector<SubRequestDesc>;
49
50     explicit HeteroInferRequest(InferenceEngine::InputsDataMap networkInputs,
51                                 InferenceEngine::OutputsDataMap networkOutputs,
52                                 const SubRequestsList &inferRequests);
53
54     void InferImpl() override;
55
56     void
57     GetPerformanceCounts(std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> &perfMap) const override;
58
59     void updateInOutIfNeeded();
60
61     void setCallbackSequence();
62
63     void startFirstAsyncRequest();
64
65     InferenceEngine::StatusCode waitAllRequests(int64_t millis_timeout);
66
67     void setCallbackForLastRequest(std::function<void(InferenceEngine::InferRequest, InferenceEngine::StatusCode)>& callback);
68
69     bool isAnyRequestBusy();
70
71 private:
72     SubRequestsList _inferRequests;
73     std::map<std::string, InferenceEngine::Blob::Ptr> _blobs;
74 };
75
76 }  // namespace HeteroPlugin
77