From 291c54aedeae8b3341e92e67e36a8483635cb04d Mon Sep 17 00:00:00 2001 From: =?utf8?q?PRAVEEN=20DORESWAMY=20NAIDU/System=20SW=20/SRI-Bangalore/St?= =?utf8?q?aff=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 19 Nov 2018 13:16:27 +0530 Subject: [PATCH] Add generated test for ARG_MAX (#3554) The changes adds the generated test's for ARG max operation. Signed-off-by: Praveen D N --- .../generated/all_generated_tests.cpp | 42 ++++++++++++++++++++++ .../generated/examples/argmax_ex.example.cpp | 22 ++++++++++++ .../generated/examples/argmax_ex_2.example.cpp | 22 ++++++++++++ .../examples/argmax_ex_neg_axis.example.cpp | 22 ++++++++++++ .../generated/models/argmax_ex.model.cpp | 24 +++++++++++++ .../generated/models/argmax_ex_2.model.cpp | 24 +++++++++++++ .../generated/models/argmax_ex_neg_axis.model.cpp | 24 +++++++++++++ ...me_run_android_nn_test.skip.armv7l-linux.neurun | 1 + .../neural_networks_test/specs/Ex/argmax_ex.mod.py | 18 ++++++++++ .../specs/Ex/argmax_ex_2.mod.py | 18 ++++++++++ .../specs/Ex/argmax_ex_neg_axis.mod.py | 17 +++++++++ 11 files changed, 234 insertions(+) create mode 100644 runtimes/tests/neural_networks_test/generated/examples/argmax_ex.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/examples/argmax_ex_2.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/examples/argmax_ex_neg_axis.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/argmax_ex.model.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/argmax_ex_2.model.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/argmax_ex_neg_axis.model.cpp create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/argmax_ex.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_2.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_neg_axis.mod.py diff --git a/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp b/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp index 33bef5f..fd49bc4 100644 --- a/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp +++ b/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp @@ -3039,6 +3039,48 @@ TEST_F(GeneratedTests, transpose_quant8_1) { transpose_quant8_1::examples); } +namespace argmax_ex_2 { +std::vector examples = { +// Generated argmax_ex_2 test +#include "generated/examples/argmax_ex_2.example.cpp" +}; +// Generated model constructor +#include "generated/models/argmax_ex_2.model.cpp" +} // namespace argmax_ex_2 +TEST_F(GeneratedTests, argmax_ex_2) { + execute(argmax_ex_2::CreateModel, + argmax_ex_2::is_ignored, + argmax_ex_2::examples); +} + +namespace argmax_ex { +std::vector examples = { +// Generated argmax_ex test +#include "generated/examples/argmax_ex.example.cpp" +}; +// Generated model constructor +#include "generated/models/argmax_ex.model.cpp" +} // namespace argmax_ex +TEST_F(GeneratedTests, argmax_ex) { + execute(argmax_ex::CreateModel, + argmax_ex::is_ignored, + argmax_ex::examples); +} + +namespace argmax_ex_neg_axis { +std::vector examples = { +// Generated argmax_ex_neg_axis test +#include "generated/examples/argmax_ex_neg_axis.example.cpp" +}; +// Generated model constructor +#include "generated/models/argmax_ex_neg_axis.model.cpp" +} // namespace argmax_ex_neg_axis +TEST_F(GeneratedTests, argmax_ex_neg_axis) { + execute(argmax_ex_neg_axis::CreateModel, + argmax_ex_neg_axis::is_ignored, + argmax_ex_neg_axis::examples); +} + namespace cast_ex_float32_to_int32 { std::vector examples = { // Generated cast_ex_float32_to_int32 test diff --git a/runtimes/tests/neural_networks_test/generated/examples/argmax_ex.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/argmax_ex.example.cpp new file mode 100644 index 0000000..766d8d7 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/argmax_ex.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: argmax_ex.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {1.0f, 4.0f, 2.0f, 3.0f}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{0, {1, 0}}}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/argmax_ex_2.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/argmax_ex_2.example.cpp new file mode 100644 index 0000000..29087c5 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/argmax_ex_2.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: argmax_ex_2.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {1.0f, 2.0f, 7.0f, 8.0f, 1.0f, 9.0f, 7.0f, 3.0f}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{0, {1, 1, 1, 0}}}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/argmax_ex_neg_axis.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/argmax_ex_neg_axis.example.cpp new file mode 100644 index 0000000..40887ba --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/argmax_ex_neg_axis.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: argmax_ex_neg_axis.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {1.0f, 2.0f, 7.0f, 8.0f, 1.0f, 9.0f, 7.0f, 3.0f}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{0, {0, 1, 0, 0}}}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/models/argmax_ex.model.cpp b/runtimes/tests/neural_networks_test/generated/models/argmax_ex.model.cpp new file mode 100644 index 0000000..4d70d3e --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/argmax_ex.model.cpp @@ -0,0 +1,24 @@ +// Generated file (from: argmax_ex.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1}); + OperandType type2(Type::TENSOR_INT32, {1, 1, 2, 1}); + OperandType type1(Type::TENSOR_INT32, {1}); + // Phase 1, operands + auto input = model->addOperand(&type0); + auto axis = model->addOperand(&type1); + auto output = model->addOperand(&type2); + // Phase 2, operations + static int32_t axis_init[] = {1}; + model->setOperandValue(axis, axis_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_ARGMAX_EX, {input, axis}, {output}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {input}, + {output}); + assert(model->isValid()); +} + +bool is_ignored(int i) { + static std::set ignore = {}; + return ignore.find(i) != ignore.end(); +} diff --git a/runtimes/tests/neural_networks_test/generated/models/argmax_ex_2.model.cpp b/runtimes/tests/neural_networks_test/generated/models/argmax_ex_2.model.cpp new file mode 100644 index 0000000..be5276e --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/argmax_ex_2.model.cpp @@ -0,0 +1,24 @@ +// Generated file (from: argmax_ex_2.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 2}); + OperandType type2(Type::TENSOR_INT32, {1, 2, 2, 1}); + OperandType type1(Type::TENSOR_INT32, {1}); + // Phase 1, operands + auto input = model->addOperand(&type0); + auto axis = model->addOperand(&type1); + auto output = model->addOperand(&type2); + // Phase 2, operations + static int32_t axis_init[] = {3}; + model->setOperandValue(axis, axis_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_ARGMAX_EX, {input, axis}, {output}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {input}, + {output}); + assert(model->isValid()); +} + +bool is_ignored(int i) { + static std::set ignore = {}; + return ignore.find(i) != ignore.end(); +} diff --git a/runtimes/tests/neural_networks_test/generated/models/argmax_ex_neg_axis.model.cpp b/runtimes/tests/neural_networks_test/generated/models/argmax_ex_neg_axis.model.cpp new file mode 100644 index 0000000..3e7d03b --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/argmax_ex_neg_axis.model.cpp @@ -0,0 +1,24 @@ +// Generated file (from: argmax_ex_neg_axis.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 4, 1}); + OperandType type2(Type::TENSOR_INT32, {1, 1, 4, 1}); + OperandType type1(Type::TENSOR_INT32, {1}); + // Phase 1, operands + auto input = model->addOperand(&type0); + auto axis = model->addOperand(&type1); + auto output = model->addOperand(&type2); + // Phase 2, operations + static int32_t axis_init[] = {-3}; + model->setOperandValue(axis, axis_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_ARGMAX_EX, {input, axis}, {output}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {input}, + {output}); + assert(model->isValid()); +} + +bool is_ignored(int i) { + static std::set ignore = {}; + return ignore.find(i) != ignore.end(); +} diff --git a/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux.neurun b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux.neurun index 1e2a061..530cd08 100644 --- a/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux.neurun +++ b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux.neurun @@ -26,6 +26,7 @@ ValidationTestExecution.SetOutputFromMemory ValidationTestExecution.StartCompute ValidationTestExecution.EventWait GeneratedTests.add* +GeneratedTests.argmax* GeneratedTests.avg_pool_float_1 GeneratedTests.avg_pool_float_2 GeneratedTests.avg_pool_float_3 diff --git a/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex.mod.py new file mode 100644 index 0000000..e2255e0 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex.mod.py @@ -0,0 +1,18 @@ +model = Model() +i1 = Input("input", "TENSOR_FLOAT32", "{1, 2, 2, 1}") +axis = Parameter("axis", "TENSOR_INT32", "{1}", [1]) +output = Output("output", "TENSOR_INT32", "{1, 1, 2, 1}") + +model = model.Operation("ARGMAX_EX", i1, axis).To(output) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [1.0, 4.0, + 2.0, 3.0]} + +output0 = {output: # output 0 + [1, + 0]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_2.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_2.mod.py new file mode 100644 index 0000000..6f06bfd --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_2.mod.py @@ -0,0 +1,18 @@ +model = Model() +i1 = Input("input", "TENSOR_FLOAT32", "{1, 2, 2, 2}") +axis = Parameter("axis", "TENSOR_INT32", "{1}", [3]) +output = Output("output", "TENSOR_INT32", "{1, 2, 2, 1}") + +model = model.Operation("ARGMAX_EX", i1, axis).To(output) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [1.0, 2.0, 7.0, 8.0, + 1.0, 9.0, 7.0, 3.0]} + +output0 = {output: # output 0 + [1,1, + 1,0]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_neg_axis.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_neg_axis.mod.py new file mode 100644 index 0000000..b29cf1e --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/argmax_ex_neg_axis.mod.py @@ -0,0 +1,17 @@ +model = Model() +i1 = Input("input", "TENSOR_FLOAT32", "{1, 2, 4, 1}") +axis = Parameter("axis", "TENSOR_INT32", "{1}", [-3]) +output = Output("output", "TENSOR_INT32", "{1, 1, 4, 1}") + +model = model.Operation("ARGMAX_EX", i1, axis).To(output) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [1.0, 2.0, 7.0, 8.0, + 1.0, 9.0, 7.0, 3.0]} + +output0 = {output: # output 0 + [0, 1, 0, 0]} + +# Instantiate an example +Example((input0, output0)) -- 2.7.4