fixed excessive outputs copying (in case when the fallback happened) and updated the test for that (#10110)

* fixed excessive outputs copying (in case when the fallback happened) and updated the test for that

* enum eExecutionFlavor to cover initial state
This commit is contained in:
Maxim Shevtsov 2022-02-04 16:58:37 +03:00 committed by GitHub
parent 9743784f91
commit 8a85bfa312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -271,7 +271,10 @@ AutoBatchAsyncInferRequest::AutoBatchAsyncInferRequest(
auto& batchReq = this->_inferRequest->_myBatchedRequestWrapper;
if (batchReq._exceptionPtr) // when the batchN execution failed
std::rethrow_exception(batchReq._exceptionPtr);
this->_inferRequest->CopyOutputsIfNeeded();
// in the case of non-batched execution the blobs were set explicitly
if (AutoBatchInferRequest::eExecutionFlavor::BATCH_EXECUTED ==
this->_inferRequest->_wasBatchedRequestUsed)
this->_inferRequest->CopyOutputsIfNeeded();
if (needPerfCounters) {
try {
this->_inferRequest->_perfMap = batchReq._inferRequestBatched->GetPerformanceCounts();
@ -399,6 +402,8 @@ std::pair<AutoBatchExecutableNetwork::WorkerInferRequest&, int> AutoBatchExecuta
IE_ASSERT(workerRequestPtr->_tasks.try_pop(t));
workerRequestPtr->_completionTasks[n] = std::move(t.second);
t.first->_inferRequest->CopyInputsIfNeeded();
t.first->_inferRequest->_wasBatchedRequestUsed =
AutoBatchInferRequest::eExecutionFlavor::BATCH_EXECUTED;
}
workerRequestPtr->_inferRequestBatched->StartAsync();
} else if ((status == std::cv_status::timeout) && sz) {
@ -418,6 +423,8 @@ std::pair<AutoBatchExecutableNetwork::WorkerInferRequest&, int> AutoBatchExecuta
if (sz == ++arrived)
all_completed.set_value();
});
t.first->_inferRequest->_wasBatchedRequestUsed =
AutoBatchInferRequest::eExecutionFlavor::TIMEOUT_EXECUTED;
t.first->_inferRequest->SetBlobsToAnotherRequest(t.first->_inferRequestWithoutBatch);
t.first->_inferRequestWithoutBatch->StartAsync();
}

View File

@ -106,6 +106,11 @@ public:
void CopyOutputsIfNeeded();
AutoBatchExecutableNetwork::WorkerInferRequest& _myBatchedRequestWrapper;
std::exception_ptr _exceptionPtr;
enum eExecutionFlavor : uint8_t {
NOT_EXECUTED,
BATCH_EXECUTED,
TIMEOUT_EXECUTED
} _wasBatchedRequestUsed = eExecutionFlavor::NOT_EXECUTED;
std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> _perfMap;
protected:

View File

@ -80,8 +80,11 @@ protected:
device_name + "(" + std::to_string(num_batch) + ")",
config);
auto network_outputs = net.getOutputsInfo();
ASSERT_EQ(network_outputs.size(), 1) << " Auto-Batching tests use networks with single output";
auto output = network_outputs.begin(); //single output
for (size_t j = 0; j < num_requests; j++) {
outputs.push_back(net.getOutputsInfo().begin()->first); //single output
outputs.push_back(output->first);
outElementsCount.push_back(
std::accumulate(begin(fn_ptrs[i]->get_output_shape(0)), end(fn_ptrs[i]->get_output_shape(0)), 1,
std::multiplies<size_t>()));
@ -103,6 +106,11 @@ protected:
const auto inBlobBuf = inBlob->cbuffer().as<uint8_t *>();
inData.push_back(std::vector<uint8_t>(inBlobBuf, inBlobBuf + blobSize));
}
if (!use_get_blob) {
auto blob = FuncTestUtils::createAndFillBlob(output->second->getTensorDesc());
inf_req.SetBlob(output->first, blob);
}
auto refOutData = ngraph::helpers::interpreterFunction(fn_ptrs[i], {inData}).front().second;
ref.push_back(refOutData);
}