diff options
author | Michael Butler <butlermichael@google.com> | 2020-04-30 19:40:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-30 19:40:43 +0000 |
commit | 3e696c96956b04e7e40e26b70b8223aa78b7fdbc (patch) | |
tree | bf67604ca8698524794600143a4a0922d44dd5db /nn/runtime/test | |
parent | 7333f191e1725c4de4e05d6acaf4956a5f38122d (diff) | |
parent | 8f6469fb5225d8fb91255ea7e676544e6e699767 (diff) | |
download | ml-3e696c96956b04e7e40e26b70b8223aa78b7fdbc.tar.gz |
Merge "Fix NNAPI TimingTests" into rvc-dev
Diffstat (limited to 'nn/runtime/test')
-rw-r--r-- | nn/runtime/test/TestIntrospectionControl.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/nn/runtime/test/TestIntrospectionControl.cpp b/nn/runtime/test/TestIntrospectionControl.cpp index b33e06a69..913e6ed15 100644 --- a/nn/runtime/test/TestIntrospectionControl.cpp +++ b/nn/runtime/test/TestIntrospectionControl.cpp @@ -361,7 +361,7 @@ std::ostream& operator<<(std::ostream& os, Success success) { {Success::PASS_FENCED_DRIVER_BIT, "FENCED_DRIVER"}, }; bool gotOutput = false; - for (const auto b : bits) { + for (const auto& b : bits) { if (hasBit(success, b.first)) { if (gotOutput) { os << '|'; @@ -430,6 +430,7 @@ class TestPreparedModelLatest : public SamplePreparedModel { }).detach(); return V1_0::ErrorStatus::NONE; case Success::FAIL_LAUNCH: + dummyExecution(); callback->notify(V1_0::ErrorStatus::GENERAL_FAILURE); return V1_0::ErrorStatus::GENERAL_FAILURE; case Success::FAIL_WAIT: @@ -459,6 +460,7 @@ class TestPreparedModelLatest : public SamplePreparedModel { }).detach(); return V1_0::ErrorStatus::NONE; case Success::FAIL_LAUNCH: + dummyExecution(); callback->notify(V1_0::ErrorStatus::GENERAL_FAILURE); return V1_0::ErrorStatus::GENERAL_FAILURE; case Success::FAIL_WAIT: @@ -497,9 +499,9 @@ class TestPreparedModelLatest : public SamplePreparedModel { // runtime may call it even for asynchronous execution, so we // need to tolerate Success::FAIL_WAIT here, not just // Success::FAIL_LAUNCH. - dummyExecution(); FALLTHROUGH_INTENDED; case Success::FAIL_LAUNCH: + dummyExecution(); cb(V1_0::ErrorStatus::GENERAL_FAILURE, {}, kBadTiming); return Void(); default: @@ -540,6 +542,7 @@ class TestPreparedModelLatest : public SamplePreparedModel { const OptionalTimeoutDuration&, executeFenced_cb callback) override { EXPECT_EQ(measure, MeasureTiming::YES); if (hasBit(mSuccess, Success::PASS_BIT)) { + dummyExecution(); const auto expectedTiming = getExpectedTiming(mSuccess, true); sp<SampleFencedExecutionCallback> fencedExecutionCallback = new SampleFencedExecutionCallback(expectedTiming.first, expectedTiming.second, @@ -548,19 +551,16 @@ class TestPreparedModelLatest : public SamplePreparedModel { return Void(); } switch (mSuccess) { + case Success::FAIL_WAIT: + // Due to the limitation of the SampleDriver, + // FAIL_WAIT behaves the same as FAIL_LAUNCH. + // If the SampleDriver is updated to return real + // sync fences, this must be updated. + FALLTHROUGH_INTENDED; case Success::FAIL_LAUNCH: + dummyExecution(); callback(V1_3::ErrorStatus::GENERAL_FAILURE, hidl_handle(nullptr), nullptr); return Void(); - case Success::FAIL_WAIT: - std::thread([callback] { - dummyExecution(); - // Due to the limitation of the SampleDriver, - // FAIL_WAIT behaves the same as FAIL_LAUNCH. - // If the SampleDriver is updated to return real - // sync fences, this must be updated. - callback(V1_3::ErrorStatus::GENERAL_FAILURE, hidl_handle(nullptr), nullptr); - }).detach(); - return Void(); default: ADD_FAILURE() << "Unexpected Success kind"; return Void(); @@ -579,7 +579,7 @@ class TestPreparedModelLatest : public SamplePreparedModel { // - // thread B: pauseExecutions(false); static void waitForExecutionToBegin() { CHECK(mPauseExecutions.load()); - while (mExecutionsInFlight.load()) { + while (mExecutionsInFlight.load() == 0) { } } @@ -875,7 +875,7 @@ TEST_P(TimingTest, Test) { isPass ? ANEURALNETWORKS_NO_ERROR : ANEURALNETWORKS_BAD_STATE; const auto getDurationWhileRunning = [this] { - if (kDriverKind == DriverKind::CPU && kSuccess == Success::FAIL_LAUNCH) { + if (kDriverKind == DriverKind::CPU) { // Testing DriverKind::CPU would require modifying the CPU execution // path to control execution completion, similarly to how this test // case does with TestPreparedModel::dummyExecution(). This does not |