[Test] Add warmup to the golden layer
authorJihoon Lee <jhoon.it.lee@samsung.com>
Fri, 24 Sep 2021 08:10:25 +0000 (17:10 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Wed, 6 Oct 2021 12:03:28 +0000 (21:03 +0900)
This patch add warmup forwarding to the layer golden test

**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jihoon Lee <jhoon.it.lee@samsung.com>
packaging/unittest_layers_v2.tar.gz
test/input_gen/recorder.py
test/unittest/layers/layers_golden_tests.cpp

index 462e8c9..80cc067 100644 (file)
Binary files a/packaging/unittest_layers_v2.tar.gz and b/packaging/unittest_layers_v2.tar.gz differ
index 15b7270..0e793f2 100644 (file)
@@ -402,6 +402,10 @@ def record_single(layer, input_shape, test_name, call_args={}):
     inputs = _rand_like(input_shape)
 
     initial_weights = [tf.Variable(i) for i in layer.weights]
+
+    for _ in range(4):
+        layer.call(inputs, **call_args) # warm layer multiple times
+
     with tf.GradientTape(persistent=True) as tape:
         tape.watch(inputs)
         outputs = layer.call(inputs, **call_args)
index eef15e9..26a6f99 100644 (file)
@@ -227,6 +227,11 @@ TEST_P(LayerGoldenTest, run) {
   bool skip_calc_grad = shouldSkipCalcGrad();
   bool skip_calc_deriv = shouldSkipCalcDeriv();
 
+  for (int i = 0; i < 4; ++i) {
+    /// warm layer multiple times
+    layer->forwarding(rc, !shouldForwardWithInferenceMode());
+  }
+
   layer->forwarding(rc, !shouldForwardWithInferenceMode());
   if (!skip_calc_grad) {
     layer->calcGradient(rc);