From 02cabcda3ccee20ace969c6bde328ad86fcbfe17 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 11 Jan 2022 17:28:50 +0300 Subject: [PATCH] Fixed coverity issues for core componets (#9558) * Fixed coverity issues for core componets * Fixed some tests --- src/core/include/openvino/op/batch_norm.hpp | 4 ++-- src/core/include/openvino/op/bucketize.hpp | 2 +- src/core/include/openvino/op/constant.hpp | 2 +- .../include/openvino/op/ctc_greedy_decoder.hpp | 2 +- .../openvino/op/ctc_greedy_decoder_seq_len.hpp | 2 +- .../openvino/op/deformable_convolution.hpp | 2 +- .../openvino/op/deformable_psroi_pooling.hpp | 4 ++-- src/core/include/openvino/op/elu.hpp | 2 +- .../op/experimental_detectron_topkrois.hpp | 2 +- .../include/openvino/op/extractimagepatches.hpp | 2 +- .../include/openvino/op/gather_elements.hpp | 2 +- src/core/include/openvino/op/lstm_sequence.hpp | 2 +- src/core/include/openvino/op/pad.hpp | 2 +- src/core/include/openvino/op/roi_pooling.hpp | 2 +- src/core/include/openvino/op/round.hpp | 2 +- .../detection_output_shape_inference.hpp | 4 ++-- .../include/einsum_shape_inference.hpp | 2 +- .../include/lstm_cell_shape_inference.hpp | 17 ++++++++++------- .../include/proposal_shape_inference.hpp | 2 +- .../include/roi_align_shape_inference.hpp | 4 ++-- src/frontends/common/src/manager.cpp | 2 +- 21 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/core/include/openvino/op/batch_norm.hpp b/src/core/include/openvino/op/batch_norm.hpp index 6f53117034c..207057d6a0a 100644 --- a/src/core/include/openvino/op/batch_norm.hpp +++ b/src/core/include/openvino/op/batch_norm.hpp @@ -48,7 +48,7 @@ private: static constexpr size_t INPUT_MEAN = 3; static constexpr size_t INPUT_VARIANCE = 4; - double m_epsilon; + double m_epsilon{0}; }; } // namespace v0 namespace v5 { @@ -89,7 +89,7 @@ private: static constexpr size_t INPUT_MEAN = 3; static constexpr size_t INPUT_VARIANCE = 4; - double m_epsilon; + double m_epsilon{0}; }; } // namespace v5 } // namespace op diff --git a/src/core/include/openvino/op/bucketize.hpp b/src/core/include/openvino/op/bucketize.hpp index dde19fb10b9..d7602328c5e 100644 --- a/src/core/include/openvino/op/bucketize.hpp +++ b/src/core/include/openvino/op/bucketize.hpp @@ -51,7 +51,7 @@ public: private: element::Type m_output_type; - bool m_with_right_bound; + bool m_with_right_bound{true}; }; } // namespace v3 } // namespace op diff --git a/src/core/include/openvino/op/constant.hpp b/src/core/include/openvino/op/constant.hpp index 7591182567d..2d524c4fe80 100644 --- a/src/core/include/openvino/op/constant.hpp +++ b/src/core/include/openvino/op/constant.hpp @@ -709,7 +709,7 @@ private: element::Type m_element_type; Shape m_shape{}; std::shared_ptr m_data; - bool m_all_elements_bitwise_identical; + bool m_all_elements_bitwise_identical = false; bool m_alloc_buffer_on_visit_attributes = true; }; } // namespace v0 diff --git a/src/core/include/openvino/op/ctc_greedy_decoder.hpp b/src/core/include/openvino/op/ctc_greedy_decoder.hpp index 1ebf2c62bc1..db618afad59 100644 --- a/src/core/include/openvino/op/ctc_greedy_decoder.hpp +++ b/src/core/include/openvino/op/ctc_greedy_decoder.hpp @@ -31,7 +31,7 @@ public: } private: - bool m_ctc_merge_repeated; + bool m_ctc_merge_repeated{true}; }; } // namespace v0 } // namespace op diff --git a/src/core/include/openvino/op/ctc_greedy_decoder_seq_len.hpp b/src/core/include/openvino/op/ctc_greedy_decoder_seq_len.hpp index dc40be35b49..f43edd76c59 100644 --- a/src/core/include/openvino/op/ctc_greedy_decoder_seq_len.hpp +++ b/src/core/include/openvino/op/ctc_greedy_decoder_seq_len.hpp @@ -92,7 +92,7 @@ public: } private: - bool m_merge_repeated; + bool m_merge_repeated{true}; element::Type m_classes_index_type{element::i32}; element::Type m_sequence_length_type{element::i32}; }; diff --git a/src/core/include/openvino/op/deformable_convolution.hpp b/src/core/include/openvino/op/deformable_convolution.hpp index c20d9eb6033..23987fa02cd 100644 --- a/src/core/include/openvino/op/deformable_convolution.hpp +++ b/src/core/include/openvino/op/deformable_convolution.hpp @@ -166,7 +166,7 @@ public: } private: - bool m_bilinear_interpolation_pad; + bool m_bilinear_interpolation_pad{false}; }; } // namespace v8 } // namespace op diff --git a/src/core/include/openvino/op/deformable_psroi_pooling.hpp b/src/core/include/openvino/op/deformable_psroi_pooling.hpp index a50e1b79abc..6b4b3f8516a 100644 --- a/src/core/include/openvino/op/deformable_psroi_pooling.hpp +++ b/src/core/include/openvino/op/deformable_psroi_pooling.hpp @@ -94,8 +94,8 @@ public: } private: - int64_t m_output_dim; - float m_spatial_scale; + int64_t m_output_dim{0}; + float m_spatial_scale{0}; int64_t m_group_size = 1; std::string m_mode = "bilinear_deformable"; int64_t m_spatial_bins_x = 1; diff --git a/src/core/include/openvino/op/elu.hpp b/src/core/include/openvino/op/elu.hpp index aa50bcff2ee..f09be3f0baf 100644 --- a/src/core/include/openvino/op/elu.hpp +++ b/src/core/include/openvino/op/elu.hpp @@ -35,7 +35,7 @@ public: } private: - double m_alpha; + double m_alpha{0}; }; } // namespace v0 } // namespace op diff --git a/src/core/include/openvino/op/experimental_detectron_topkrois.hpp b/src/core/include/openvino/op/experimental_detectron_topkrois.hpp index 72f173b280d..cb48b61e220 100644 --- a/src/core/include/openvino/op/experimental_detectron_topkrois.hpp +++ b/src/core/include/openvino/op/experimental_detectron_topkrois.hpp @@ -39,7 +39,7 @@ public: } private: - size_t m_max_rois; + size_t m_max_rois{0}; template friend void shape_infer(ExperimentalDetectronTopKROIs* op, diff --git a/src/core/include/openvino/op/extractimagepatches.hpp b/src/core/include/openvino/op/extractimagepatches.hpp index 20ed6681dbb..f3c7c5a939e 100644 --- a/src/core/include/openvino/op/extractimagepatches.hpp +++ b/src/core/include/openvino/op/extractimagepatches.hpp @@ -64,7 +64,7 @@ private: Shape m_patch_sizes; Strides m_patch_movement_strides; Shape m_patch_selection_rates; - PadType m_padding; + PadType m_padding{PadType::EXPLICIT}; template friend void shape_infer(const ExtractImagePatches* op, const std::vector& input_shapes, diff --git a/src/core/include/openvino/op/gather_elements.hpp b/src/core/include/openvino/op/gather_elements.hpp index 2ac8546d5b0..9c2579d21ce 100644 --- a/src/core/include/openvino/op/gather_elements.hpp +++ b/src/core/include/openvino/op/gather_elements.hpp @@ -33,7 +33,7 @@ public: } private: - int64_t m_axis; + int64_t m_axis{0}; template void friend shape_infer(const GatherElements* op, const std::vector& input_shapes, diff --git a/src/core/include/openvino/op/lstm_sequence.hpp b/src/core/include/openvino/op/lstm_sequence.hpp index 4232db13434..39505cfb597 100644 --- a/src/core/include/openvino/op/lstm_sequence.hpp +++ b/src/core/include/openvino/op/lstm_sequence.hpp @@ -191,7 +191,7 @@ public: } private: - direction m_direction; + direction m_direction{direction::FORWARD}; }; } // namespace v5 } // namespace op diff --git a/src/core/include/openvino/op/pad.hpp b/src/core/include/openvino/op/pad.hpp index 2df1d98f2f6..9d1cc9f68ac 100644 --- a/src/core/include/openvino/op/pad.hpp +++ b/src/core/include/openvino/op/pad.hpp @@ -74,7 +74,7 @@ public: bool has_evaluate() const override; private: - PadMode m_pad_mode; + PadMode m_pad_mode{PadMode::CONSTANT}; bool evaluate_pad(const HostTensorVector& outputs, const HostTensorVector& inputs) const; }; } // namespace v1 diff --git a/src/core/include/openvino/op/roi_pooling.hpp b/src/core/include/openvino/op/roi_pooling.hpp index 5e9954ebc0d..39cffaf482a 100644 --- a/src/core/include/openvino/op/roi_pooling.hpp +++ b/src/core/include/openvino/op/roi_pooling.hpp @@ -45,7 +45,7 @@ public: private: Shape m_output_size{0, 0}; - float m_spatial_scale; + float m_spatial_scale{0}; std::string m_method = "max"; }; } // namespace v0 diff --git a/src/core/include/openvino/op/round.hpp b/src/core/include/openvino/op/round.hpp index b3b5882af93..3fb60db1b8e 100644 --- a/src/core/include/openvino/op/round.hpp +++ b/src/core/include/openvino/op/round.hpp @@ -44,7 +44,7 @@ public: } private: - RoundMode m_mode; + RoundMode m_mode{RoundMode::HALF_TO_EVEN}; }; } // namespace v5 } // namespace op diff --git a/src/core/shape_inference/include/detection_output_shape_inference.hpp b/src/core/shape_inference/include/detection_output_shape_inference.hpp index df7e1e4a62e..2cf830f8377 100644 --- a/src/core/shape_inference/include/detection_output_shape_inference.hpp +++ b/src/core/shape_inference/include/detection_output_shape_inference.hpp @@ -160,7 +160,7 @@ void shape_infer_base(const DetectionOutputBase* op, if (!num_prior_boxes && box_logits_pshape[1].is_static()) { auto box_logits_pshape_2nd_dim = box_logits_pshape[1].get_length(); NODE_VALIDATION_CHECK(op, - (box_logits_pshape_2nd_dim % (num_loc_classes * 4)) == 0, + num_loc_classes != 0 && (box_logits_pshape_2nd_dim % (num_loc_classes * 4)) == 0, "Box logits' second dimension must be a multiply of num_loc_classes * 4 (", num_loc_classes * 4, "). Current value is: ", @@ -340,4 +340,4 @@ void shape_infer(const DetectionOutput* op, const std::vector& input_shapes, } // namespace v8 } // namespace op -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/core/shape_inference/include/einsum_shape_inference.hpp b/src/core/shape_inference/include/einsum_shape_inference.hpp index 58342148444..fedfc54a5fb 100644 --- a/src/core/shape_inference/include/einsum_shape_inference.hpp +++ b/src/core/shape_inference/include/einsum_shape_inference.hpp @@ -71,7 +71,7 @@ void shape_infer(const Einsum* op, const std::vector& input_shapes, std::vect label_to_shape[label].compatible(T{pshape[label_ind]}), "Different input dimensions indicated by the same labels for Einsum " "must be compatible."); - T::merge_into(label_to_shape[label], T{pshape[dim_ind]}); + OPENVINO_ASSERT(T::merge_into(label_to_shape[label], T{pshape[dim_ind]})); } ++dim_ind; } diff --git a/src/core/shape_inference/include/lstm_cell_shape_inference.hpp b/src/core/shape_inference/include/lstm_cell_shape_inference.hpp index 771075ce8a6..7c51a86c03f 100644 --- a/src/core/shape_inference/include/lstm_cell_shape_inference.hpp +++ b/src/core/shape_inference/include/lstm_cell_shape_inference.hpp @@ -3,6 +3,7 @@ // #pragma once #include + #include "utils.hpp" namespace ov { @@ -16,7 +17,7 @@ void lstm_shape_infer(const OpsType* op, using DimType = typename std::iterator_traits::value_type; enum { X, initial_hidden_state, initial_cell_state, W, R, B }; std::vector input_rank_static(6, false); - bool all_rank_dynamic = false; + bool all_rank_dynamic = true; bool all_rank_static = true; // Prepare OutShape auto& hidden_shape = output_shapes[0]; @@ -43,7 +44,7 @@ void lstm_shape_infer(const OpsType* op, bool is_hidden_init = false; // deduce batch/hidden_size - for (size_t i = 0; i < input_shapes.size() && i < 6 ; i++) { + for (size_t i = 0; i < input_shapes.size() && i < 6; i++) { const auto& input = input_shapes[i]; if (input_rank_static[i]) { // batch could be deduced from x, cell_state or hidden_state @@ -94,7 +95,9 @@ void lstm_shape_infer(const OpsType* op, } else { NODE_VALIDATION_CHECK( op, - DimType::merge(output_hidden_size, output_hidden_size, input[0].get_length() / gates_count), + DimType::merge(output_hidden_size, + output_hidden_size, + input[0].get_length() / gates_count), "Parameter hidden_size not matched for W, R, B, initial_hidden_state and " "initial_cell_state " "inputs."); @@ -115,7 +118,9 @@ void lstm_shape_infer(const OpsType* op, } else { NODE_VALIDATION_CHECK( op, - DimType::merge(output_hidden_size, output_hidden_size, input[0].get_length() / gates_count), + DimType::merge(output_hidden_size, + output_hidden_size, + input[0].get_length() / gates_count), "Parameter hidden_size not matched for W, R, B, initial_hidden_state and " "initial_cell_state " "inputs."); @@ -140,9 +145,7 @@ void lstm_shape_infer(const OpsType* op, // Check peepholes if (input_shapes.size() == 7) { const auto& p_pshape = input_shapes[6]; - NODE_VALIDATION_CHECK(op, - (p_pshape.rank().compatible(1)), - "LSTMCell input tensor P shall have dimension 1D."); + NODE_VALIDATION_CHECK(op, (p_pshape.rank().compatible(1)), "LSTMCell input tensor P shall have dimension 1D."); } // check input size diff --git a/src/core/shape_inference/include/proposal_shape_inference.hpp b/src/core/shape_inference/include/proposal_shape_inference.hpp index 25375e62e8c..0b9abcb7a38 100644 --- a/src/core/shape_inference/include/proposal_shape_inference.hpp +++ b/src/core/shape_inference/include/proposal_shape_inference.hpp @@ -66,7 +66,7 @@ void infer_prop_shape(const OpType* op, auto out_dim = DimType{}; if (class_probs_ps.rank().is_static() && bbox_deltas_ps.rank().is_static()) { - DimType::merge(out_dim, class_probs_ps[0], bbox_deltas_ps[0]); + OPENVINO_ASSERT(DimType::merge(out_dim, class_probs_ps[0], bbox_deltas_ps[0])); } else if (class_probs_ps.rank().is_static()) { out_dim = class_probs_ps[0]; } else if (bbox_deltas_ps.rank().is_static()) { diff --git a/src/core/shape_inference/include/roi_align_shape_inference.hpp b/src/core/shape_inference/include/roi_align_shape_inference.hpp index 820ece21bd7..9fbe6218b05 100644 --- a/src/core/shape_inference/include/roi_align_shape_inference.hpp +++ b/src/core/shape_inference/include/roi_align_shape_inference.hpp @@ -62,7 +62,7 @@ void shape_infer(const ov::op::v3::ROIAlign* op, const std::vector& input_sha // if either of those 2 dimensions is static its value will be used // for the first dimension of the output shape - 'NUM_ROIS' if (rois_ps_rank.is_static() && batch_indices_ps_rank.is_static()) { - DimType::merge(output_shape[0], batch_indices_ps[0], rois_ps[0]); + OPENVINO_ASSERT(DimType::merge(output_shape[0], batch_indices_ps[0], rois_ps[0])); } else if (rois_ps_rank.is_static()) { output_shape[0] = rois_ps[0]; } else if (batch_indices_ps_rank.is_static()) { @@ -74,4 +74,4 @@ void shape_infer(const ov::op::v3::ROIAlign* op, const std::vector& input_sha } // namespace v3 } // namespace op -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/frontends/common/src/manager.cpp b/src/frontends/common/src/manager.cpp index 263c2ba7e16..c0858b50840 100644 --- a/src/frontends/common/src/manager.cpp +++ b/src/frontends/common/src/manager.cpp @@ -53,7 +53,7 @@ public: } // Load plugins until we found the right one for (auto& plugin : m_plugins) { - plugin.load(); + OPENVINO_ASSERT(plugin.load(), "Cannot load frontend ", plugin.get_name_from_file()); if (plugin.get_creator().m_name == framework) { auto fe_obj = std::make_shared(); fe_obj->m_shared_object = plugin.get_so_pointer();