Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto plugin async infer request implementation #5707

Merged
merged 2 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions inference-engine/include/cpp/ie_infer_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ class INFERENCE_ENGINE_API_CLASS(InferRequest) {
* @return true if current InferRequest object is initialized, false - otherwise
*/
explicit operator bool() const noexcept;

/**
* @brief Compares whether this request wraps the same impl underneath
* @return true if current InferRequest object doesn't wrap the same impl as the operator's arg
*/
bool operator!=(const InferRequest&) const noexcept;

/**
* @brief Compares whether this request wraps the same impl underneath
* @return true if current InferRequest object wraps the same impl as the operator's arg
*/
bool operator==(const InferRequest&) const noexcept;
};

template<>
Expand Down
10 changes: 7 additions & 3 deletions inference-engine/src/auto_plugin/auto_exec_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ AutoExecutableNetwork::AutoExecutableNetwork(const SoExecutableNetworkInternal&

AutoExecutableNetwork::~AutoExecutableNetwork() = default;

IInferRequestInternal::Ptr AutoExecutableNetwork::CreateInferRequestImpl(InputsDataMap networkInputs,
InferenceEngine::IInferRequestInternal::Ptr AutoExecutableNetwork::CreateInferRequestImpl(InputsDataMap networkInputs,
OutputsDataMap networkOutputs) {
SoIInferRequestInternal inferRequest = { _network, _network->CreateInferRequest() };
return std::make_shared<AutoInferRequest>(networkInputs, networkOutputs, inferRequest);
IE_THROW(NotImplemented);
}

InferenceEngine::IInferRequestInternal::Ptr AutoExecutableNetwork::CreateInferRequest() {
SoIInferRequestInternal inferRequest = {_network, _network->CreateInferRequest()};
return std::make_shared<AutoInferRequest>(_networkInputs, _networkOutputs, inferRequest);
}

void AutoExecutableNetwork::Export(std::ostream& networkModel) {
Expand Down
4 changes: 3 additions & 1 deletion inference-engine/src/auto_plugin/auto_exec_network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct DeviceInformation {
std::map<std::string, std::string> config;
};

class AutoExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSafeDefault {
class AutoExecutableNetwork : public InferenceEngine::ExecutableNetworkInternal {
public:
using Ptr = std::shared_ptr<AutoExecutableNetwork>;

Expand All @@ -38,6 +38,8 @@ class AutoExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSaf
InferenceEngine::Parameter GetConfig(const std::string& name) const override;
InferenceEngine::IInferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs,
InferenceEngine::OutputsDataMap networkOutputs) override;
InferenceEngine::IInferRequestInternal::Ptr CreateInferRequest() override;

~AutoExecutableNetwork() override;

private:
Expand Down
12 changes: 12 additions & 0 deletions inference-engine/src/auto_plugin/auto_infer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@ void AutoInferRequest::Cancel() {
_inferRequest->Cancel();
}

void AutoInferRequest::StartAsync() {
_inferRequest->StartAsync();
}

InferenceEngine::StatusCode AutoInferRequest::Wait(int64_t millis_timeout) {
return _inferRequest->Wait(millis_timeout);
}

void AutoInferRequest::SetCallback(Callback callback) {
_inferRequest->SetCallback(callback);
}

} // namespace AutoPlugin
4 changes: 4 additions & 0 deletions inference-engine/src/auto_plugin/auto_infer_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class AutoInferRequest : public InferenceEngine::IInferRequestInternal {
void SetBlob(const std::string& name, const InferenceEngine::Blob::Ptr& data) override;
InferenceEngine::Blob::Ptr GetBlob(const std::string& name) override;
void Cancel() override;
//async impl
void StartAsync() override;
InferenceEngine::StatusCode Wait(int64_t millis_timeout) override;
void SetCallback(Callback callback) override;

private:
InferenceEngine::SoIInferRequestInternal _inferRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,12 @@ bool InferRequest::operator!() const noexcept {
InferRequest::operator bool() const noexcept {
return !!_impl;
}

bool InferRequest::operator!=(const InferRequest& r) const noexcept {
return !(r == *this);
}

bool InferRequest::operator==(const InferRequest& r) const noexcept {
return r._impl == _impl;
}
} // namespace InferenceEngine
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ TEST_P(CallbackTests, canCallSyncAndAsyncWithCompletionCallback) {
// Create InferRequest
InferenceEngine::InferRequest req = execNet.CreateInferRequest();
bool isCalled = false;
req.SetCompletionCallback<std::function<void(InferenceEngine::InferRequest, InferenceEngine::StatusCode)>>(
req.SetCompletionCallback<std::function<void(InferenceEngine::InferRequest r, InferenceEngine::StatusCode)>>(
[&](InferenceEngine::InferRequest request, InferenceEngine::StatusCode status) {
ASSERT_TRUE(req == request); //the callback is called on the same impl of the request
// HSD_1805940120: Wait on starting callback return HDDL_ERROR_INVAL_TASK_HANDLE
if (targetDevice != CommonTestUtils::DEVICE_HDDL) {
ASSERT_EQ(static_cast<int>(InferenceEngine::StatusCode::OK), status);
Expand Down