From a6d3314c0ad3781bfa00cbbcae725fb28ae559cb Mon Sep 17 00:00:00 2001 From: HyoungjooAhn Date: Fri, 14 Dec 2018 11:55:34 +0900 Subject: [PATCH] [bugfix] fix checking the dimension of input tensor logic is fixed to make it work properly for the any type of input dimension Signed-off-by: HyoungjooAhn --- gst/tensor_filter/tensor_filter_tensorflow_core.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gst/tensor_filter/tensor_filter_tensorflow_core.cc b/gst/tensor_filter/tensor_filter_tensorflow_core.cc index 5b1fa6d..79918ae 100644 --- a/gst/tensor_filter/tensor_filter_tensorflow_core.cc +++ b/gst/tensor_filter/tensor_filter_tensorflow_core.cc @@ -225,6 +225,7 @@ TFCore::getTensorTypeToTF (tensor_type tType) * -2 if the name of input tensors is not matched. * -3 if the type of input tensors is not matched. * -4 if the dimension of input tensors is not matched. + * -5 if the rank of input tensors exceeds our capacity NNS_TENSOR_RANK_LIMIT. */ int TFCore::inputTensorValidation (std::vector placeholders) @@ -275,11 +276,16 @@ TFCore::inputTensorValidation (std::vector placeholders) gchar **str_dims; str_dims = g_strsplit (shape_description.c_str(), ",", -1); - for (int j = 0; j < NNS_TENSOR_RANK_LIMIT; j++) { + uint len = g_strv_length (str_dims); + if (len > NNS_TENSOR_RANK_LIMIT){ + GST_ERROR ("The Rank of Input Tensor is not affordable. It's over our capacity.\n"); + return -5; + } + for (int j = 0; j < len; j++) { if (!strcmp (str_dims[j], "?")) continue; - if (inputTensorMeta.info[i].dimension[NNS_TENSOR_RANK_LIMIT - j - 1] != atoi (str_dims[j])){ + if (inputTensorMeta.info[i].dimension[len - j - 1] != atoi (str_dims[j])){ GST_ERROR ("Input Tensor is not valid: the dim of input tensor is different\n"); return -4; } -- 2.7.4