Handle the backend parameter mismatch caused by maketuple Abstract setting error

This commit is contained in:
Margaret_wangrui 2021-07-12 17:18:38 +08:00
parent fe9809b03f
commit 01ae9db58e
2 changed files with 9 additions and 4 deletions

View File

@ -165,7 +165,11 @@ void ReplaceLoadUserMakeTuple(const FuncGraphManagerPtr &manager, const FuncGrap
(void)std::copy_if(make_tuple_inputs.begin(), make_tuple_inputs.end(), std::back_inserter(new_make_tuple_inputs),
[load](const AnfNodePtr &input) { return load != input; });
const auto &new_make_tuple = fg->NewCNode(new_make_tuple_inputs);
new_make_tuple->set_abstract(make_tuple->abstract());
// Set abstract for the MakeTuple node.
abstract::AbstractBasePtrList element_abstracts;
std::transform(new_make_tuple_inputs.begin() + 1, new_make_tuple_inputs.end(), std::back_inserter(element_abstracts),
[](const AnfNodePtr &input) { return input->abstract(); });
new_make_tuple->set_abstract(std::make_shared<abstract::AbstractTuple>(element_abstracts));
manager->Replace(make_tuple, new_make_tuple);
}

View File

@ -107,6 +107,9 @@ class OrderEnforcer {
const size_t input_size = update_state->inputs().size();
for (size_t index = attach_index; index < input_size; index++) {
auto attach = update_state->input(attach_index);
if (attach == load_user) {
return true;
}
if (IsPrimitiveCNode(attach, prim::kPrimMakeTuple)) {
auto attach_cnode = attach->cast<CNodePtr>();
auto inputs = attach_cnode->inputs();
@ -115,8 +118,6 @@ class OrderEnforcer {
if (has_load_user) {
return true;
}
} else if (attach == load_user) {
return true;
}
}
return false;
@ -126,7 +127,7 @@ class OrderEnforcer {
void AddInputEdges(const CNodePtr &update_state, const std::unordered_set<AnfNodePtr> &load_users) {
auto sorted_load_users = SortLoadUsers(load_users);
for (auto &load_user : sorted_load_users) {
if (!IsDependOn(load_user, update_state) && load_user != update_state) {
if (!IsDependOn(load_user, update_state) && !IsPrimitiveCNode(load_user, prim::kPrimUpdateState)) {
processed_nodes_.insert(load_user);
if (!IsInUpdateState(load_user, update_state)) {
manager_->AddEdge(update_state, load_user);