Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[core] Coverity fix issues gated delta net shape infer (#35046)

Pawel Raasz2ce9d9810dc1
diff --git a/src/core/shape_inference/include/gated_delta_net_shape_inference.hpp b/src/core/shape_inference/include/gated_delta_net_shape_inference.hpp
index f396b754b42..a54773d1852 100644
--- a/src/core/shape_inference/include/gated_delta_net_shape_inference.hpp
+++ b/src/core/shape_inference/include/gated_delta_net_shape_inference.hpp
@@ -4,15 +4,14 @@
#pragma once
-#include "openvino/op/util/binary_elementwise_arithmetic.hpp"
-#include "openvino/op/util/binary_elementwise_comparison.hpp"
-#include "openvino/op/util/binary_elementwise_logical.hpp"
+#include "openvino/op/gated_delta_net.hpp"
#include "utils.hpp"
namespace ov::op::internal {
-template <class OpType, class T, class TRShape = result_shape_t<T>>
-std::vector<TRShape> shape_infer(const OpType* op, const std::vector<T>& input_shapes) {
- NODE_SHAPE_INFER_CHECK(op, input_shapes, input_shapes.size() == 6, "Incorrect number of input for GatedDeltaNet");
+
+template <class T, class TRShape = result_shape_t<T>>
+std::vector<TRShape> shape_infer(const GatedDeltaNet* op, const std::vector<T>& input_shapes) {
+ NODE_VALIDATION_CHECK(op, input_shapes.size() == 6);
// batch, seq_len, head_num, head_size
const auto& query_ps = input_shapes[0];
@@ -22,13 +21,13 @@ std::vector<TRShape> shape_infer(const OpType* op, const std::vector<T>& input_s
const auto& gate_ps = input_shapes[4];
const auto& beta_ps = input_shapes[5];
- const auto q_head_num = query_ps[2];
- const auto k_head_num = key_ps[2];
- const auto v_head_num = value_ps[2];
+ const auto& q_head_num = query_ps[2];
+ const auto& k_head_num = key_ps[2];
+ const auto& v_head_num = value_ps[2];
- const auto k_head_size = key_ps[3];
- const auto q_head_size = query_ps[3];
- const auto v_head_size = value_ps[3];
+ const auto& k_head_size = key_ps[3];
+ const auto& q_head_size = query_ps[3];
+ const auto& v_head_size = value_ps[3];
NODE_SHAPE_INFER_CHECK(op,
input_shapes,
@@ -36,8 +35,7 @@ std::vector<TRShape> shape_infer(const OpType* op, const std::vector<T>& input_s
"The number of heads in query key and value should be the same, but got ",
q_head_num,
" and ",
- k_head_num,
- ".");
+ k_head_num);
NODE_SHAPE_INFER_CHECK(op,
input_shapes,
@@ -45,11 +43,10 @@ std::vector<TRShape> shape_infer(const OpType* op, const std::vector<T>& input_s
"The head size in key and query should be the same, but got ",
k_head_size,
" and ",
- q_head_size,
- ".");
+ q_head_size);
- const auto gate_head_num = gate_ps[2];
- const auto beta_head_num = beta_ps[2];
+ const auto& gate_head_num = gate_ps[2];
+ const auto& beta_head_num = beta_ps[2];
NODE_SHAPE_INFER_CHECK(op,
input_shapes,
@@ -57,29 +54,26 @@ std::vector<TRShape> shape_infer(const OpType* op, const std::vector<T>& input_s
"The number of heads in gate, beta, and query should be the same, but got ",
gate_head_num,
" and ",
- beta_head_num,
- ".");
+ beta_head_num);
// [batch, v_head_nums, k_head_size, v_head_size]
- const auto state_head_num = state_ps[1];
- const auto state_hidden_size_0 = state_ps[2];
- const auto state_hidden_size_1 = state_ps[3];
+ const auto& state_head_num = state_ps[1];
+ const auto& state_hidden_size_0 = state_ps[2];
+ const auto& state_hidden_size_1 = state_ps[3];
NODE_SHAPE_INFER_CHECK(op,
input_shapes,
state_head_num.compatible(v_head_num),
"The number of heads in recurrent_state and value should be the same, but got ",
state_head_num,
" and ",
- v_head_num,
- ".");
+ v_head_num);
NODE_SHAPE_INFER_CHECK(op,
input_shapes,
state_hidden_size_0.compatible(k_head_size),
"The dim at shape[-2] of recurrent_state and head size of key should be the same, but got ",
state_hidden_size_0,
" and ",
- k_head_size,
- ".");
+ k_head_size);
NODE_SHAPE_INFER_CHECK(
op,
input_shapes,
@@ -87,11 +81,9 @@ std::vector<TRShape> shape_infer(const OpType* op, const std::vector<T>& input_s
"The dim at shape[-1] of recurrent_state and head size of value should be the same, but got ",
state_hidden_size_1,
" and ",
- v_head_size,
- ".");
+ v_head_size);
// output has the same shape and type as input value, output state has the same shape and type as input
// recurrent_state
- auto output_shapes = std::vector<TRShape>{value_ps, state_ps};
- return output_shapes;
+ return {value_ps, state_ps};
}
} // namespace ov::op::internal