[Generated Test] TC for Concat([4D, 4D, 4D], axis=3) (#2364)
author윤현식/동작제어Lab(SR)/Principal Engineer/삼성전자 <hyunsik.yoon@samsung.com>
Mon, 20 Aug 2018 09:37:57 +0000 (18:37 +0900)
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Mon, 20 Aug 2018 09:37:57 +0000 (18:37 +0900)
Currently all of generated test for concat fail.
This commit adds a test case for concat with 4D inputs and axis=3 and passes without error.
The purpose of adding this test is to check whether any modification against current concat code works correctly.

Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp
runtimes/tests/neural_networks_test/generated/examples/concat_float_4D_axis3_1_nnfw.example.cpp [new file with mode: 0644]
runtimes/tests/neural_networks_test/generated/models/concat_float_4D_axis3_1_nnfw.model.cpp [new file with mode: 0644]
runtimes/tests/neural_networks_test/specs/V1_0/concat_float_4D_axis3_1_nnfw.mod.py [new file with mode: 0644]

index 7c562b9..5b2013d 100644 (file)
@@ -225,6 +225,20 @@ TEST_F(GeneratedTests, concat_float_3) {
             concat_float_3::examples);
 }
 
+namespace concat_float_4D_axis3_1_nnfw {
+std::vector<MixedTypedExample> examples = {
+// Generated concat_float_4D_axis3_1_nnfw test
+#include "generated/examples/concat_float_4D_axis3_1_nnfw.example.cpp"
+};
+// Generated model constructor
+#include "generated/models/concat_float_4D_axis3_1_nnfw.model.cpp"
+} // namespace concat_float_4D_axis3_1_nnfw
+TEST_F(GeneratedTests, concat_float_4D_axis3_1_nnfw) {
+    execute(concat_float_4D_axis3_1_nnfw::CreateModel,
+            concat_float_4D_axis3_1_nnfw::is_ignored,
+            concat_float_4D_axis3_1_nnfw::examples);
+}
+
 namespace concat_quant8_1 {
 std::vector<MixedTypedExample> examples = {
 // Generated concat_quant8_1 test
diff --git a/runtimes/tests/neural_networks_test/generated/examples/concat_float_4D_axis3_1_nnfw.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/concat_float_4D_axis3_1_nnfw.example.cpp
new file mode 100644 (file)
index 0000000..63ec5c1
--- /dev/null
@@ -0,0 +1,22 @@
+// Generated file (from: concat_float_4D_axis3_1_nnfw.mod.py). Do not edit
+// Begin of an example
+{
+//Input(s)
+{ // See tools/test_generator/include/TestHarness.h:MixedTyped
+  // int -> FLOAT32 map
+  {{0, {-0.03203143f, -0.0334147f, -0.02527265f, 0.04576106f, 0.08869292f, 0.06428383f, -0.06473722f, -0.21933985f, -0.05541003f, -0.24157837f, -0.16328812f, -0.04581105f}}, {1, {-0.0569439f, -0.15872048f, 0.02965238f, -0.12761882f, -0.00185435f, -0.03297619f, 0.03581043f, -0.12603407f, 0.05999133f, 0.00290503f, 0.1727029f, 0.03342071f}}, {2, {0.10992613f, 0.09185287f, 0.16433905f, -0.00059073f, -0.01480746f, 0.0135175f, 0.07129054f, -0.15095694f, -0.04579685f, -0.13260484f, -0.10045543f, 0.0647094f}}},
+  // int -> INT32 map
+  {},
+  // int -> QUANT8_ASYMM map
+  {}
+},
+//Output(s)
+{ // See tools/test_generator/include/TestHarness.h:MixedTyped
+  // int -> FLOAT32 map
+  {{0, {-0.03203143f, -0.0334147f, -0.0569439f, -0.15872048f, 0.10992613f, 0.09185287f, -0.02527265f, 0.04576106f, 0.02965238f, -0.12761882f, 0.16433905f, -0.00059073f, 0.08869292f, 0.06428383f, -0.00185435f, -0.03297619f, -0.01480746f, 0.0135175f, -0.06473722f, -0.21933985f, 0.03581043f, -0.12603407f, 0.07129054f, -0.15095694f, -0.05541003f, -0.24157837f, 0.05999133f, 0.00290503f, -0.04579685f, -0.13260484f, -0.16328812f, -0.04581105f, 0.1727029f, 0.03342071f, -0.10045543f, 0.0647094f}}},
+  // int -> INT32 map
+  {},
+  // int -> QUANT8_ASYMM map
+  {}
+}
+}, // End of an example
diff --git a/runtimes/tests/neural_networks_test/generated/models/concat_float_4D_axis3_1_nnfw.model.cpp b/runtimes/tests/neural_networks_test/generated/models/concat_float_4D_axis3_1_nnfw.model.cpp
new file mode 100644 (file)
index 0000000..82ef41d
--- /dev/null
@@ -0,0 +1,26 @@
+// Generated file (from: concat_float_4D_axis3_1_nnfw.mod.py). Do not edit
+void CreateModel(Model *model) {
+  OperandType type1(Type::INT32, {});
+  OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 3, 2});
+  OperandType type2(Type::TENSOR_FLOAT32, {1, 2, 3, 6});
+  // Phase 1, operands
+  auto op1 = model->addOperand(&type0);
+  auto op2 = model->addOperand(&type0);
+  auto op3 = model->addOperand(&type0);
+  auto axis0 = model->addOperand(&type1);
+  auto result = model->addOperand(&type2);
+  // Phase 2, operations
+  static int32_t axis0_init[] = {3};
+  model->setOperandValue(axis0, axis0_init, sizeof(int32_t) * 1);
+  model->addOperation(ANEURALNETWORKS_CONCATENATION, {op1, op2, op3, axis0}, {result});
+  // Phase 3, inputs and outputs
+  model->identifyInputsAndOutputs(
+    {op1, op2, op3},
+    {result});
+  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/V1_0/concat_float_4D_axis3_1_nnfw.mod.py b/runtimes/tests/neural_networks_test/specs/V1_0/concat_float_4D_axis3_1_nnfw.mod.py
new file mode 100644 (file)
index 0000000..39080a3
--- /dev/null
@@ -0,0 +1,64 @@
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# model
+model = Model()
+i1 = Input("op1", "TENSOR_FLOAT32", "{1, 2, 3, 2}") # input tensor 0
+i2 = Input("op2", "TENSOR_FLOAT32", "{1, 2, 3, 2}") # input tensor 1
+i3 = Input("op3", "TENSOR_FLOAT32", "{1, 2, 3, 2}") # input tensor 2
+axis0 = Int32Scalar("axis0", 3)
+r = Output("result", "TENSOR_FLOAT32", "{1, 2, 3, 6}") # output
+model = model.Operation("CONCATENATION", i1, i2, i3, axis0).To(r)
+
+# Example 1.
+input0 = {i1: [-0.03203143, -0.0334147 , -0.02527265,  0.04576106,  0.08869292,
+                0.06428383, -0.06473722, -0.21933985, -0.05541003, -0.24157837,
+               -0.16328812, -0.04581105],
+          i2: [-0.0569439 , -0.15872048,  0.02965238, -0.12761882, -0.00185435,
+               -0.03297619,  0.03581043, -0.12603407,  0.05999133,  0.00290503,
+                0.1727029 ,  0.03342071],
+          i3: [ 0.10992613,  0.09185287,  0.16433905, -0.00059073, -0.01480746,
+                0.0135175 ,  0.07129054, -0.15095694, -0.04579685, -0.13260484,
+               -0.10045543,  0.0647094 ]}
+output0 = {r: [-0.03203143, -0.0334147 , -0.0569439 , -0.15872048,  0.10992613,
+                0.09185287, -0.02527265,  0.04576106,  0.02965238, -0.12761882,
+                0.16433905, -0.00059073,  0.08869292,  0.06428383, -0.00185435,
+               -0.03297619, -0.01480746,  0.0135175 , -0.06473722, -0.21933985,
+                0.03581043, -0.12603407,  0.07129054, -0.15095694, -0.05541003,
+               -0.24157837,  0.05999133,  0.00290503, -0.04579685, -0.13260484,
+               -0.16328812, -0.04581105,  0.1727029 ,  0.03342071, -0.10045543,
+                0.0647094 ]}
+
+# Instantiate an example
+Example((input0, output0))
+
+
+'''
+# The above data was generated with the code below:
+
+with tf.Session() as sess:
+
+    t1 = tf.random_normal([1, 2, 3, 2], stddev=0.1, dtype=tf.float32)
+    t2 = tf.random_normal([1, 2, 3, 2], stddev=0.1, dtype=tf.float32)
+    t3 = tf.random_normal([1, 2, 3, 2], stddev=0.1, dtype=tf.float32)
+    c1 = tf.concat([t1, t2, t3], axis=3)
+
+    print(c1) # print shape
+    print( sess.run([tf.reshape(t1, [12]),
+                     tf.reshape(t2, [12]),
+                     tf.reshape(t3, [12]),
+                     tf.reshape(c1, [1*2*3*(2*3)])]))
+'''