summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2020-10-07 16:42:26 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-10-07 16:42:26 +0000
commit0539b0cfec15380c23c257d5655f96d15f8e6487 (patch)
tree8aa8a78848fe9516bc38752943e752db6c3f32cb
parente238d86505854623f9a39bf480b1aa5c78151f61 (diff)
parent99a085ed1762073a333f23bf4327ea98abf04cd8 (diff)
downloadml-0539b0cfec15380c23c257d5655f96d15f8e6487.tar.gz
Merge "ml: add define guards for hardware buffer tests"
-rw-r--r--nn/runtime/test/TestCompliance.cpp4
-rw-r--r--nn/runtime/test/TestMemory.cpp5
-rw-r--r--nn/runtime/test/TestMemoryDomain.cpp13
-rw-r--r--nn/runtime/test/TestTrivialModel.cpp4
4 files changed, 23 insertions, 3 deletions
diff --git a/nn/runtime/test/TestCompliance.cpp b/nn/runtime/test/TestCompliance.cpp
index 39ae017fc..d756c2414 100644
--- a/nn/runtime/test/TestCompliance.cpp
+++ b/nn/runtime/test/TestCompliance.cpp
@@ -134,6 +134,9 @@ TEST_F(ComplianceTest, Rank0TensorTemporaryVariable) {
testAvailableSinceV1_2(model);
}
+// Hardware buffers are an Android concept, which aren't necessarily
+// available on other platforms such as ChromeOS, which also build NNAPI.
+#if defined(__ANDROID__)
TEST_F(ComplianceTest, HardwareBufferModel) {
const size_t memorySize = 20;
AHardwareBuffer_Desc desc{
@@ -188,6 +191,7 @@ TEST_F(ComplianceTest, HardwareBufferRequest) {
.pools = {sharedMemoryPool, ahwbMemoryPool},
});
}
+#endif
TEST_F(ComplianceTest, DeviceMemory) {
Request::MemoryPool sharedMemoryPool, deviceMemoryPool;
diff --git a/nn/runtime/test/TestMemory.cpp b/nn/runtime/test/TestMemory.cpp
index b0e147882..11b144273 100644
--- a/nn/runtime/test/TestMemory.cpp
+++ b/nn/runtime/test/TestMemory.cpp
@@ -91,6 +91,9 @@ TEST_F(MemoryTest, TestFd) {
unlink(path);
}
+// Hardware buffers are an Android concept, which aren't necessarily
+// available on other platforms such as ChromeOS, which also build NNAPI.
+#if defined(__ANDROID__)
TEST_F(MemoryTest, TestAHardwareBuffer) {
const uint32_t offsetForMatrix2 = 20;
const uint32_t offsetForMatrix3 = 200;
@@ -147,4 +150,6 @@ TEST_F(MemoryTest, TestAHardwareBuffer) {
ASSERT_EQ(execution2.compute(), WrapperResult::NO_ERROR);
ASSERT_EQ(CompareMatrices(expected3, actual), 0);
}
+#endif
+
} // end namespace
diff --git a/nn/runtime/test/TestMemoryDomain.cpp b/nn/runtime/test/TestMemoryDomain.cpp
index c2cf8e852..06418e5af 100644
--- a/nn/runtime/test/TestMemoryDomain.cpp
+++ b/nn/runtime/test/TestMemoryDomain.cpp
@@ -419,13 +419,19 @@ static const auto kAllocateReturnChoices =
testing::Values(AllocateReturn::OK, AllocateReturn::BAD_TOKEN, AllocateReturn::BAD_IBUFFER,
AllocateReturn::BAD_STATUS, AllocateReturn::NOT_SUPPORTED);
-INSTANTIATE_TEST_SUITE_P(DeviceVersionLatest, MemoryDomainTest,
- testing::Combine(testing::Values(false), testing::Bool(),
- kAllocateReturnChoices));
INSTANTIATE_TEST_SUITE_P(DeviceVersionV1_2, MemoryDomainTest,
testing::Combine(testing::Values(true), testing::Bool(),
testing::Values(AllocateReturn::NOT_SUPPORTED)));
+// Hardware buffers are an Android concept, which aren't necessarily
+// available on other platforms such as ChromeOS, which also build NNAPI.
+// When using the latest driver, memory is allocated via hardware buffers,
+// which will fail on non-android platforms.
+#if defined(__ANDROID__)
+INSTANTIATE_TEST_SUITE_P(DeviceVersionLatest, MemoryDomainTest,
+ testing::Combine(testing::Values(false), testing::Bool(),
+ kAllocateReturnChoices));
+
class MemoryDomainCopyTest : public MemoryDomainTestBase {};
TEST_F(MemoryDomainCopyTest, MemoryCopyTest) {
@@ -457,5 +463,6 @@ TEST_F(MemoryDomainCopyTest, MemoryCopyTest) {
EXPECT_EQ(ashmem2->dataAs<float>()[0], initValue1);
}
+#endif
} // namespace
diff --git a/nn/runtime/test/TestTrivialModel.cpp b/nn/runtime/test/TestTrivialModel.cpp
index 0ccbc57ba..9f7a6281a 100644
--- a/nn/runtime/test/TestTrivialModel.cpp
+++ b/nn/runtime/test/TestTrivialModel.cpp
@@ -122,6 +122,9 @@ TEST_F(TrivialTest, AddTwo) {
ASSERT_EQ(CompareMatrices(expected2, actual), 0);
}
+// Hardware buffers are an Android concept, which aren't necessarily
+// available on other platforms such as ChromeOS, which also build NNAPI.
+#if defined(__ANDROID__)
TEST_F(TrivialTest, AddTwoWithHardwareBufferInput) {
Model modelAdd2;
CreateAddTwoTensorModel(&modelAdd2);
@@ -179,6 +182,7 @@ TEST_F(TrivialTest, AddTwoWithHardwareBufferInput) {
ASSERT_EQ(CompareMatrices(expected2, actual), 0);
}
+#endif
TEST_F(TrivialTest, AddThree) {
Model modelAdd3;