aboutsummaryrefslogtreecommitdiff
path: root/test/DriverTestHelpers.cpp
diff options
context:
space:
mode:
authortelsoa01 <telmo.soares@arm.com>2018-08-31 09:31:35 +0100
committertelsoa01 <telmo.soares@arm.com>2018-08-31 09:31:35 +0100
commitce3e84a8d449cbf31cee57e30f0eef6a96c0ce94 (patch)
tree77a769e27879fb712027c990071b061c5e0e3b60 /test/DriverTestHelpers.cpp
parentdeb3bdbe028a59da0759dd7a560387d03a11d322 (diff)
downloadandroid-nn-driver-ce3e84a8d449cbf31cee57e30f0eef6a96c0ce94.tar.gz
Release 18.08
Diffstat (limited to 'test/DriverTestHelpers.cpp')
-rw-r--r--test/DriverTestHelpers.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/test/DriverTestHelpers.cpp b/test/DriverTestHelpers.cpp
index d2d380a7..82087961 100644
--- a/test/DriverTestHelpers.cpp
+++ b/test/DriverTestHelpers.cpp
@@ -25,10 +25,12 @@ std::ostream& operator<<(std::ostream& os, ErrorStatus stat)
} // namespace android::hardware
} // namespace android
-
namespace driverTestHelpers
{
+using namespace android::hardware;
+using namespace armnn_driver;
+
Return<void> ExecutionCallback::notify(ErrorStatus status)
{
(void)status;
@@ -107,13 +109,13 @@ void AddPoolAndSetData(uint32_t size, Request& request, const float* data)
memcpy(dst, data, size * sizeof(float));
}
-void AddOperand(V1_0::Model& model, const Operand& op)
+void AddOperand(neuralnetworks::V1_0::Model& model, const Operand& op)
{
model.operands.resize(model.operands.size() + 1);
model.operands[model.operands.size() - 1] = op;
}
-void AddIntOperand(V1_0::Model& model, int32_t value)
+void AddIntOperand(neuralnetworks::V1_0::Model& model, int32_t value)
{
DataLocation location = {};
location.offset = model.operandValues.size();
@@ -131,10 +133,12 @@ void AddIntOperand(V1_0::Model& model, int32_t value)
AddOperand(model, op);
}
-void AddInputOperand(V1_0::Model& model, hidl_vec<uint32_t> dimensions)
+void AddInputOperand(neuralnetworks::V1_0::Model& model,
+ hidl_vec<uint32_t> dimensions,
+ neuralnetworks::V1_0::OperandType operandType)
{
Operand op = {};
- op.type = OperandType::TENSOR_FLOAT32;
+ op.type = operandType;
op.dimensions = dimensions;
op.lifetime = OperandLifeTime::MODEL_INPUT;
@@ -144,10 +148,13 @@ void AddInputOperand(V1_0::Model& model, hidl_vec<uint32_t> dimensions)
model.inputIndexes[model.inputIndexes.size() - 1] = model.operands.size() - 1;
}
-void AddOutputOperand(V1_0::Model& model, hidl_vec<uint32_t> dimensions)
+void AddOutputOperand(neuralnetworks::V1_0::Model& model,
+ hidl_vec<uint32_t> dimensions,
+ neuralnetworks::V1_0::OperandType operandType)
{
Operand op = {};
- op.type = OperandType::TENSOR_FLOAT32;
+ op.type = operandType;
+ op.scale = operandType == neuralnetworks::V1_0::OperandType::TENSOR_QUANT8_ASYMM ? 1.f / 255.f : 0.f;
op.dimensions = dimensions;
op.lifetime = OperandLifeTime::MODEL_OUTPUT;
@@ -158,7 +165,7 @@ void AddOutputOperand(V1_0::Model& model, hidl_vec<uint32_t> dimensions)
}
-android::sp<IPreparedModel> PrepareModelWithStatus(const V1_0::Model& model,
+android::sp<IPreparedModel> PrepareModelWithStatus(const neuralnetworks::V1_0::Model& model,
armnn_driver::ArmnnDriver& driver,
ErrorStatus & prepareStatus,
ErrorStatus expectedStatus)
@@ -176,7 +183,7 @@ android::sp<IPreparedModel> PrepareModelWithStatus(const V1_0::Model& model,
return cb->GetPreparedModel();
}
-android::sp<IPreparedModel> PrepareModel(const V1_0::Model& model,
+android::sp<IPreparedModel> PrepareModel(const neuralnetworks::V1_0::Model& model,
armnn_driver::ArmnnDriver& driver)
{
ErrorStatus prepareStatus = ErrorStatus::NONE;
@@ -187,6 +194,7 @@ ErrorStatus Execute(android::sp<IPreparedModel> preparedModel,
const Request& request,
ErrorStatus expectedStatus)
{
+ BOOST_TEST(preparedModel.get() != nullptr);
android::sp<ExecutionCallback> cb(new ExecutionCallback());
ErrorStatus execStatus = preparedModel->execute(request, cb);
BOOST_TEST(execStatus == expectedStatus);