summaryrefslogtreecommitdiff
path: root/nn/runtime/test/TestValidation.cpp
diff options
context:
space:
mode:
authorMichael Butler <butlermichael@google.com>2019-01-29 11:20:30 -0800
committerMichael Butler <butlermichael@google.com>2019-03-26 17:51:17 -0700
commit3db6fe510dcc3c6076e3894814f954f7b8e2008e (patch)
tree1904aa19ad7acaeec836cb9265016cbd8757b9e0 /nn/runtime/test/TestValidation.cpp
parent8da5809b5e8332e48d3cfdd3ba2ff508ea509862 (diff)
downloadml-3db6fe510dcc3c6076e3894814f954f7b8e2008e.tar.gz
NNAPI Burst object cleanup
This CL addresses some follow up comments from ag/6154003 and ag/6575732. Bug: 119570067 Test: mma Test: atest NeuralNetworksTest_static Change-Id: I1a2bd4c9d97296f50d6ef9bb86515ea8e9a54515
Diffstat (limited to 'nn/runtime/test/TestValidation.cpp')
-rw-r--r--nn/runtime/test/TestValidation.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/nn/runtime/test/TestValidation.cpp b/nn/runtime/test/TestValidation.cpp
index 4e95fa520..c3a6f0fe3 100644
--- a/nn/runtime/test/TestValidation.cpp
+++ b/nn/runtime/test/TestValidation.cpp
@@ -1111,6 +1111,15 @@ TEST_F(ValidationTestBurst, BurstComputeNull) {
ANEURALNETWORKS_UNEXPECTED_NULL);
}
+TEST_F(ValidationTestBurst, BurstComputeBadCompilation) {
+ ANeuralNetworksCompilation* compilation;
+ ASSERT_EQ(ANeuralNetworksCompilation_create(mModel, &compilation), ANEURALNETWORKS_NO_ERROR);
+ // NOTE: ANeuralNetworksCompilation_finish not called
+
+ ANeuralNetworksBurst* burst;
+ EXPECT_EQ(ANeuralNetworksBurst_create(compilation, &burst), ANEURALNETWORKS_BAD_STATE);
+}
+
TEST_F(ValidationTestBurst, BurstComputeDifferentCompilations) {
ANeuralNetworksCompilation* secondCompilation;
ASSERT_EQ(ANeuralNetworksCompilation_create(mModel, &secondCompilation),
@@ -1160,15 +1169,20 @@ TEST_F(ValidationTestBurst, BurstComputeConcurrent) {
sizeof(outputB0)),
ANEURALNETWORKS_NO_ERROR);
- // execute on the same burst concurrently
+ // Execute on the same burst concurrently. At least one result must be
+ // ANEURALNETWORKS_NO_ERROR. One may return ANEURALNETWORKS_BAD_STATE if the
+ // other is already executing on the burst.
auto first = std::async(std::launch::async, [this] {
- const int result = ANeuralNetworksExecution_burstCompute(mExecution, mBurst);
- EXPECT_TRUE(result == ANEURALNETWORKS_BAD_STATE || result == ANEURALNETWORKS_NO_ERROR);
+ return ANeuralNetworksExecution_burstCompute(mExecution, mBurst);
});
auto second = std::async(std::launch::async, [this, secondExecution] {
- const int result = ANeuralNetworksExecution_burstCompute(secondExecution, mBurst);
- EXPECT_TRUE(result == ANEURALNETWORKS_BAD_STATE || result == ANEURALNETWORKS_NO_ERROR);
+ return ANeuralNetworksExecution_burstCompute(secondExecution, mBurst);
});
+ const int result1 = first.get();
+ const int result2 = second.get();
+ EXPECT_TRUE(result1 == ANEURALNETWORKS_BAD_STATE || result1 == ANEURALNETWORKS_NO_ERROR);
+ EXPECT_TRUE(result2 == ANEURALNETWORKS_BAD_STATE || result2 == ANEURALNETWORKS_NO_ERROR);
+ EXPECT_TRUE(result1 == ANEURALNETWORKS_NO_ERROR || result2 == ANEURALNETWORKS_NO_ERROR);
}
TEST(ValidationTestIntrospection, GetNumDevices) {