21 class ICompletionCallbackWrapper {
23 virtual ~ICompletionCallbackWrapper() =
default;
29 class CompletionCallbackWrapper :
public ICompletionCallbackWrapper {
32 explicit CompletionCallbackWrapper(
const T &lambda) : lambda(lambda) {}
34 void call(InferenceEngine::IInferRequest::Ptr ,
41 class CompletionCallbackWrapper<IInferRequest::CompletionCallback> :
public ICompletionCallbackWrapper {
47 callBack(request, code);
59 IInferRequest::Ptr actual;
60 std::shared_ptr<details::ICompletionCallbackWrapper> callback;
63 details::ICompletionCallbackWrapper *pWrapper =
nullptr;
65 request->GetUserData(reinterpret_cast<void**>(&pWrapper), &dsc);
66 pWrapper->call(request, code);
79 CALL_STATUS_FNC(SetBlob, name.c_str(), data);
88 CALL_STATUS_FNC(GetBlob, name.c_str(), data);
89 std::string error =
"Internal error: blob with name `" + name +
"` is not allocated!";
90 auto blobPtr = data.get();
101 CALL_STATUS_FNC_NO_ARGS(Infer);
109 std::map<std::string, InferenceEngineProfileInfo> perfMap;
110 CALL_STATUS_FNC(GetPerformanceCounts, perfMap);
121 for (
auto &&input : inputs) {
122 CALL_STATUS_FNC(SetBlob, input.first.c_str(), input.second);
133 for (
auto &&result : results) {
134 CALL_STATUS_FNC(SetBlob, result.first.c_str(), result.second);
143 CALL_STATUS_FNC(SetBatch, batch);
157 CALL_STATUS_FNC_NO_ARGS(StartAsync);
165 return actual->Wait(millis_timeout,
nullptr);
176 callback.reset(
new details::CompletionCallbackWrapper<T>(callbackToSet));
177 CALL_STATUS_FNC(SetUserData, callback.get());
178 actual->SetCompletionCallback(callWrapper);
184 operator IInferRequest::Ptr &() {
188 bool operator!()
const noexcept {
192 explicit operator bool()
const noexcept {
196 using Ptr = std::shared_ptr<InferRequest>;
202 class CompletionCallbackWrapper<std::function<void(InferRequest, StatusCode)>>
203 :
public ICompletionCallbackWrapper {
204 std::function<void(InferRequest, StatusCode)> lambda;
209 void call(InferenceEngine::IInferRequest::Ptr request,
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:22
void StartAsync()
Start inference of specified input(s) in asynchronous mode.
Definition: ie_infer_request.hpp:156
Definition: ie_argmax_layer.hpp:11
Blob::Ptr GetBlob(const std::string &name)
Wraps original method IInferRequest::GetBlob.
Definition: ie_infer_request.hpp:86
StatusCode Wait(int64_t millis_timeout)
Wraps original method IInferRequest::Wait.
Definition: ie_infer_request.hpp:164
A header file that provides macros to handle no exception methods.
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:172
void SetInput(const BlobMap &inputs)
Sets input data to infer.
Definition: ie_infer_request.hpp:120
void SetOutput(const BlobMap &results)
Sets data that will contain result of the inference.
Definition: ie_infer_request.hpp:132
void SetBlob(const std::string &name, const Blob::Ptr &data)
Sets input/output data to infer.
Definition: ie_infer_request.hpp:78
a header file for IInferRequest interface
This class is a wrapper of IInferRequest to provide setters/getters of input/output which operates wi...
Definition: ie_infer_request.hpp:58
void SetCompletionCallback(const T &callbackToSet)
Wraps original method IInferRequest::SetCompletionCallback.
Definition: ie_infer_request.hpp:175
Represents detailed information for an error.
Definition: ie_common.h:195
std::shared_ptr< Blob > Ptr
A smart pointer containing Blob object.
Definition: ie_blob.h:38
InferRequest(IInferRequest::Ptr request)
Definition: ie_infer_request.hpp:150
std::map< std::string, Blob::Ptr > BlobMap
This is a convenient type for working with a map containing pairs(string, pointer to a Blob instance)...
Definition: ie_blob.h:259
void(* CompletionCallback)(InferenceEngine::IInferRequest::Ptr context, InferenceEngine::StatusCode code)
Completion callback definition as pointer to a function.
Definition: ie_iinfer_request.hpp:102
std::map< std::string, InferenceEngineProfileInfo > GetPerformanceCounts() const
Wraps original method IInferRequest::GetPerformanceCounts.
Definition: ie_infer_request.hpp:108
void Infer()
Wraps original method IInferRequest::Infer.
Definition: ie_infer_request.hpp:100
void SetBatch(const int batch)
Sets new batch size when dynamic batching is enabled in executable network that created this request...
Definition: ie_infer_request.hpp:142