1 // Copyright (C) 2018 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
10 #include "ie_iinfer_request.hpp"
11 #include "cpp_interfaces/exception2status.hpp"
12 #include "ie_profiling.hpp"
14 namespace InferenceEngine {
17 * @brief cpp interface for async infer request, to avoid dll boundaries and simplify internal development
18 * @tparam T Minimal CPP implementation of IInferRequest (e.g. AsyncInferRequestThreadSafeDefault)
21 class InferRequestBase : public IInferRequest {
23 std::shared_ptr<T> _impl;
26 typedef std::shared_ptr<InferRequestBase<T>> Ptr;
28 explicit InferRequestBase(std::shared_ptr<T> impl) : _impl(impl) {}
30 StatusCode Infer(ResponseDesc *resp) noexcept override {
31 IE_PROFILING_AUTO_SCOPE(Infer);
32 TO_STATUS(_impl->Infer());
35 StatusCode GetPerformanceCounts(std::map<std::string, InferenceEngineProfileInfo> &perfMap,
36 ResponseDesc *resp) const noexcept override {
37 TO_STATUS(_impl->GetPerformanceCounts(perfMap));
40 StatusCode SetBlob(const char *name, const Blob::Ptr &data, ResponseDesc *resp) noexcept override {
41 TO_STATUS(_impl->SetBlob(name, data));
44 StatusCode GetBlob(const char *name, Blob::Ptr &data, ResponseDesc *resp) noexcept override {
45 TO_STATUS(_impl->GetBlob(name, data));
48 StatusCode StartAsync(ResponseDesc *resp) noexcept override {
49 IE_PROFILING_AUTO_SCOPE(StartAsync);
50 TO_STATUS(_impl->StartAsync());
53 StatusCode Wait(int64_t millis_timeout, ResponseDesc *resp) noexcept override {
54 IE_PROFILING_AUTO_SCOPE(Wait);
55 NO_EXCEPT_CALL_RETURN_STATUS(_impl->Wait(millis_timeout));
58 StatusCode SetCompletionCallback(CompletionCallback callback) noexcept override {
59 TO_STATUS_NO_RESP(_impl->SetCompletionCallback(callback));
62 StatusCode GetUserData(void **data, ResponseDesc *resp) noexcept override {
63 TO_STATUS(_impl->GetUserData(data));
66 StatusCode SetUserData(void *data, ResponseDesc *resp) noexcept override {
67 TO_STATUS(_impl->SetUserData(data));
70 void Release() noexcept override {
74 StatusCode SetBatch(int batch_size, ResponseDesc *resp) noexcept override {
75 TO_STATUS(_impl->SetBatch(batch_size));
79 ~InferRequestBase() = default;
82 } // namespace InferenceEngine