Skip to content

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

[Transformations] Fix exception when converting precision on Read_Value node without inputs. (#26829)

Luwei Zhoue582f61a65ba
diff --git a/src/common/transformations/src/transformations/convert_precision.cpp b/src/common/transformations/src/transformations/convert_precision.cpp
index 54fb6a972b7..6f5166dfd26 100644
--- a/src/common/transformations/src/transformations/convert_precision.cpp
+++ b/src/common/transformations/src/transformations/convert_precision.cpp
@@ -29,7 +29,7 @@ bool fuse_type_to_parameter(const std::shared_ptr<ov::Node>& node,
bool convert_input_precision);
// this function inserts Convert operations to 'data' input and outputs of `node`
-// to execute 'node' with the original type.
+// to execute 'node' with the original type. This function supports nodes with single output.
bool wrap_into_original_type(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions);
bool store_original_type_as_attribute(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions);
@@ -622,17 +622,20 @@ bool wrap_into_original_type(const std::shared_ptr<ov::Node>& node, const precis
const auto& to = it->second;
const auto& from = it->first;
-
- auto convert_before = std::make_shared<ov::op::v0::Convert>(node->input_value(0), from);
- node->input(0).replace_source_output(convert_before);
- auto consumers = node->output(0).get_target_inputs();
- auto convert_after = std::make_shared<ov::op::v0::Convert>(node, to);
- for (auto& input : consumers) {
- const auto consumer = input.get_node();
- if (ov::is_type<ov::op::v0::Result>(consumer) || ov::is_type<ov::op::v0::Convert>(consumer)) {
- continue;
+ if (node->get_input_size()) {
+ auto convert_before = std::make_shared<ov::op::v0::Convert>(node->input_value(0), from);
+ node->input(0).replace_source_output(convert_before);
+ }
+ if (node->get_output_size() == 1) {
+ auto consumers = node->output(0).get_target_inputs();
+ auto convert_after = std::make_shared<ov::op::v0::Convert>(node, to);
+ for (auto& input : consumers) {
+ const auto consumer = input.get_node();
+ if (ov::is_type<ov::op::v0::Result>(consumer) || ov::is_type<ov::op::v0::Convert>(consumer)) {
+ continue;
+ }
+ input.replace_source_output(convert_after);
}
- input.replace_source_output(convert_after);
}
return true;