From 97a4b944b1d11aee1e7cd1e59a0c5bb9660ebe7b Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 10 Nov 2021 06:17:43 +0300 Subject: [PATCH] Fixed coverity issues (#8448) --- ngraph/core/include/openvino/op/matmul.hpp | 4 ++-- ngraph/core/include/openvino/op/shuffle_channels.hpp | 4 ++-- ngraph/frontend/onnx/frontend/src/edge_mapper.cpp | 2 +- ngraph/frontend/onnx/frontend/src/editor.cpp | 7 +++++-- .../frontend/onnx/frontend/src/utils/random_normal.cpp | 10 ++++++++-- ngraph/frontend/paddlepaddle/src/op/fill_any_like.cpp | 6 +++++- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ngraph/core/include/openvino/op/matmul.hpp b/ngraph/core/include/openvino/op/matmul.hpp index c14f2a366ad..5026ebbc365 100644 --- a/ngraph/core/include/openvino/op/matmul.hpp +++ b/ngraph/core/include/openvino/op/matmul.hpp @@ -50,8 +50,8 @@ public: } private: - bool m_transpose_a; - bool m_transpose_b; + bool m_transpose_a{false}; + bool m_transpose_b{false}; }; } // namespace v0 } // namespace op diff --git a/ngraph/core/include/openvino/op/shuffle_channels.hpp b/ngraph/core/include/openvino/op/shuffle_channels.hpp index f8318d2bce5..3a231a9c266 100644 --- a/ngraph/core/include/openvino/op/shuffle_channels.hpp +++ b/ngraph/core/include/openvino/op/shuffle_channels.hpp @@ -49,8 +49,8 @@ public: private: bool evaluate_shuffle_channels(const HostTensorVector& outputs, const HostTensorVector& inputs) const; - int64_t m_axis; - int64_t m_group; + int64_t m_axis{1}; + int64_t m_group{1}; }; } // namespace v0 } // namespace op diff --git a/ngraph/frontend/onnx/frontend/src/edge_mapper.cpp b/ngraph/frontend/onnx/frontend/src/edge_mapper.cpp index 4602a2db623..3cec8738966 100644 --- a/ngraph/frontend/onnx/frontend/src/edge_mapper.cpp +++ b/ngraph/frontend/onnx/frontend/src/edge_mapper.cpp @@ -150,7 +150,7 @@ InputEdge onnx_editor::EdgeMapper::find_input_edge(const EditorNode& node, const } OutputEdge onnx_editor::EdgeMapper::find_output_edge(const EditorNode& node, const EditorOutput& out) const { - int node_index = node_index = node.m_node_index; + int node_index = node.m_node_index; if (node_index == -1) { // the node index is not provided // identification can be both based on node name and output name (if the node index is not provided) const auto& node_indexes = find_node_indexes(node.m_node_name, node.m_output_name); diff --git a/ngraph/frontend/onnx/frontend/src/editor.cpp b/ngraph/frontend/onnx/frontend/src/editor.cpp index 641f43b144a..907e92fa378 100644 --- a/ngraph/frontend/onnx/frontend/src/editor.cpp +++ b/ngraph/frontend/onnx/frontend/src/editor.cpp @@ -183,8 +183,11 @@ public: m_infer_shapes_was_run = true; } ~InferShapesAutoRelease() { - if (m_infer_shapes_was_run) { - m_model_proto->mutable_graph()->clear_value_info(); + try { + if (m_infer_shapes_was_run) { + m_model_proto->mutable_graph()->clear_value_info(); + } + } catch (...) { } } diff --git a/ngraph/frontend/onnx/frontend/src/utils/random_normal.cpp b/ngraph/frontend/onnx/frontend/src/utils/random_normal.cpp index de6c3ddcfab..66cad4983fc 100644 --- a/ngraph/frontend/onnx/frontend/src/utils/random_normal.cpp +++ b/ngraph/frontend/onnx/frontend/src/utils/random_normal.cpp @@ -4,6 +4,8 @@ #include "random_normal.hpp" +#include + #include "default_opset.hpp" #include "ngraph/opsets/opset8.hpp" @@ -16,6 +18,10 @@ OutputVector make_random_normal(const Output& shape, float mean, float scale, float seed) { + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution distrib(0, 9999); + // We start by generating two random series from a uniform distribution const uint64_t global_seed = 0; @@ -23,8 +29,8 @@ OutputVector make_random_normal(const Output& shape, const auto op_seed = static_cast(seed * 1000); // We need to use two op_seeds to make sure we get different results for two RandomUniform series - const uint64_t seed_1 = (op_seed == 0 ? rand() % 10000 : op_seed); - const uint64_t seed_2 = (op_seed == 0 ? rand() % 10000 : op_seed + 10000); + const uint64_t seed_1 = (op_seed == 0 ? distrib(gen) : op_seed); + const uint64_t seed_2 = (op_seed == 0 ? distrib(gen) : op_seed + 10000); const auto min_val = default_opset::Constant::create(target_type, Shape{1}, {0}); const auto max_val = default_opset::Constant::create(target_type, Shape{1}, {1}); diff --git a/ngraph/frontend/paddlepaddle/src/op/fill_any_like.cpp b/ngraph/frontend/paddlepaddle/src/op/fill_any_like.cpp index 2a7e9f3facd..8cc57de3c10 100644 --- a/ngraph/frontend/paddlepaddle/src/op/fill_any_like.cpp +++ b/ngraph/frontend/paddlepaddle/src/op/fill_any_like.cpp @@ -18,7 +18,11 @@ NamedOutputs fill_any_like(const NodeContext& node) { // when type does not define, use the input type dtype = x.get_element_type(); } - const auto supported_type = {element::i32, element::i64, element::f16, element::f32, element::f64}; + const std::vector supported_type = {element::i32, + element::i64, + element::f16, + element::f32, + element::f64}; const bool valid_type = std::any_of(supported_type.begin(), supported_type.end(), [dtype](const element::Type& type) { return dtype == type;