Skip to content

Commit

Permalink
[Transformations] Fix exception when converting precision on Read_Val…
Browse files Browse the repository at this point in the history
…ue node without inputs. (openvinotoolkit#26829)

### Details:
- *Read value node without input source on FP16 precision would raise
exception. The PR fix this.*

### Tickets:
 - *CVS-153067*
  • Loading branch information
luweizhou2016 authored Oct 18, 2024
1 parent a8293f3 commit e582f61
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e582f61

Please sign in to comment.