[moco-tf] Reshape shape inference rejects dynamic case (#6013)
author박천교/On-Device Lab(SR)/Engineer/삼성전자 <ch.bahk@samsung.com>
Tue, 30 Jul 2019 07:55:32 +0000 (16:55 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 30 Jul 2019 07:55:32 +0000 (16:55 +0900)
Previously shape inference stage for TFReshape node was erroneously
done for wildcard dimension as well. This commit fixes this bug to
reject dynamic reshape case.

Signed-off-by: Cheongyo Bahk <ch.bahk@samsung.com>
compiler/moco-tf/src/Transforms/FixShapeTransform.cpp

index 23275df..72cb3e4 100644 (file)
@@ -990,7 +990,14 @@ bool fix_shape(moco::tf::TFReshape *node)
   shape_data.rank(shape_rank);
   for (uint32_t axis = 0; axis < shape_rank; ++axis)
   {
-    shape_data.dim(axis) = const_shape_input->at<loco::DataType::S32>(axis);
+    auto shape_dim = const_shape_input->at<loco::DataType::S32>(axis);
+    if (shape_dim == -1)
+    {
+      // Reshape's new shape has wildcard dimension, i.e. dynamic reshape
+      return false;
+    }
+    assert(shape_dim >= 1);
+    shape_data.dim(axis) = shape_dim;
   }
 
   // TODO Compare 'tensor' input and validate coherency?