From b5823802fb30743fce41e8efe47104dca2ea2681 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Prasanna=20R/System=20SW=20/SRI-Bangalore/Engineer/?= =?utf8?q?=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 5 Oct 2018 06:51:36 +0530 Subject: [PATCH] Add generated tests for NEG_EX (#2869) Add neg_ex_1D_float for testing 1d tensor. Add neg_ex_2D_float for testing 2d tensor. Signed-off-by: prasannar --- .../generated/all_generated_tests.cpp | 28 ++++++++++++++++++++++ .../generated/examples/neg_ex_1D_float.example.cpp | 22 +++++++++++++++++ .../generated/examples/neg_ex_2D_float.example.cpp | 22 +++++++++++++++++ .../generated/models/neg_ex_1D_float.model.cpp | 19 +++++++++++++++ .../generated/models/neg_ex_2D_float.model.cpp | 19 +++++++++++++++ ...me_run_android_nn_test.skip.armv7l-linux.neurun | 2 ++ .../runtime_run_android_nn_test.skip.armv7l-tizen | 2 ++ .../runtime_run_android_nn_test.skip.x86_64-linux | 2 ++ .../specs/Ex/neg_ex_1D_float.mod.py | 15 ++++++++++++ .../specs/Ex/neg_ex_2D_float.mod.py | 19 +++++++++++++++ 10 files changed, 150 insertions(+) create mode 100644 runtimes/tests/neural_networks_test/generated/examples/neg_ex_1D_float.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/examples/neg_ex_2D_float.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/neg_ex_1D_float.model.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/neg_ex_2D_float.model.cpp create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/neg_ex_1D_float.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/neg_ex_2D_float.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 6d55d7a..9ab638b 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,34 @@ TEST_F(GeneratedTests, gather_2D_quant8) { gather_2D_quant8::examples); } +namespace neg_ex_1D_float { +std::vector examples = { +// Generated neg_ex_1D_float test +#include "generated/examples/neg_ex_1D_float.example.cpp" +}; +// Generated model constructor +#include "generated/models/neg_ex_1D_float.model.cpp" +} // namespace neg_ex_1D_float +TEST_F(GeneratedTests, neg_ex_1D_float) { + execute(neg_ex_1D_float::CreateModel, + neg_ex_1D_float::is_ignored, + neg_ex_1D_float::examples); +} + +namespace neg_ex_2D_float { +std::vector examples = { +// Generated neg_ex_2D_float test +#include "generated/examples/neg_ex_2D_float.example.cpp" +}; +// Generated model constructor +#include "generated/models/neg_ex_2D_float.model.cpp" +} // namespace neg_ex_2D_float +TEST_F(GeneratedTests, neg_ex_2D_float) { + execute(neg_ex_2D_float::CreateModel, + neg_ex_2D_float::is_ignored, + neg_ex_2D_float::examples); +} + namespace tensorflowmax_ex_2D_float { std::vector examples = { // Generated tensorflowmax_ex_2D_float test diff --git a/runtimes/tests/neural_networks_test/generated/examples/neg_ex_1D_float.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/neg_ex_1D_float.example.cpp new file mode 100644 index 0000000..26513ed --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/neg_ex_1D_float.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: neg_ex_1D_float.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {3.0f, 4.0f, 5.0f, 6.0f}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {-3.0f, -4.0f, -5.0f, -6.0f}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/neg_ex_2D_float.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/neg_ex_2D_float.example.cpp new file mode 100644 index 0000000..599f89c --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/neg_ex_2D_float.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: neg_ex_2D_float.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {3.123456789123457f, 4.123456789123456f, 5.123456789123456f, 6.123456789123456f, 7.123456789123456f, 8.123456789123457f, 9.123456789123457f, 1.1234567891234568f, 2.123456789123457f, 18.123456789123455f, 19.123456789123455f, 11.123456789123457f}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {-3.123456789123457f, -4.123456789123456f, -5.123456789123456f, -6.123456789123456f, -7.123456789123456f, -8.123456789123457f, -9.123456789123457f, -1.1234567891234568f, -2.123456789123457f, -18.123456789123455f, -19.123456789123455f, -11.123456789123457f}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/models/neg_ex_1D_float.model.cpp b/runtimes/tests/neural_networks_test/generated/models/neg_ex_1D_float.model.cpp new file mode 100644 index 0000000..0375a9e --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/neg_ex_1D_float.model.cpp @@ -0,0 +1,19 @@ +// Generated file (from: neg_ex_1D_float.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type0(Type::TENSOR_FLOAT32, {4}); + // Phase 1, operands + auto op1 = model->addOperand(&type0); + auto op2 = model->addOperand(&type0); + // Phase 2, operations + model->addOperationEx(ANEURALNETWORKS_NEG_EX, {op1}, {op2}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op1}, + {op2}); + 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/neg_ex_2D_float.model.cpp b/runtimes/tests/neural_networks_test/generated/models/neg_ex_2D_float.model.cpp new file mode 100644 index 0000000..82a72b7 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/neg_ex_2D_float.model.cpp @@ -0,0 +1,19 @@ +// Generated file (from: neg_ex_2D_float.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type0(Type::TENSOR_FLOAT32, {3,4}); + // Phase 1, operands + auto op1 = model->addOperand(&type0); + auto op2 = model->addOperand(&type0); + // Phase 2, operations + model->addOperationEx(ANEURALNETWORKS_NEG_EX, {op1}, {op2}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op1}, + {op2}); + 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 84a48a6..5ac1e3f 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 @@ -73,6 +73,8 @@ GeneratedTests.max_pool_quant8_2 GeneratedTests.max_pool_quant8_3 GeneratedTests.mobilenet* GeneratedTests.mul* +GeneratedTests.neg_ex_1D_float +GeneratedTests.neg_ex_2D_float GeneratedTests.relu1* GeneratedTests.relu6* GeneratedTests.relu* diff --git a/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-tizen b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-tizen index a33955f..38321a1 100644 --- a/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-tizen +++ b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-tizen @@ -44,6 +44,8 @@ GeneratedTests.mean_float_2 GeneratedTests.mean_quant8_1 GeneratedTests.mean_quant8_2 GeneratedTests.mobilenet_quantized +GeneratedTests.neg_ex_1D_float +GeneratedTests.neg_ex_2D_float GeneratedTests.pad GeneratedTests.pad_float_1 GeneratedTests.space_to_batch diff --git a/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.x86_64-linux b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.x86_64-linux index 05f708e..f3d3b38 100644 --- a/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.x86_64-linux +++ b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.x86_64-linux @@ -36,6 +36,8 @@ GeneratedTests.lstm3_state GeneratedTests.lstm GeneratedTests.lstm_state2 GeneratedTests.lstm_state +GeneratedTests.neg_ex_1D_float +GeneratedTests.neg_ex_2D_float GeneratedTests.relu1_float_1 GeneratedTests.relu1_float_2 GeneratedTests.relu1_quant8_1 diff --git a/runtimes/tests/neural_networks_test/specs/Ex/neg_ex_1D_float.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/neg_ex_1D_float.mod.py new file mode 100644 index 0000000..d662980 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/neg_ex_1D_float.mod.py @@ -0,0 +1,15 @@ +# model +model = Model() +i1 = Input("op1", "TENSOR_FLOAT32", "{4}") # a vector of input +i2 = Output("op2", "TENSOR_FLOAT32", "{4}") # a vector of output +model = model.Operation("NEG_EX", i1).To(i2) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [3.0, 4.0, 5.0, 6.0]} + +output0 = {i2: # output 0 + [-3.0, -4.0, -5.0, -6.0]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/neg_ex_2D_float.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/neg_ex_2D_float.mod.py new file mode 100644 index 0000000..829fede --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/neg_ex_2D_float.mod.py @@ -0,0 +1,19 @@ +# model +model = Model() +i1 = Input("op1", "TENSOR_FLOAT32", "{3,4}") +i2 = Output("op2", "TENSOR_FLOAT32", "{3,4}") +model = model.Operation("NEG_EX", i1).To(i2) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [3.123456789123456789, 4.123456789123456789, 5.123456789123456789, 6.123456789123456789, + 7.123456789123456789, 8.123456789123456789, 9.123456789123456789, 1.123456789123456789, + 2.123456789123456789, 18.123456789123456789, 19.123456789123456789, 11.123456789123456789]} + +output0 = {i2: # output 0 + [-3.123456789123456789, -4.123456789123456789, -5.123456789123456789, -6.123456789123456789, + -7.123456789123456789, -8.123456789123456789, -9.123456789123456789, -1.123456789123456789, + -2.123456789123456789, -18.123456789123456789, -19.123456789123456789, -11.123456789123456789]} + +# Instantiate an example +Example((input0, output0)) -- 2.7.4