Added test cases for Pack operation (#3399)
authorVishal Keshav/System SW /SRI-Bangalore/Engineer/삼성전자 <vishal.k1@samsung.com>
Mon, 5 Nov 2018 01:09:04 +0000 (06:39 +0530)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 5 Nov 2018 01:09:04 +0000 (10:09 +0900)
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 <vishal.k1@samsung.com>
runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float.example.cpp [new file with mode: 0644]
runtimes/tests/neural_networks_test/generated/examples/pack_ex_3D_float2.example.cpp [new file with mode: 0644]
runtimes/tests/neural_networks_test/generated/models/pack_ex_3D_float.model.cpp [new file with mode: 0644]
runtimes/tests/neural_networks_test/generated/models/pack_ex_3D_float2.model.cpp [new file with mode: 0644]
runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux
runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.armv7l-linux.neurun
runtimes/tests/neural_networks_test/runtime_run_android_nn_test.skip.x86_64-linux
runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float.mod.py [new file with mode: 0644]
runtimes/tests/neural_networks_test/specs/Ex/pack_ex_3D_float2.mod.py [new file with mode: 0644]

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 (file)
index 0000000..eee3cd3
--- /dev/null
@@ -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 (file)
index 0000000..f3c70ce
--- /dev/null
@@ -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 (file)
index 0000000..d39ea37
--- /dev/null
@@ -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<int> 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 (file)
index 0000000..aacb9cf
--- /dev/null
@@ -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<int> ignore = {};
+  return ignore.find(i) != ignore.end();
+}
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 (file)
index 0000000..f88a399
--- /dev/null
@@ -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 (file)
index 0000000..9bd026b
--- /dev/null
@@ -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))