Create u-tests for RESULT_NOT_READY and INFER_NOT_STARTED (GNA QoS) (#3102)
* Create tests for RESULT_NOT_READY and INFER_NOT_STARTED (GNA QoS) * Suppress deprecated definition errors * Fix warning
This commit is contained in:
parent
302ded7bd6
commit
dc2ac0fb9e
@ -75,7 +75,7 @@ void GNADeviceHelper::propagateSync(const uint32_t requestConfigId, Gna2Accelera
|
||||
}
|
||||
|
||||
uint32_t GNADeviceHelper::propagate(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode) {
|
||||
uint32_t reqId;
|
||||
uint32_t reqId{};
|
||||
if (gna2AccelerationMode == Gna2AccelerationModeHardware &&
|
||||
detectedGnaDevVersion == Gna2DeviceVersionSoftwareEmulation) {
|
||||
gnawarn() << "GNA Device not detected, consider using other mode of acceleration";
|
||||
|
@ -8,12 +8,14 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "cpp_interfaces/impl/ie_infer_async_request_internal.hpp"
|
||||
#include "cpp_interfaces/impl/ie_infer_request_internal.hpp"
|
||||
#include "gna_plugin.hpp"
|
||||
|
||||
namespace GNAPluginNS {
|
||||
|
||||
class GNAInferRequest : public InferenceEngine::AsyncInferRequestInternal {
|
||||
protected:
|
||||
std::shared_ptr<GNAPlugin> plg;
|
||||
uint32_t inferRequestIdx = -1;
|
||||
|
||||
|
@ -129,6 +129,9 @@ GNA2_API enum Gna2Status Gna2RequestEnqueue(
|
||||
GNA2_API enum Gna2Status Gna2RequestWait(
|
||||
uint32_t requestId,
|
||||
uint32_t timeoutMilliseconds) {
|
||||
if (current != nullptr) {
|
||||
return current->Gna2RequestWait(requestId, timeoutMilliseconds);
|
||||
}
|
||||
return Gna2StatusSuccess;
|
||||
}
|
||||
|
||||
|
@ -80,5 +80,8 @@ public:
|
||||
uint32_t sizeRequested,
|
||||
uint32_t * sizeGranted,
|
||||
void ** memoryAddress));
|
||||
MOCK_METHOD2(Gna2RequestWait, Gna2Status(
|
||||
uint32_t requestId,
|
||||
uint32_t timeoutMilliseconds));
|
||||
#endif
|
||||
};
|
||||
|
69
inference-engine/tests/unit/gna/gna_wait_test.cpp
Normal file
69
inference-engine/tests/unit/gna/gna_wait_test.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#if GNA_LIB_VER == 2
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// to suppress deprecated definition errors
|
||||
#define IMPLEMENT_INFERENCE_ENGINE_PLUGIN
|
||||
#include "gna_infer_request.hpp"
|
||||
#include "gna_mock_api.hpp"
|
||||
|
||||
using GNAPluginNS::GNAPlugin;
|
||||
using GNAPluginNS::GNAInferRequest;
|
||||
using ::testing::Return;
|
||||
using ::testing::_;
|
||||
|
||||
class GNAWaitTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
class GNAPluginForGNAWaitTest : public GNAPlugin {
|
||||
public:
|
||||
// Prepare underlining object to enable GNAInferRequest::Wait() working
|
||||
GNAPluginForGNAWaitTest() {
|
||||
InferenceEngine::TensorDesc td{ InferenceEngine::Precision::FP32, {}, InferenceEngine::Layout::HW };
|
||||
auto fakeInfo = std::make_shared<InferenceEngine::InputInfo>();
|
||||
auto fakePtr = std::make_shared<InferenceEngine::Data>("fakeName", td);
|
||||
fakeInfo->setInputData(fakePtr);
|
||||
outputsDataMap["fakeOut"] = fakePtr;
|
||||
inputsDataMap["fakeIn"] = fakeInfo;
|
||||
gnaRequestConfigToRequestIdMap.push_back({ 0, 0, {} });
|
||||
InitGNADevice();
|
||||
}
|
||||
};
|
||||
|
||||
class GNAInferRequestForGNAWaitTest : public GNAInferRequest {
|
||||
public:
|
||||
// Prepare underlining object to enable Wait() working
|
||||
GNAInferRequestForGNAWaitTest(std::shared_ptr<GNAPlugin> plugin) : GNAInferRequest{
|
||||
plugin,
|
||||
plugin->GetInputs(),
|
||||
plugin->GetOutputs() } {
|
||||
inferRequestIdx = 0;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(GNAWaitTest, ReturnsGna2StatusDriverQoSTimeoutExceeded) {
|
||||
GNACppApi enableMocks;
|
||||
EXPECT_CALL(enableMocks, Gna2RequestWait(_, _)).
|
||||
Times(1).
|
||||
WillOnce(Return(Gna2StatusDriverQoSTimeoutExceeded));
|
||||
auto plugin = std::make_shared<GNAPluginForGNAWaitTest>();
|
||||
GNAInferRequestForGNAWaitTest inferRequest{ plugin };
|
||||
ASSERT_EQ(InferenceEngine::INFER_NOT_STARTED, inferRequest.Wait(0));
|
||||
}
|
||||
|
||||
TEST_F(GNAWaitTest, ReturnsGna2StatusWarningDeviceBusy) {
|
||||
GNACppApi enableMocks;
|
||||
EXPECT_CALL(enableMocks, Gna2RequestWait(_, _)).
|
||||
Times(1).
|
||||
WillOnce(Return(Gna2StatusWarningDeviceBusy));
|
||||
auto plugin = std::make_shared<GNAPluginForGNAWaitTest>();
|
||||
GNAInferRequestForGNAWaitTest inferRequest{ plugin };
|
||||
ASSERT_EQ(InferenceEngine::RESULT_NOT_READY, inferRequest.Wait(0));
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user