From c6472fe4aae148fa2a66ad9408215845a2eefbbc Mon Sep 17 00:00:00 2001 From: chunseoklee Date: Wed, 25 Oct 2023 14:50:54 +0900 Subject: [PATCH] Fix coverity defects (#11759) - WID 1733311 - WID 1733310 - WID 1733309 - WID 1733308 ONE-DCO-1.0-Signed-off-by: Chunseok Lee --- onert-micro/luci-interpreter/pal/common/PALL2Pool2D.h | 1 + onert-micro/luci-interpreter/src/kernels/DepthToSpace.cpp | 1 + onert-micro/luci-interpreter/src/kernels/Softmax.cpp | 4 ++-- onert-micro/luci-interpreter/src/kernels/SpaceToDepth.cpp | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/onert-micro/luci-interpreter/pal/common/PALL2Pool2D.h b/onert-micro/luci-interpreter/pal/common/PALL2Pool2D.h index 9744dd02f1e..c58aae68c1e 100644 --- a/onert-micro/luci-interpreter/pal/common/PALL2Pool2D.h +++ b/onert-micro/luci-interpreter/pal/common/PALL2Pool2D.h @@ -66,6 +66,7 @@ inline void L2Pool(const PoolParams ¶ms, const luci_interpreter::RuntimeShap filter_count++; } } + assert(filter_count != 0); const float l2pool_result = std::sqrt(sum_squares / filter_count); output_data[offset(output_shape.dimsData(), batch, out_y, out_x, channel)] = activationFunctionWithMinMax(l2pool_result, params.float_activation_min, diff --git a/onert-micro/luci-interpreter/src/kernels/DepthToSpace.cpp b/onert-micro/luci-interpreter/src/kernels/DepthToSpace.cpp index c8ab72d2933..f10e1ed84ac 100644 --- a/onert-micro/luci-interpreter/src/kernels/DepthToSpace.cpp +++ b/onert-micro/luci-interpreter/src/kernels/DepthToSpace.cpp @@ -65,6 +65,7 @@ void execute_kernel_CircleDepthToSpace(const circle::Operator *cur_op, #ifndef DIS_FLOAT case DataType::FLOAT32: { + assert(block_size != 0); luci_interpreter_pal::DepthToSpace( block_size, kernels::getTensorRuntimeShape(kernel.input(), runtime_graph), kernels::getTensorData(runtime_graph->getDataByTensor(kernel.input())), diff --git a/onert-micro/luci-interpreter/src/kernels/Softmax.cpp b/onert-micro/luci-interpreter/src/kernels/Softmax.cpp index 1a1f42de889..5126e66aef5 100644 --- a/onert-micro/luci-interpreter/src/kernels/Softmax.cpp +++ b/onert-micro/luci-interpreter/src/kernels/Softmax.cpp @@ -86,7 +86,7 @@ void evalQuantize(const circle::Tensor *input, const circle::Tensor *output, if (Tensor::element_type(input) == DataType::S16) { - int left_shift = params.input_left_shift; + int left_shift = 0; double input_scale_beta_rescale = static_cast(Tensor::scale(input)) * static_cast(beta) / (10.0 / 65535.0); // scale the input_diff such that [-65535, 0] @@ -99,7 +99,7 @@ void evalQuantize(const circle::Tensor *input, const circle::Tensor *output, } else { - int left_shift = params.input_left_shift; + int left_shift = 0; preprocessSoftmaxScaling(static_cast(params.beta), static_cast(Tensor::scale(input)), kScaledDiffIntegerBits, ¶ms.input_multiplier, &left_shift); diff --git a/onert-micro/luci-interpreter/src/kernels/SpaceToDepth.cpp b/onert-micro/luci-interpreter/src/kernels/SpaceToDepth.cpp index 5e3f08dcdbb..cef886422ab 100644 --- a/onert-micro/luci-interpreter/src/kernels/SpaceToDepth.cpp +++ b/onert-micro/luci-interpreter/src/kernels/SpaceToDepth.cpp @@ -62,6 +62,7 @@ void execute_kernel_CircleSpaceToDepth(const circle::Operator *cur_op, #ifndef DIS_FLOAT case DataType::FLOAT32: { + assert(block_size != 0); luci_interpreter_pal::SpaceToDepth( block_size, kernels::getTensorRuntimeShape(kernel.input(), runtime_graph), kernels::getTensorData(runtime_graph->getDataByTensor(kernel.input())),