diff options
author | Miao Wang <miaowang@google.com> | 2020-02-06 13:01:34 -0800 |
---|---|---|
committer | Miao Wang <miaowang@google.com> | 2020-02-10 13:50:54 -0800 |
commit | 9f4f113b8ccecd8a46c16103156ec53f2a8012fb (patch) | |
tree | 8aa032975628da661d9ec6256ec41a9b334b20dd /nn/runtime/test/TestValidation.cpp | |
parent | 34141e48d2c134c96afc3f2bf184637ea6e93872 (diff) | |
download | ml-9f4f113b8ccecd8a46c16103156ec53f2a8012fb.tar.gz |
Fix ANNExecution_getDuration with new duration codes
- Also add validation tests
Bug: 148803008
Test: mm
Test: NeuralNetworksTest_static
Change-Id: I00df8202f8893a12ae77103ee6730bdf070efc3c
Diffstat (limited to 'nn/runtime/test/TestValidation.cpp')
-rw-r--r-- | nn/runtime/test/TestValidation.cpp | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/nn/runtime/test/TestValidation.cpp b/nn/runtime/test/TestValidation.cpp index b4204becf..446f0eba8 100644 --- a/nn/runtime/test/TestValidation.cpp +++ b/nn/runtime/test/TestValidation.cpp @@ -2302,8 +2302,9 @@ TEST_F(ValidationTestCompilationForDevices_1, ExecutionTiming) { const bool executionTimeout = ANeuralNetworksDevice_supportsExecutionTimeout(mDevice); - enum class ExecutionType : uint32_t { ASYNC, SYNC, BURST }; - for (auto executionType : {ExecutionType::ASYNC, ExecutionType::SYNC, ExecutionType::BURST}) { + enum class ExecutionType : uint32_t { ASYNC, SYNC, BURST, FENCED }; + for (auto executionType : + {ExecutionType::ASYNC, ExecutionType::SYNC, ExecutionType::BURST, ExecutionType::FENCED}) { SCOPED_TRACE(static_cast<uint32_t>(executionType)); ANeuralNetworksExecution* execution; @@ -2385,6 +2386,18 @@ TEST_F(ValidationTestCompilationForDevices_1, ExecutionTiming) { ANeuralNetworksBurst_free(burst); break; } + case ExecutionType::FENCED: { + ANeuralNetworksEvent* event = nullptr; + ASSERT_EQ(ANeuralNetworksExecution_startComputeWithDependencies(execution, nullptr, + 0, 0, &event), + ANEURALNETWORKS_NO_ERROR); + testMeasureTooLate(); + ASSERT_EQ(ANeuralNetworksEvent_wait(event), ANEURALNETWORKS_NO_ERROR); + testSetTimeoutTooLate(); + testMeasureTooLate(); + ANeuralNetworksEvent_free(event); + break; + } default: FAIL() << "Unreachable"; } @@ -2406,7 +2419,8 @@ TEST_F(ValidationTestCompilationForDevices_1, ExecutionTiming) { int expectedResultCode = ANEURALNETWORKS_NO_ERROR; if (e == nullptr | durationPtr == nullptr) { expectedResultCode = ANEURALNETWORKS_UNEXPECTED_NULL; - } else if (durationCode < 0) { + } else if (durationCode < 0 || + durationCode > ANEURALNETWORKS_FENCED_DURATION_IN_DRIVER) { expectedResultCode = ANEURALNETWORKS_BAD_DATA; } @@ -2418,8 +2432,12 @@ TEST_F(ValidationTestCompilationForDevices_1, ExecutionTiming) { }; std::vector<ANeuralNetworksExecution*> executions = {nullptr, execution}; - std::vector<int32_t> durationCodes = {-1, ANEURALNETWORKS_DURATION_ON_HARDWARE, - ANEURALNETWORKS_DURATION_IN_DRIVER}; + std::vector<int32_t> durationCodes = {-1, + ANEURALNETWORKS_DURATION_ON_HARDWARE, + ANEURALNETWORKS_DURATION_IN_DRIVER, + ANEURALNETWORKS_FENCED_DURATION_ON_HARDWARE, + ANEURALNETWORKS_FENCED_DURATION_IN_DRIVER, + ANEURALNETWORKS_FENCED_DURATION_IN_DRIVER + 1}; std::vector<bool> nullDurations = {false, true}; for (auto e : executions) { for (auto d : durationCodes) { @@ -2453,8 +2471,9 @@ void runExecutionSetTimeoutTest(const ANeuralNetworksDevice* device, const bool executionTimeout = ANeuralNetworksDevice_supportsExecutionTimeout(device); - enum class ExecutionType : uint32_t { ASYNC, SYNC, BURST }; - for (auto executionType : {ExecutionType::ASYNC, ExecutionType::SYNC, ExecutionType::BURST}) { + enum class ExecutionType : uint32_t { ASYNC, SYNC, BURST, FENCED }; + for (auto executionType : + {ExecutionType::ASYNC, ExecutionType::SYNC, ExecutionType::BURST, ExecutionType::FENCED}) { SCOPED_TRACE(static_cast<uint32_t>(executionType)); ANeuralNetworksExecution* execution; @@ -2520,6 +2539,15 @@ void runExecutionSetTimeoutTest(const ANeuralNetworksDevice* device, ANeuralNetworksBurst_free(burst); break; } + case ExecutionType::FENCED: { + ANeuralNetworksEvent* event = nullptr; + ASSERT_EQ(ANeuralNetworksExecution_startComputeWithDependencies(execution, nullptr, + 0, 0, &event), + ANEURALNETWORKS_NO_ERROR); + checkResult(ANeuralNetworksEvent_wait(event)); + ANeuralNetworksEvent_free(event); + break; + } default: FAIL() << "Unreachable"; } |