diff options
author | Inki Dae <inki.dae@samsung.com> | 2024-10-16 15:03:00 +0900 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2024-10-22 07:55:31 +0900 |
commit | 51f9d139f58905a0eba0a96052f91e8da049cdc4 (patch) | |
tree | 5b8b590d015ffe8f5dba59101c8ef5f9e650a4b2 | |
parent | ff5d0a0c11ba926fc263e95e756f6ced582c8f95 (diff) | |
download | inference-engine-mlapi-tizen.tar.gz inference-engine-mlapi-tizen.tar.bz2 inference-engine-mlapi-tizen.zip |
Fix a bug to output tensor size calculationtizen
[Version] : 0.4.11
[Issue type] : bug fix
Fix a bug to output tensor size calculation.
output tensor dimension array can have 0 so output tensor
size can be 0, and it results in an exception error.
Calculate the output tensor size with valid dimension values only.
Change-Id: Ic7b17909fb4c67c7da9ff02175a2bbee4ca13388
Signed-off-by: Inki Dae <inki.dae@samsung.com>
-rw-r--r-- | packaging/inference-engine-mlapi.spec | 2 | ||||
-rw-r--r-- | src/inference_engine_mlapi.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/packaging/inference-engine-mlapi.spec b/packaging/inference-engine-mlapi.spec index d2ea2d9..674b398 100644 --- a/packaging/inference-engine-mlapi.spec +++ b/packaging/inference-engine-mlapi.spec @@ -1,6 +1,6 @@ Name: inference-engine-mlapi Summary: ML Single API backend of NNStreamer for MediaVision -Version: 0.4.10 +Version: 0.4.11 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/inference_engine_mlapi.cpp b/src/inference_engine_mlapi.cpp index 7fbf997..983301d 100644 --- a/src/inference_engine_mlapi.cpp +++ b/src/inference_engine_mlapi.cpp @@ -617,7 +617,6 @@ namespace MLAPIImpl inference_engine_tensor_info tensor_info; ml_tensor_type_e out_type; unsigned int out_dim[ML_TENSOR_RANK_LIMIT]; - size_t out_size = 1; ret = ml_tensors_info_get_tensor_type(mOutputInfoHandle, output.second, &out_type); if (ret != ML_ERROR_NONE) { @@ -649,8 +648,6 @@ namespace MLAPIImpl LOGI("Output tensor dimension:"); for (unsigned int shape_idx = 0; shape_idx < MAX_TENSOR_DIMENSION_SIZE; ++shape_idx) { - out_size *= static_cast<size_t>(out_dim[shape_idx]); - if (out_dim[shape_idx] == 1 && shape_size == 0) shape_size = shape_idx; @@ -660,8 +657,11 @@ namespace MLAPIImpl LOGI("Shape size of output tensor : %d", shape_size); LOGI("Reversed output tensor dimension:"); + size_t out_size = 1; + // Reverse shape order. for (int idx = shape_size; idx >= 0; --idx) { + out_size *= static_cast<size_t>(out_dim[idx]); tensor_info.shape.push_back(out_dim[idx]); LOGI("%u", out_dim[idx]); } |