Skip to content

Commit

Permalink
Modify data conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
bukejiyu committed Jan 24, 2025
1 parent 41ca9a0 commit 2f488af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/frontends/paddle/src/op/assign_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ NamedOutputs assign_value(const NodeContext& node) {
const_node = {opset6::Constant::create(dtype, Shape{shape.begin(), shape.end()}, values)};
} else {
auto values = node.get_attribute<std::vector<double>>("values");
auto values_f32 = std::vector<float>(values.begin(), values.end());
std::vector<float> values_f32(values.size());
std::transform(values.begin(), values.end(), values_f32.begin(), [](double v) {
return static_cast<float>(v);
});
const_node = {opset6::Constant::create(dtype, Shape{shape.begin(), shape.end()}, values_f32)};
}
break;
Expand Down
5 changes: 3 additions & 2 deletions src/frontends/paddle/src/op/fill_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ NamedOutputs fill_constant(const NodeContext& node) {
int32_t value = static_cast<int32_t>(node.get_attribute<float>("value"));
value_node = opset6::Constant::create(dtype, {}, {value});
} else if (dtype == element::f16) {
float value = static_cast<float16>(node.get_attribute<float>("value"));
float value = static_cast<ov::float16>(node.get_attribute<float>("value"));
value_node = opset6::Constant::create(dtype, {}, {value});
} else if (dtype == element::f32) {
float value = node.get_attribute<float>("value");
value_node = opset6::Constant::create(dtype, {}, {value});
} else if (dtype == element::f64) {
float value = static_cast<double>(node.get_attribute<float>("value"));
float f32_value = node.get_attribute<float>("value");
double value = static_cast<double>(f32_value);
value_node = opset6::Constant::create(dtype, {}, {value});
} else if (dtype == element::i64) {
int64_t value = static_cast<int64_t>(node.get_attribute<float>("value"));
Expand Down
5 changes: 4 additions & 1 deletion src/frontends/paddle/src/op/set_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ NamedOutputs set_value(const NodeContext& node) {
value_arrt)};
} else {
auto value_arrt = node.get_attribute<std::vector<double>>("values");
auto fp32_value = std::vector<float>(value_arrt.begin(), value_arrt.end());
std::vector<float> fp32_value(value_arrt.size());
std::transform(value_arrt.begin(), value_arrt.end(), fp32_value.begin(), [](double v) {
return static_cast<float>(v);
});
value_node = {default_opset::Constant::create(input_type,
Shape{value_shape.begin(), value_shape.end()},
fp32_value)};
Expand Down

0 comments on commit 2f488af

Please sign in to comment.