Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Frontend][Paddle]Handle Exception in Op Conversion. #7296

Merged
merged 7 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ngraph/frontend/paddlepaddle/src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ NamedOutputs make_ng_node(const std::map<pdpd::TensorName, Output<Node>>& nodes,
named_inputs[input_port.parameter()].push_back(node_it->second);
}
}
NamedOutputs outputs;
// In case the conversion function throws exception
try {
outputs = creator_it->second(NodeContext(DecoderPDPDProto(op_place), named_inputs));
zhangYiIntel marked this conversation as resolved.
Show resolved Hide resolved
} catch (std::exception& ex) {
FRONT_END_OP_CONVERSION_CHECK(false, "Fail to convert " + op_desc.type() + " Exception " + ex.what());
}

return creator_it->second(NodeContext(DecoderPDPDProto(op_place), named_inputs));
return outputs;
}

NamedOutputs make_framework_node(const std::map<pdpd::TensorName, Output<Node>>& nodes,
Expand Down
9 changes: 8 additions & 1 deletion ngraph/frontend/paddlepaddle/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,14 @@ InputModelPDPD::InputModelPDPDImpl::InputModelPDPDImpl(const std::basic_string<T

FRONT_END_GENERAL_CHECK(pb_stream && pb_stream.is_open(), "Model file doesn't exist");
FRONT_END_GENERAL_CHECK(m_fw_ptr->ParseFromIstream(&pb_stream), "Model can't be parsed");

// According to Paddle, the saved model has the framework version
// For exmaple Paddle 2.1.0 is encoded as 2001000. 0 means latest framework.
zhangYiIntel marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/version.cmake
// https://github.com/PaddlePaddle/Paddle/blob/2100816c5190693cc7dee181e96af72e9f0fbd1d/paddle/fluid/framework/program_desc.cc#L52
int64_t version = m_fw_ptr->version().version();
FRONT_END_GENERAL_CHECK(
version >= 2001000 || version == 0,
zhangYiIntel marked this conversation as resolved.
Show resolved Hide resolved
"[Frontend]Only Support Paddle greater than 2.1.0, current version " + std::to_string(version));
loadPlaces();
if (weights_stream && weights_stream.is_open()) {
loadConsts(std::basic_string<T>{}, &weights_stream);
Expand Down