Skip to content

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

[Core/Ref][Tmpl plugin] DetectionOutput: Resolve coverity issues (#30547)

Tomasz Jankowski94e56480e513
diff --git a/src/core/reference/include/openvino/reference/detection_output.hpp b/src/core/reference/include/openvino/reference/detection_output.hpp
index 20d8bfc69fd..2378db2288f 100644
--- a/src/core/reference/include/openvino/reference/detection_output.hpp
+++ b/src/core/reference/include/openvino/reference/detection_output.hpp
@@ -133,7 +133,7 @@ private:
for (int j = 0; j < 4; ++j) {
var[j] = (priorVar[start_idx + j]);
}
- currPrVar.push_back(var);
+ currPrVar.push_back(std::move(var));
}
}
priorData += off;
@@ -538,9 +538,9 @@ public:
int idx = scoreIndexPairs[j].second.second;
newIndices[label].push_back(idx);
}
- allIndices.push_back(newIndices);
+ allIndices.push_back(std::move(newIndices));
} else {
- allIndices.push_back(indices);
+ allIndices.push_back(std::move(indices));
}
}
diff --git a/src/plugins/template/backend/ops/detection_output.cpp b/src/plugins/template/backend/ops/detection_output.cpp
index e9326a9d985..50c4d402b41 100644
--- a/src/plugins/template/backend/ops/detection_output.cpp
+++ b/src/plugins/template/backend/ops/detection_output.cpp
@@ -71,13 +71,9 @@ template <>
bool evaluate_node<ov::op::v0::DetectionOutput>(std::shared_ptr<ov::Node> node,
ov::TensorVector& outputs,
const ov::TensorVector& inputs) {
- auto element_type = node->get_output_element_type(0);
- if (ov::is_type<ov::op::v1::Select>(node) || ov::is_type<ov::op::util::BinaryElementwiseComparison>(node))
- element_type = node->get_input_element_type(1);
+ const auto& element_type = node->get_output_element_type(0);
switch (element_type) {
- case ov::element::boolean:
- return evaluate<ov::element::boolean>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
case ov::element::bf16:
return evaluate<ov::element::bf16>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
case ov::element::f16:
@@ -86,28 +82,6 @@ bool evaluate_node<ov::op::v0::DetectionOutput>(std::shared_ptr<ov::Node> node,
return evaluate<ov::element::f64>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
case ov::element::f32:
return evaluate<ov::element::f32>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::i4:
- return evaluate<ov::element::i4>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::i8:
- return evaluate<ov::element::i8>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::i16:
- return evaluate<ov::element::i16>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::i32:
- return evaluate<ov::element::i32>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::i64:
- return evaluate<ov::element::i64>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::u1:
- return evaluate<ov::element::u1>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::u4:
- return evaluate<ov::element::u4>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::u8:
- return evaluate<ov::element::u8>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::u16:
- return evaluate<ov::element::u16>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::u32:
- return evaluate<ov::element::u32>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
- case ov::element::u64:
- return evaluate<ov::element::u64>(ov::as_type_ptr<ov::op::v0::DetectionOutput>(node), outputs, inputs);
default:
OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()");
}
@@ -117,13 +91,9 @@ template <>
bool evaluate_node<ov::op::v8::DetectionOutput>(std::shared_ptr<ov::Node> node,
ov::TensorVector& outputs,
const ov::TensorVector& inputs) {
- auto element_type = node->get_output_element_type(0);
- if (ov::is_type<ov::op::v1::Select>(node) || ov::is_type<ov::op::util::BinaryElementwiseComparison>(node))
- element_type = node->get_input_element_type(1);
+ const auto& element_type = node->get_output_element_type(0);
switch (element_type) {
- case ov::element::boolean:
- return evaluate<ov::element::boolean>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
case ov::element::bf16:
return evaluate<ov::element::bf16>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
case ov::element::f16:
@@ -132,28 +102,6 @@ bool evaluate_node<ov::op::v8::DetectionOutput>(std::shared_ptr<ov::Node> node,
return evaluate<ov::element::f64>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
case ov::element::f32:
return evaluate<ov::element::f32>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::i4:
- return evaluate<ov::element::i4>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::i8:
- return evaluate<ov::element::i8>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::i16:
- return evaluate<ov::element::i16>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::i32:
- return evaluate<ov::element::i32>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::i64:
- return evaluate<ov::element::i64>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::u1:
- return evaluate<ov::element::u1>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::u4:
- return evaluate<ov::element::u4>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::u8:
- return evaluate<ov::element::u8>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::u16:
- return evaluate<ov::element::u16>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::u32:
- return evaluate<ov::element::u32>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
- case ov::element::u64:
- return evaluate<ov::element::u64>(ov::as_type_ptr<ov::op::v8::DetectionOutput>(node), outputs, inputs);
default:
OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()");
}