forked from mindspore-Ecosystem/mindspore
!20076 Handle the backend parameter mismatch caused by maketuple Abstract setting error
Merge pull request !20076 from Margaret_wangrui/order_enforce_enforce_r1.3
This commit is contained in:
commit
8726b51eae
|
@ -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),
|
(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; });
|
[load](const AnfNodePtr &input) { return load != input; });
|
||||||
const auto &new_make_tuple = fg->NewCNode(new_make_tuple_inputs);
|
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);
|
manager->Replace(make_tuple, new_make_tuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,9 @@ class OrderEnforcer {
|
||||||
const size_t input_size = update_state->inputs().size();
|
const size_t input_size = update_state->inputs().size();
|
||||||
for (size_t index = attach_index; index < input_size; index++) {
|
for (size_t index = attach_index; index < input_size; index++) {
|
||||||
auto attach = update_state->input(attach_index);
|
auto attach = update_state->input(attach_index);
|
||||||
|
if (attach == load_user) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (IsPrimitiveCNode(attach, prim::kPrimMakeTuple)) {
|
if (IsPrimitiveCNode(attach, prim::kPrimMakeTuple)) {
|
||||||
auto attach_cnode = attach->cast<CNodePtr>();
|
auto attach_cnode = attach->cast<CNodePtr>();
|
||||||
auto inputs = attach_cnode->inputs();
|
auto inputs = attach_cnode->inputs();
|
||||||
|
@ -115,8 +118,6 @@ class OrderEnforcer {
|
||||||
if (has_load_user) {
|
if (has_load_user) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (attach == load_user) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -126,7 +127,7 @@ class OrderEnforcer {
|
||||||
void AddInputEdges(const CNodePtr &update_state, const std::unordered_set<AnfNodePtr> &load_users) {
|
void AddInputEdges(const CNodePtr &update_state, const std::unordered_set<AnfNodePtr> &load_users) {
|
||||||
auto sorted_load_users = SortLoadUsers(load_users);
|
auto sorted_load_users = SortLoadUsers(load_users);
|
||||||
for (auto &load_user : sorted_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);
|
processed_nodes_.insert(load_user);
|
||||||
if (!IsInUpdateState(load_user, update_state)) {
|
if (!IsInUpdateState(load_user, update_state)) {
|
||||||
manager_->AddEdge(update_state, load_user);
|
manager_->AddEdge(update_state, load_user);
|
||||||
|
|
Loading…
Reference in New Issue