From: Devansh Bansal/SNAP /SRI-Bangalore/Engineer/삼성전자 Date: Wed, 5 Dec 2018 00:17:31 +0000 (+0530) Subject: Add generatedtests for TransposeConv (#3710) X-Git-Tag: 0.3~211 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2de86edf3c32fa4902b3d45ac569d71b1e8895c4;p=platform%2Fcore%2Fml%2Fnnfw.git Add generatedtests for TransposeConv (#3710) This patch adds generatedtests for TransposeConv. Signed-off-by: b.devansh --- 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 8a94e80..440610d 100644 --- a/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp +++ b/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp @@ -4005,6 +4005,48 @@ TEST_F(GeneratedTests, topk_v2_ex_2D_quant8) { topk_v2_ex_2D_quant8::examples); } +namespace transpose_conv_ex_float_1 { +std::vector examples = { +// Generated transpose_conv_ex_float_1 test +#include "generated/examples/transpose_conv_ex_float_1.example.cpp" +}; +// Generated model constructor +#include "generated/models/transpose_conv_ex_float_1.model.cpp" +} // namespace transpose_conv_ex_float_1 +TEST_F(GeneratedTests, transpose_conv_ex_float_1) { + execute(transpose_conv_ex_float_1::CreateModel, + transpose_conv_ex_float_1::is_ignored, + transpose_conv_ex_float_1::examples); +} + +namespace transpose_conv_ex_float_2 { +std::vector examples = { +// Generated transpose_conv_ex_float_2 test +#include "generated/examples/transpose_conv_ex_float_2.example.cpp" +}; +// Generated model constructor +#include "generated/models/transpose_conv_ex_float_2.model.cpp" +} // namespace transpose_conv_ex_float_2 +TEST_F(GeneratedTests, transpose_conv_ex_float_2) { + execute(transpose_conv_ex_float_2::CreateModel, + transpose_conv_ex_float_2::is_ignored, + transpose_conv_ex_float_2::examples); +} + +namespace transpose_conv_ex_float_3 { +std::vector examples = { +// Generated transpose_conv_ex_float_3 test +#include "generated/examples/transpose_conv_ex_float_3.example.cpp" +}; +// Generated model constructor +#include "generated/models/transpose_conv_ex_float_3.model.cpp" +} // namespace transpose_conv_ex_float_3 +TEST_F(GeneratedTests, transpose_conv_ex_float_3) { + execute(transpose_conv_ex_float_3::CreateModel, + transpose_conv_ex_float_3::is_ignored, + transpose_conv_ex_float_3::examples); +} + namespace unpack_ex_3D_float2 { std::vector examples = { // Generated unpack_ex_3D_float2 test diff --git a/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_1.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_1.example.cpp new file mode 100644 index 0000000..0661187 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_1.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: transpose_conv_ex_float_1.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {1, 4, 4, 1}}, {1, {1, 2, 3, 4, 5, 6, 7, 8, 9}}, {2, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {29, 62, 83, 75, 99, 192, 237, 198, 207, 372, 417, 330, 263, 446, 485, 365}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_2.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_2.example.cpp new file mode 100644 index 0000000..d0103ae --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_2.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: transpose_conv_ex_float_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, 5, 5, 1}}, {1, {1, 2, 3, 4, 5, 6, 7, 8, 9}}, {2, {1, 2, 3, 4}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {1, 2, 5, 4, 6, 4, 5, 14, 10, 12, 10, 14, 36, 24, 30, 12, 15, 34, 20, 24, 21, 24, 55, 32, 36}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_3.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_3.example.cpp new file mode 100644 index 0000000..a291edb --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/transpose_conv_ex_float_3.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: transpose_conv_ex_float_3.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {1, 5, 5, 2}}, {1, {1, 3, 5, 7, 9, 11, 13, 15, 17, 2, 4, 6, 8, 10, 12, 14, 16, 18}}, {2, {1, 2, 3, 4}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {1, 2, 3, 4, 7, 10, 6, 8, 10, 12, 7, 8, 9, 10, 25, 28, 18, 20, 22, 24, 16, 20, 24, 28, 62, 72, 42, 48, 54, 60, 21, 24, 27, 30, 61, 68, 36, 40, 44, 48, 39, 42, 45, 48, 103, 110, 60, 64, 68, 72}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/models/transpose_conv_ex_float_1.model.cpp b/runtimes/tests/neural_networks_test/generated/models/transpose_conv_ex_float_1.model.cpp new file mode 100644 index 0000000..f31d02c --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/transpose_conv_ex_float_1.model.cpp @@ -0,0 +1,33 @@ +// Generated file (from: transpose_conv_ex_float_1.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type3(Type::INT32, {}); + OperandType type1(Type::TENSOR_FLOAT32, {1, 3, 3, 1}); + OperandType type2(Type::TENSOR_FLOAT32, {1, 4, 4, 1}); + OperandType type0(Type::TENSOR_FLOAT32, {4}); + // Phase 1, operands + auto op_shape = model->addOperand(&type0); + auto ker = model->addOperand(&type1); + auto in = model->addOperand(&type2); + auto pad_same = model->addOperand(&type3); + auto stride_x = model->addOperand(&type3); + auto stride_y = model->addOperand(&type3); + auto op = model->addOperand(&type2); + // Phase 2, operations + static int32_t pad_same_init[] = {1}; + model->setOperandValue(pad_same, pad_same_init, sizeof(int32_t) * 1); + static int32_t stride_x_init[] = {1}; + model->setOperandValue(stride_x, stride_x_init, sizeof(int32_t) * 1); + static int32_t stride_y_init[] = {1}; + model->setOperandValue(stride_y, stride_y_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_TRANSPOSE_CONV_EX, {op_shape, ker, in, pad_same, stride_x, stride_y}, {op}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op_shape, ker, in}, + {op}); + 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/transpose_conv_ex_float_2.model.cpp b/runtimes/tests/neural_networks_test/generated/models/transpose_conv_ex_float_2.model.cpp new file mode 100644 index 0000000..18b9443 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/transpose_conv_ex_float_2.model.cpp @@ -0,0 +1,34 @@ +// Generated file (from: transpose_conv_ex_float_2.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type3(Type::INT32, {}); + OperandType type2(Type::TENSOR_FLOAT32, {1, 2, 2, 1}); + OperandType type1(Type::TENSOR_FLOAT32, {1, 3, 3, 1}); + OperandType type4(Type::TENSOR_FLOAT32, {1, 5, 5, 1}); + OperandType type0(Type::TENSOR_FLOAT32, {4}); + // Phase 1, operands + auto op_shape = model->addOperand(&type0); + auto ker = model->addOperand(&type1); + auto in = model->addOperand(&type2); + auto pad_valid = model->addOperand(&type3); + auto stride_x = model->addOperand(&type3); + auto stride_y = model->addOperand(&type3); + auto op = model->addOperand(&type4); + // Phase 2, operations + static int32_t pad_valid_init[] = {2}; + model->setOperandValue(pad_valid, pad_valid_init, sizeof(int32_t) * 1); + static int32_t stride_x_init[] = {2}; + model->setOperandValue(stride_x, stride_x_init, sizeof(int32_t) * 1); + static int32_t stride_y_init[] = {2}; + model->setOperandValue(stride_y, stride_y_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_TRANSPOSE_CONV_EX, {op_shape, ker, in, pad_valid, stride_x, stride_y}, {op}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op_shape, ker, in}, + {op}); + 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/transpose_conv_ex_float_3.model.cpp b/runtimes/tests/neural_networks_test/generated/models/transpose_conv_ex_float_3.model.cpp new file mode 100644 index 0000000..138a594 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/transpose_conv_ex_float_3.model.cpp @@ -0,0 +1,34 @@ +// Generated file (from: transpose_conv_ex_float_3.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type3(Type::INT32, {}); + OperandType type2(Type::TENSOR_FLOAT32, {1, 2, 2, 1}); + OperandType type4(Type::TENSOR_FLOAT32, {1, 5, 5, 2}); + OperandType type1(Type::TENSOR_FLOAT32, {2, 3, 3, 1}); + OperandType type0(Type::TENSOR_FLOAT32, {4}); + // Phase 1, operands + auto op_shape = model->addOperand(&type0); + auto ker = model->addOperand(&type1); + auto in = model->addOperand(&type2); + auto pad_valid = model->addOperand(&type3); + auto stride_x = model->addOperand(&type3); + auto stride_y = model->addOperand(&type3); + auto op = model->addOperand(&type4); + // Phase 2, operations + static int32_t pad_valid_init[] = {2}; + model->setOperandValue(pad_valid, pad_valid_init, sizeof(int32_t) * 1); + static int32_t stride_x_init[] = {2}; + model->setOperandValue(stride_x, stride_x_init, sizeof(int32_t) * 1); + static int32_t stride_y_init[] = {2}; + model->setOperandValue(stride_y, stride_y_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_TRANSPOSE_CONV_EX, {op_shape, ker, in, pad_valid, stride_x, stride_y}, {op}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op_shape, ker, in}, + {op}); + 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 534de1f..9b5c359 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 @@ -116,5 +116,6 @@ GeneratedTests.conv_quant8_2 GeneratedTests.max_pool_quant8_4 GeneratedTests.softmax* GeneratedTests.split* +GeneratedTests.transpose_conv* GeneratedTests.pack* GeneratedTests.unpack* 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 4596409..e068f44 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 @@ -111,5 +111,6 @@ GeneratedTests.logistic_quant8_2 GeneratedTests.mul_broadcast_quant8 GeneratedTests.mul_quant8 GeneratedTests.split* +GeneratedTests.transpose_conv* GeneratedTests.sub_broadcast_float GeneratedTests.pack_ex_3D_float2 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 dd18702..ab29975 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 @@ -81,5 +81,6 @@ ValidationTestExecution.* GeneratedTests.gather_ex_1D_quant8 GeneratedTests.gather_ex_2D_quant8 GeneratedTests.split* +GeneratedTests.transpose_conv* GeneratedTests.pack* GeneratedTests.unpack* diff --git a/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_1.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_1.mod.py new file mode 100644 index 0000000..40be027 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_1.mod.py @@ -0,0 +1,25 @@ +# model +model = Model() +i0 = Input("op_shape", "TENSOR_FLOAT32", "{4}") +weights = Input("ker", "TENSOR_FLOAT32", "{1, 3, 3, 1}") +i1 = Input("in", "TENSOR_FLOAT32", "{1, 4, 4, 1}" ) +pad = Int32Scalar("pad_same", 1) +s_x = Int32Scalar("stride_x", 1) +s_y = Int32Scalar("stride_y", 1) +i2 = Output("op", "TENSOR_FLOAT32", "{1, 4, 4, 1}") +model = model.Operation("TRANSPOSE_CONV_EX", i0, weights, i1, pad, s_x, s_y).To(i2) + +# Example 1. Input in operand 0, +input0 = {i0: # output shape + [1, 4, 4, 1], + i1: # input 0 + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], + weights: # input 1 + [1, 2, 3, 4, 5, 6, 7, 8, 9]} + +output0 = {i2: # output 0 + [29, 62, 83, 75, 99, 192, 237, 198, 207, 372, + 417, 330, 263, 446, 485, 365]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_2.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_2.mod.py new file mode 100644 index 0000000..d52d82c --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_2.mod.py @@ -0,0 +1,25 @@ +# model +model = Model() +i0 = Input("op_shape", "TENSOR_FLOAT32", "{4}") +weights = Input("ker", "TENSOR_FLOAT32", "{1, 3, 3, 1}") +i1 = Input("in", "TENSOR_FLOAT32", "{1, 2, 2, 1}" ) +pad = Int32Scalar("pad_valid", 2) +s_x = Int32Scalar("stride_x", 2) +s_y = Int32Scalar("stride_y", 2) +i2 = Output("op", "TENSOR_FLOAT32", "{1, 5, 5, 1}") +model = model.Operation("TRANSPOSE_CONV_EX", i0, weights, i1, pad, s_x, s_y).To(i2) + +# Example 1. Input in operand 0, +input0 = {i0: # output shape + [1, 5, 5, 1], + i1: # input 0 + [1, 2, 3, 4], + weights: # input 1 + [1, 2, 3, 4, 5, 6, 7, 8, 9]} + +output0 = {i2: # output 0 + [1, 2, 5, 4, 6, 4, 5, 14, 10, 12, 10, 14, 36, + 24, 30, 12, 15, 34, 20, 24, 21, 24, 55, 32, 36]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_3.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_3.mod.py new file mode 100644 index 0000000..03cfaed --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/transpose_conv_ex_float_3.mod.py @@ -0,0 +1,27 @@ +# model +model = Model() +i0 = Input("op_shape", "TENSOR_FLOAT32", "{4}") +weights = Input("ker", "TENSOR_FLOAT32", "{2, 3, 3, 1}") +i1 = Input("in", "TENSOR_FLOAT32", "{1, 2, 2, 1}" ) +pad = Int32Scalar("pad_valid", 2) +s_x = Int32Scalar("stride_x", 2) +s_y = Int32Scalar("stride_y", 2) +i2 = Output("op", "TENSOR_FLOAT32", "{1, 5, 5, 2}") +model = model.Operation("TRANSPOSE_CONV_EX", i0, weights, i1, pad, s_x, s_y).To(i2) + +# Example 1. Input in operand 0, +input0 = {i0: # output shape + [1, 5, 5, 2], + i1: # input 0 + [1, 2, 3, 4], + weights: # input 1 + [1, 3, 5, 7, 9, 11, 13, 15, 17, 2, 4, 6, 8, 10, 12, 14, 16, 18]} + +output0 = {i2: # output 0 + [1, 2, 3, 4, 7, 10, 6, 8, 10, 12, 7, 8, 9, + 10, 25, 28, 18, 20, 22, 24, 16, 20, 24, 28, 62, 72, + 42, 48, 54, 60, 21, 24, 27, 30, 61, 68, 36, 40, 44, + 48, 39, 42, 45, 48, 103, 110, 60, 64, 68, 72]} + +# Instantiate an example +Example((input0, output0))