From 14196567235d3dbe9cda8a186c470cf290503c2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=B2=9C=EA=B5=90/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 5 Aug 2019 17:30:40 +0900 Subject: [PATCH] [moco-tf] Give chance for negative squeeze dim shape inference (#6206) Previously shape inference for TFSqueeze aborts when it encounters negative squeeze dimension. From this commit, shape inference, 'fix_shape()', for TFSqueeze just return false, not abort program to give a chance for later time, possibly after negative dimension resolved. Signed-off-by: Cheongyo Bahk --- compiler/moco-tf/src/Transforms/FixShapeTransform.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp index d1d39e0..149ef06 100644 --- a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp +++ b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp @@ -1209,22 +1209,18 @@ bool fix_shape(moco::tf::TFSqueeze *node) { uint32_t input_rank = input_tensor_shape.rank(); - auto is_valid_squeeze_dims = [&squeeze_dims, &input_rank]() { - if (squeeze_dims.size() >= input_rank) - return false; + // Sanity check for 'squeeze_dims' + { + assert(squeeze_dims.size() < input_rank); for (auto squeeze_dim : squeeze_dims) { // Negative squeeze dimensions should be resolve before if (squeeze_dim < 0) return false; - if (squeeze_dim >= (int64_t)input_rank) - return false; + assert(squeeze_dim < (int64_t)input_rank); } - return true; }; - assert(is_valid_squeeze_dims()); - // Remove squeeze dimensions only for (uint32_t axis = 0; axis < input_rank; ++axis) { -- 2.7.4