aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Monahan <david.monahan@arm.com>2020-05-19 14:58:34 +0100
committerJan Eilers <jan.eilers@arm.com>2020-05-20 11:43:32 +0100
commitd275cb2fcb3b41928348a408f7eace4ff516ca8b (patch)
tree5a825089eb6c24cebb49b502e6c0404d7b79bd56
parent813f23049d73177edfc1f1cff71147c39f4b695e (diff)
downloadandroid-nn-driver-d275cb2fcb3b41928348a408f7eace4ff516ca8b.tar.gz
IVGCVSW-IVGCVSW-4772 Fixes for android-nn-driver unit tests on Android R
* Added missing operand parameter numberOfConsumers to DriverTestHelpers * Added nullptr checks to unit tests * Disabling QuantizedLstmTest when ARMCOMPUTECL_ENABLED is undefined Signed-off-by: David Monahan <david.monahan@arm.com> Change-Id: I46dc413d3bb1805eb0e7c982177b6d60d0b297f5
-rw-r--r--test/1.2/Lstm.cpp2
-rw-r--r--test/Concat.cpp1
-rw-r--r--test/Concurrent.cpp1
-rw-r--r--test/DriverTestHelpers.hpp88
-rw-r--r--test/GenericLayerTests.cpp28
5 files changed, 79 insertions, 41 deletions
diff --git a/test/1.2/Lstm.cpp b/test/1.2/Lstm.cpp
index 032b537..03f7fe4 100644
--- a/test/1.2/Lstm.cpp
+++ b/test/1.2/Lstm.cpp
@@ -41,9 +41,11 @@ BOOST_DATA_TEST_CASE(LstmCifgPeepholeProjectionNoClippingLayerNormTest, COMPUTE_
LstmCifgPeepholeProjectionNoClippingLayerNorm<hal_1_2::HalPolicy>(sample);
}
+#if defined(ARMCOMPUTECL_ENABLED)
BOOST_DATA_TEST_CASE(QuantizedLstmTest, COMPUTE_DEVICES)
{
QuantizedLstm<hal_1_2::HalPolicy>(sample);
}
+#endif
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/Concat.cpp b/test/Concat.cpp
index b99e31c..b4b650f 100644
--- a/test/Concat.cpp
+++ b/test/Concat.cpp
@@ -128,6 +128,7 @@ ConcatTestImpl(const std::vector<const TestTensor*> & inputs,
float* outdata = static_cast<float*>(static_cast<void*>(outMemory->getPointer()));
// run the execution
+ ARMNN_ASSERT(preparedModel.get() != nullptr);
auto execStatus = Execute(preparedModel, request, expectedExecStatus);
BOOST_TEST(execStatus == expectedExecStatus);
diff --git a/test/Concurrent.cpp b/test/Concurrent.cpp
index 0694934..aeea17f 100644
--- a/test/Concurrent.cpp
+++ b/test/Concurrent.cpp
@@ -110,6 +110,7 @@ BOOST_AUTO_TEST_CASE(ConcurrentExecute)
ALOGI("ConcurrentExecute: waiting for callbacks");
for (size_t i = 0; i < maxRequests; ++i)
{
+ ARMNN_ASSERT(cb[i]);
cb[i]->wait();
}
diff --git a/test/DriverTestHelpers.hpp b/test/DriverTestHelpers.hpp
index 7a35b23..66d6ac5 100644
--- a/test/DriverTestHelpers.hpp
+++ b/test/DriverTestHelpers.hpp
@@ -142,7 +142,7 @@ void AddOperand(HalModel& model, const HalOperand& op)
}
template<typename HalPolicy, typename HalModel = typename HalPolicy::Model>
-void AddIntOperand(HalModel& model, int32_t value)
+void AddIntOperand(HalModel& model, int32_t value, uint32_t numberOfConsumers = 1)
{
using HalOperand = typename HalPolicy::Operand;
using HalOperandType = typename HalPolicy::OperandType;
@@ -152,11 +152,12 @@ void AddIntOperand(HalModel& model, int32_t value)
location.offset = model.operandValues.size();
location.length = sizeof(int32_t);
- HalOperand op = {};
- op.type = HalOperandType::INT32;
- op.dimensions = hidl_vec<uint32_t>{};
- op.lifetime = HalOperandLifeTime::CONSTANT_COPY;
- op.location = location;
+ HalOperand op = {};
+ op.type = HalOperandType::INT32;
+ op.dimensions = hidl_vec<uint32_t>{};
+ op.lifetime = HalOperandLifeTime::CONSTANT_COPY;
+ op.location = location;
+ op.numberOfConsumers = numberOfConsumers;
model.operandValues.resize(model.operandValues.size() + location.length);
*reinterpret_cast<int32_t*>(&model.operandValues[location.offset]) = value;
@@ -165,7 +166,7 @@ void AddIntOperand(HalModel& model, int32_t value)
}
template<typename HalPolicy, typename HalModel = typename HalPolicy::Model>
-void AddBoolOperand(HalModel& model, bool value)
+void AddBoolOperand(HalModel& model, bool value, uint32_t numberOfConsumers = 1)
{
using HalOperand = typename HalPolicy::Operand;
using HalOperandType = typename HalPolicy::OperandType;
@@ -175,11 +176,12 @@ void AddBoolOperand(HalModel& model, bool value)
location.offset = model.operandValues.size();
location.length = sizeof(uint8_t);
- HalOperand op = {};
- op.type = HalOperandType::BOOL;
- op.dimensions = hidl_vec<uint32_t>{};
- op.lifetime = HalOperandLifeTime::CONSTANT_COPY;
- op.location = location;
+ HalOperand op = {};
+ op.type = HalOperandType::BOOL;
+ op.dimensions = hidl_vec<uint32_t>{};
+ op.lifetime = HalOperandLifeTime::CONSTANT_COPY;
+ op.location = location;
+ op.numberOfConsumers = numberOfConsumers;
model.operandValues.resize(model.operandValues.size() + location.length);
*reinterpret_cast<uint8_t*>(&model.operandValues[location.offset]) = static_cast<uint8_t>(value);
@@ -207,7 +209,8 @@ void AddTensorOperand(HalModel& model,
HalOperandType operandType = HalOperandType::TENSOR_FLOAT32,
HalOperandLifeTime operandLifeTime = V1_0::OperandLifeTime::CONSTANT_COPY,
double scale = 0.f,
- int offset = 0)
+ int offset = 0,
+ uint32_t numberOfConsumers = 1)
{
using HalOperand = typename HalPolicy::Operand;
@@ -225,13 +228,14 @@ void AddTensorOperand(HalModel& model,
location.offset = model.operandValues.size();
}
- HalOperand op = {};
- op.type = operandType;
- op.dimensions = dimensions;
- op.scale = scale;
- op.zeroPoint = offset;
- op.lifetime = HalOperandLifeTime::CONSTANT_COPY;
- op.location = location;
+ HalOperand op = {};
+ op.type = operandType;
+ op.dimensions = dimensions;
+ op.scale = scale;
+ op.zeroPoint = offset;
+ op.lifetime = HalOperandLifeTime::CONSTANT_COPY;
+ op.location = location;
+ op.numberOfConsumers = numberOfConsumers;
model.operandValues.resize(model.operandValues.size() + location.length);
for (uint32_t i = 0; i < totalElements; i++)
@@ -253,9 +257,17 @@ void AddTensorOperand(HalModel& model,
HalOperandType operandType = HalPolicy::OperandType::TENSOR_FLOAT32,
HalOperandLifeTime operandLifeTime = V1_0::OperandLifeTime::CONSTANT_COPY,
double scale = 0.f,
- int offset = 0)
+ int offset = 0,
+ uint32_t numberOfConsumers = 1)
{
- AddTensorOperand<HalPolicy, T>(model, dimensions, values.data(), operandType, operandLifeTime, scale, offset);
+ AddTensorOperand<HalPolicy, T>(model,
+ dimensions,
+ values.data(),
+ operandType,
+ operandLifeTime,
+ scale,
+ offset,
+ numberOfConsumers);
}
template<typename HalPolicy,
@@ -265,17 +277,19 @@ void AddInputOperand(HalModel& model,
const hidl_vec<uint32_t>& dimensions,
HalOperandType operandType = HalOperandType::TENSOR_FLOAT32,
double scale = 0.f,
- int offset = 0)
+ int offset = 0,
+ uint32_t numberOfConsumers = 1)
{
using HalOperand = typename HalPolicy::Operand;
using HalOperandLifeTime = typename HalPolicy::OperandLifeTime;
- HalOperand op = {};
- op.type = operandType;
- op.scale = scale;
- op.zeroPoint = offset;
- op.dimensions = dimensions;
- op.lifetime = HalOperandLifeTime::MODEL_INPUT;
+ HalOperand op = {};
+ op.type = operandType;
+ op.scale = scale;
+ op.zeroPoint = offset;
+ op.dimensions = dimensions;
+ op.lifetime = HalOperandLifeTime::MODEL_INPUT;
+ op.numberOfConsumers = numberOfConsumers;
AddOperand<HalPolicy>(model, op);
@@ -290,17 +304,19 @@ void AddOutputOperand(HalModel& model,
const hidl_vec<uint32_t>& dimensions,
HalOperandType operandType = HalOperandType::TENSOR_FLOAT32,
double scale = 0.f,
- int offset = 0)
+ int offset = 0,
+ uint32_t numberOfConsumers = 0)
{
using HalOperand = typename HalPolicy::Operand;
using HalOperandLifeTime = typename HalPolicy::OperandLifeTime;
- HalOperand op = {};
- op.type = operandType;
- op.scale = scale;
- op.zeroPoint = offset;
- op.dimensions = dimensions;
- op.lifetime = HalOperandLifeTime::MODEL_OUTPUT;
+ HalOperand op = {};
+ op.type = operandType;
+ op.scale = scale;
+ op.zeroPoint = offset;
+ op.dimensions = dimensions;
+ op.lifetime = HalOperandLifeTime::MODEL_OUTPUT;
+ op.numberOfConsumers = numberOfConsumers;
AddOperand<HalPolicy>(model, op);
diff --git a/test/GenericLayerTests.cpp b/test/GenericLayerTests.cpp
index 961ab16..188c7b1 100644
--- a/test/GenericLayerTests.cpp
+++ b/test/GenericLayerTests.cpp
@@ -87,9 +87,19 @@ BOOST_AUTO_TEST_CASE(GetSupportedOperations)
// Test Broadcast on add/mul operators
HalPolicy::Model model2 = {};
- AddInputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4});
- AddInputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{4});
- AddIntOperand<HalPolicy>(model2, actValue);
+ AddInputOperand<HalPolicy>(model2,
+ hidl_vec<uint32_t>{1, 1, 3, 4},
+ HalPolicy::OperandType::TENSOR_FLOAT32,
+ 0.0f,
+ 0,
+ 2);
+ AddInputOperand<HalPolicy>(model2,
+ hidl_vec<uint32_t>{4},
+ HalPolicy::OperandType::TENSOR_FLOAT32,
+ 0.0f,
+ 0,
+ 2);
+ AddIntOperand<HalPolicy>(model2, actValue, 2);
AddOutputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4});
AddOutputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4});
@@ -181,8 +191,16 @@ BOOST_AUTO_TEST_CASE(UnsupportedLayerContinueOnFailure)
HalPolicy::OperandType::TENSOR_INT32);
AddInputOperand<HalPolicy>(model,
hidl_vec<uint32_t>{4},
- HalPolicy::OperandType::TENSOR_INT32);
- AddInputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4});
+ HalPolicy::OperandType::TENSOR_INT32,
+ 0.0f,
+ 0,
+ 2);
+ AddInputOperand<HalPolicy>(model,
+ hidl_vec<uint32_t>{1, 1, 3, 4},
+ HalPolicy::OperandType::TENSOR_FLOAT32,
+ 0.0f,
+ 0,
+ 2);
AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4});
AddOutputOperand<HalPolicy>(model,