Skip to content

Commit e582f61

Browse files
[Transformations] Fix exception when converting precision on Read_Value node without inputs. (#26829)
### Details: - *Read value node without input source on FP16 precision would raise exception. The PR fix this.* ### Tickets: - *CVS-153067*
1 parent a8293f3 commit e582f61

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/common/transformations/src/transformations/convert_precision.cpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool fuse_type_to_parameter(const std::shared_ptr<ov::Node>& node,
2929
bool convert_input_precision);
3030

3131
// this function inserts Convert operations to 'data' input and outputs of `node`
32-
// to execute 'node' with the original type.
32+
// to execute 'node' with the original type. This function supports nodes with single output.
3333
bool wrap_into_original_type(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions);
3434
bool store_original_type_as_attribute(const std::shared_ptr<ov::Node>& node, const precisions_map& precisions);
3535

@@ -622,17 +622,20 @@ bool wrap_into_original_type(const std::shared_ptr<ov::Node>& node, const precis
622622

623623
const auto& to = it->second;
624624
const auto& from = it->first;
625-
626-
auto convert_before = std::make_shared<ov::op::v0::Convert>(node->input_value(0), from);
627-
node->input(0).replace_source_output(convert_before);
628-
auto consumers = node->output(0).get_target_inputs();
629-
auto convert_after = std::make_shared<ov::op::v0::Convert>(node, to);
630-
for (auto& input : consumers) {
631-
const auto consumer = input.get_node();
632-
if (ov::is_type<ov::op::v0::Result>(consumer) || ov::is_type<ov::op::v0::Convert>(consumer)) {
633-
continue;
625+
if (node->get_input_size()) {
626+
auto convert_before = std::make_shared<ov::op::v0::Convert>(node->input_value(0), from);
627+
node->input(0).replace_source_output(convert_before);
628+
}
629+
if (node->get_output_size() == 1) {
630+
auto consumers = node->output(0).get_target_inputs();
631+
auto convert_after = std::make_shared<ov::op::v0::Convert>(node, to);
632+
for (auto& input : consumers) {
633+
const auto consumer = input.get_node();
634+
if (ov::is_type<ov::op::v0::Result>(consumer) || ov::is_type<ov::op::v0::Convert>(consumer)) {
635+
continue;
636+
}
637+
input.replace_source_output(convert_after);
634638
}
635-
input.replace_source_output(convert_after);
636639
}
637640

638641
return true;

0 commit comments

Comments
 (0)