Test dynamic output shape in GeneratedTests.

Enable VTS unit test for dynamic output shape deduction.

Only test dynamic output shape for V1_2::IDevice with V1_2::Model.

Bug: 73506513
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: I4134e1ec54a15554eb8533134897279651b57da3
Merged-In: I4134e1ec54a15554eb8533134897279651b57da3
(cherry picked from commit a316581b21)
This commit is contained in:
Xusong Wang
2018-11-19 18:26:08 -08:00
committed by Miao Wang
parent 55a3d328b7
commit d22c5232f3
6 changed files with 24 additions and 4 deletions

View File

@@ -20,7 +20,11 @@ cc_test {
defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
srcs: [
"GeneratedTestsV1_0.cpp",
]
],
cflags: [
"-DNN_TEST_DYNAMIC_OUTPUT_SHAPE"
],
test_suites: ["general-tests"],
}
// Tests for V1_1 models using the V1_2 HAL.
@@ -30,6 +34,10 @@ cc_test {
srcs: [
"GeneratedTestsV1_1.cpp",
],
cflags: [
"-DNN_TEST_DYNAMIC_OUTPUT_SHAPE"
],
test_suites: ["general-tests"],
}
// Tests for V1_2 models.
@@ -40,5 +48,8 @@ cc_test {
"BasicTests.cpp",
"GeneratedTests.cpp",
],
cflags: [
"-DNN_TEST_DYNAMIC_OUTPUT_SHAPE"
],
test_suites: ["general-tests"],
}

View File

@@ -33,7 +33,8 @@ namespace neuralnetworks {
namespace generated_tests {
using ::test_helper::MixedTypedExample;
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
std::function<bool(int)>, const std::vector<MixedTypedExample>&);
std::function<bool(int)>, const std::vector<MixedTypedExample>&,
bool testDynamicOutputShape = false);
} // namespace generated_tests
namespace V1_2 {

View File

@@ -33,7 +33,8 @@ namespace neuralnetworks {
namespace generated_tests {
using ::test_helper::MixedTypedExample;
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
std::function<bool(int)>, const std::vector<MixedTypedExample>&);
std::function<bool(int)>, const std::vector<MixedTypedExample>&,
bool testDynamicOutputShape = false);
} // namespace generated_tests
namespace V1_2 {

View File

@@ -33,7 +33,8 @@ namespace neuralnetworks {
namespace generated_tests {
using ::test_helper::MixedTypedExample;
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
std::function<bool(int)>, const std::vector<MixedTypedExample>&);
std::function<bool(int)>, const std::vector<MixedTypedExample>&,
bool testDynamicOutputShape = false);
} // namespace generated_tests
namespace V1_2 {

View File

@@ -172,6 +172,9 @@ static uint32_t getInvalidRank(OperandType type) {
static void mutateOperandRankTest(const sp<IDevice>& device, const Model& model) {
for (size_t operand = 0; operand < model.operands.size(); ++operand) {
const uint32_t invalidRank = getInvalidRank(model.operands[operand].type);
if (invalidRank == 0) {
continue;
}
const std::string message = "mutateOperandRankTest: operand " + std::to_string(operand) +
" has rank of " + std::to_string(invalidRank);
validate(device, message, model, [operand, invalidRank](Model* model) {

View File

@@ -79,6 +79,9 @@ class ValidationTest : public NeuralnetworksHidlTest {
// Tag for the generated tests
class GeneratedTest : public NeuralnetworksHidlTest {};
// Tag for the dynamic output shape tests
class DynamicOutputShapeTest : public NeuralnetworksHidlTest {};
// Utility function to get PreparedModel from callback and downcast to V1_2.
sp<IPreparedModel> getPreparedModel_1_2(
const sp<V1_2::implementation::PreparedModelCallback>& callback);