summaryrefslogtreecommitdiff
path: root/nn/runtime/test
diff options
context:
space:
mode:
authorXusong Wang <xusongw@google.com>2020-05-06 13:49:19 -0700
committerXusong Wang <xusongw@google.com>2020-05-11 15:50:49 -0700
commitca8c1cba4c7ba6612e0471be620c899e27032f77 (patch)
tree8fec1f2466c03331e5916a7d24a2f10fe2c58aed /nn/runtime/test
parent55bee1c40e56f690de39bae8e47a4b6f9743086c (diff)
downloadml-ca8c1cba4c7ba6612e0471be620c899e27032f77.tar.gz
Avoid sending ahwb requests to 1.0 and 1.1 drivers.
AHWB buffer support is a feature introduced in 1.2. Prior to this CL, requests with AHWB as memory pool will be sent to 1.0 and 1.1 drivers. This CL modifies the compliance check and avoids sending ahwb to 1.0 and 1.1 drivers. Using AHWBs on compilations with 1.0 and 1.1 drivers will result in a CPU fallback. Bug: 155686276 Test: NNTS Change-Id: Ib00a2d0d24d4a8c385b5992a1168e20c4a6bb786
Diffstat (limited to 'nn/runtime/test')
-rw-r--r--nn/runtime/test/TestCompliance.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/nn/runtime/test/TestCompliance.cpp b/nn/runtime/test/TestCompliance.cpp
index 53bff038b..db5ab4d3e 100644
--- a/nn/runtime/test/TestCompliance.cpp
+++ b/nn/runtime/test/TestCompliance.cpp
@@ -18,6 +18,7 @@
#include "GeneratedTestUtils.h"
#include "HalInterfaces.h"
+#include "Memory.h"
#include "MemoryUtils.h"
#include "ModelBuilder.h"
#include "TestNeuralNetworksWrapper.h"
@@ -71,8 +72,14 @@ static void testAvailableSinceV1_0(const WrapperModel& wrapperModel) {
ASSERT_TRUE(compliantWithV1_0(hidlModel));
}
+static void testAvailableSinceV1_2(const Request& request) {
+ ASSERT_FALSE(compliantWithV1_0(request));
+ ASSERT_TRUE(compliantWithV1_2(request));
+}
+
static void testAvailableSinceV1_3(const Request& request) {
ASSERT_FALSE(compliantWithV1_0(request));
+ ASSERT_FALSE(compliantWithV1_2(request));
}
static const WrapperOperandType kTypeTensorFloat(WrapperType::TENSOR_FLOAT32, {1});
@@ -126,7 +133,7 @@ TEST_F(ComplianceTest, Rank0TensorTemporaryVariable) {
testAvailableSinceV1_2(model);
}
-TEST_F(ComplianceTest, HardwareBuffer) {
+TEST_F(ComplianceTest, HardwareBufferModel) {
const size_t memorySize = 20;
AHardwareBuffer_Desc desc{
.width = memorySize,
@@ -157,6 +164,29 @@ TEST_F(ComplianceTest, HardwareBuffer) {
AHardwareBuffer_release(buffer);
}
+TEST_F(ComplianceTest, HardwareBufferRequest) {
+ const auto [n, ahwb] = MemoryRuntimeAHWB::create(1024);
+ ASSERT_EQ(n, ANEURALNETWORKS_NO_ERROR);
+ Request::MemoryPool sharedMemoryPool, ahwbMemoryPool = ahwb->getMemoryPool();
+ sharedMemoryPool.hidlMemory(allocateSharedMemory(1024));
+ ASSERT_TRUE(sharedMemoryPool.hidlMemory().valid());
+ ASSERT_TRUE(ahwbMemoryPool.hidlMemory().valid());
+
+ // AHardwareBuffer as input.
+ testAvailableSinceV1_2(Request{
+ .inputs = {{.hasNoValue = false, .location = {.poolIndex = 0}, .dimensions = {}}},
+ .outputs = {{.hasNoValue = false, .location = {.poolIndex = 1}, .dimensions = {}}},
+ .pools = {ahwbMemoryPool, sharedMemoryPool},
+ });
+
+ // AHardwareBuffer as output.
+ testAvailableSinceV1_2(Request{
+ .inputs = {{.hasNoValue = false, .location = {.poolIndex = 0}, .dimensions = {}}},
+ .outputs = {{.hasNoValue = false, .location = {.poolIndex = 1}, .dimensions = {}}},
+ .pools = {sharedMemoryPool, ahwbMemoryPool},
+ });
+}
+
TEST_F(ComplianceTest, DeviceMemory) {
Request::MemoryPool sharedMemoryPool, deviceMemoryPool;
sharedMemoryPool.hidlMemory(allocateSharedMemory(1024));