From: Vishal Keshav/System SW /SRI-Bangalore/Engineer/삼성전자 Date: Mon, 5 Nov 2018 01:09:04 +0000 (+0530) Subject: Added test cases for Pack operation (#3399) X-Git-Tag: 0.3~481 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=269aad4c56ace5bd58e13156767d0888a6649236;p=platform%2Fcore%2Fml%2Fnnfw.git Added test cases for Pack operation (#3399) Test cases for 3D to 4D pack along 2 axises Added test in skiplist of arm-linux, neuran and x86-linux Signed-off-by: Vishal Keshav --- diff --git a/runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float.example.cpp new file mode 100644 index 0000000..eee3cd3 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: pack_ex_3D_float.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {0, 4, 8, 12, 16, 20, 1, 5, 9, 13, 17, 21, 2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23}}, {1, {24, 28, 32, 36, 40, 44, 25, 29, 33, 37, 41, 45, 26, 30, 34, 38, 42, 46, 27, 31, 35, 39, 43, 47}}, {2, {48, 52, 56, 60, 64, 68, 49, 53, 57, 61, 65, 69, 50, 54, 58, 62, 66, 70, 51, 55, 59, 63, 67, 71}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float2.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float2.example.cpp new file mode 100644 index 0000000..f3c70ce --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float2.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: pack_ex_3D_float2.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {0, 1, 2, 3}}, {1, {4, 5, 6, 7}}, {2, {8, 9, 10, 11}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {{0, {0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11}}}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/models/pack_ex_3D_float.model.cpp b/runtimes/tests/neural_networks_test/generated/models/pack_ex_3D_float.model.cpp new file mode 100644 index 0000000..d39ea37 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/pack_ex_3D_float.model.cpp @@ -0,0 +1,26 @@ +// Generated file (from: pack_ex_3D_float.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type1(Type::INT32, {}); + OperandType type2(Type::TENSOR_FLOAT32, {3, 2, 3, 4}); + OperandType type0(Type::TENSOR_FLOAT32, {4, 2, 3}); + // Phase 1, operands + auto input1 = model->addOperand(&type0); + auto input2 = model->addOperand(&type0); + auto input3 = model->addOperand(&type0); + auto axis = model->addOperand(&type1); + auto output = model->addOperand(&type2); + // Phase 2, operations + static int32_t axis_init[] = {0}; + model->setOperandValue(axis, axis_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_PACK_EX, {input1, input2, input3, axis}, {output}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {input1, input2, input3}, + {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/pack_ex_3D_float2.model.cpp b/runtimes/tests/neural_networks_test/generated/models/pack_ex_3D_float2.model.cpp new file mode 100644 index 0000000..aacb9cf --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/pack_ex_3D_float2.model.cpp @@ -0,0 +1,26 @@ +// Generated file (from: pack_ex_3D_float2.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type1(Type::INT32, {}); + OperandType type0(Type::TENSOR_FLOAT32, {2, 2, 1}); + OperandType type2(Type::TENSOR_FLOAT32, {2, 2, 3, 1}); + // Phase 1, operands + auto input1 = model->addOperand(&type0); + auto input2 = model->addOperand(&type0); + auto input3 = model->addOperand(&type0); + auto axis = model->addOperand(&type1); + auto output = model->addOperand(&type2); + // Phase 2, operations + static int32_t axis_init[] = {2}; + model->setOperandValue(axis, axis_init, sizeof(int32_t) * 1); + model->addOperationEx(ANEURALNETWORKS_PACK_EX, {input1, input2, input3, axis}, {output}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {input1, input2, input3}, + {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 b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux index e853130..bc69e07 100644 --- a/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux +++ b/runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux @@ -50,3 +50,4 @@ GeneratedTests.logistic_quant8_1 GeneratedTests.logistic_quant8_2 GeneratedTests.mul_broadcast_quant8 GeneratedTests.mul_quant8 +GeneratedTests.pack* 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 1b14b13..eb89d41 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 @@ -110,3 +110,4 @@ GeneratedTests.avg_pool_quant8_5 GeneratedTests.conv_quant8_2 GeneratedTests.max_pool_quant8_4 GeneratedTests.softmax* +GeneratedTests.pack* 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 8771150..68ec117 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 @@ -76,3 +76,4 @@ ValidationTestIdentify.* ValidationTestExecution.* GeneratedTests.gather_1D_quant8 GeneratedTests.gather_2D_quant8 +GeneratedTests.pack* diff --git a/runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float.mod.py new file mode 100644 index 0000000..f88a399 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float.mod.py @@ -0,0 +1,24 @@ +# Sample Stack or Pack model +model = Model() +i1 = Input("input1", "TENSOR_FLOAT32", "{4, 2, 3}") +i2 = Input("input2", "TENSOR_FLOAT32", "{4, 2, 3}") +i3 = Input("input3", "TENSOR_FLOAT32", "{4, 2, 3}") +axis = Int32Scalar("axis", 0) +out = Output("output", "TENSOR_FLOAT32", "{3, 2, 3, 4}") +model = model.Operation("PACK_EX", i1,i2,i3,axis).To(out) + +input0 = {i1: # input 0 + [ 0, 4, 8, 12, 16, 20, 1, 5, 9, 13, 17, 21, 2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23], + i2: # input 1 + [24, 28, 32, 36, 40, 44, 25, 29, 33, 37, 41, 45, 26, 30, 34, 38, 42, 46, 27, 31, 35, 39, 43, 47], + i3: # input 2 + [48, 52, 56, 60, 64, 68, 49, 53, 57, 61, 65, 69, 50, 54, 58, 62, 66, 70, 51, 55, 59, 63, 67, 71]} + +output0 = {out: # output 0 + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float2.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float2.mod.py new file mode 100644 index 0000000..9bd026b --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float2.mod.py @@ -0,0 +1,21 @@ +# Sample Stack or Pack model +model = Model() +i1 = Input("input1", "TENSOR_FLOAT32", "{2, 2, 1}") +i2 = Input("input2", "TENSOR_FLOAT32", "{2, 2, 1}") +i3 = Input("input3", "TENSOR_FLOAT32", "{2, 2, 1}") +axis = Int32Scalar("axis", 2) +out = Output("output", "TENSOR_FLOAT32", "{2, 2, 3, 1}") +model = model.Operation("PACK_EX", i1,i2,i3,axis).To(out) + +input0 = {i1: # input 0 + [0, 1, 2, 3], + i2: # input 1 + [4, 5, 6, 7], + i3: # input 2 + [ 8, 9, 10, 11]} + +output0 = {out: # output 0 +[ 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11]} + +# Instantiate an example +Example((input0, output0))