Browse Source

fix bug of eliminate cast when trans through depend

tags/v1.2.0-rc1
chenfei 5 years ago
parent
commit
5d7a867118
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.cc

+ 3
- 3
mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.cc View File

@@ -60,6 +60,7 @@ AnfNodePtr CastSameTypeEliminater::operator()(const OptimizerPtr &, const AnfNod
}

if (src_type->type_id() == tgt_type->type_id()) {
// If 2nd input of cast is a depend, can't erase cast directly, but should replace cast with a new depend.
if (IsPrimitiveCNode(node->cast<CNodePtr>()->input(2), prim::kPrimDepend)) {
auto new_depend =
node->func_graph()->NewCNode({NewValueNode(prim::kPrimDepend), src_, node->cast<CNodePtr>()->input(2)});
@@ -72,11 +73,10 @@ AnfNodePtr CastSameTypeEliminater::operator()(const OptimizerPtr &, const AnfNod
}

void CastSameTypeEliminater::Visit(const AnfNodePtr &node) {
auto cur_node = TransThroughDepend(node);
if (src_ == nullptr) {
src_ = cur_node;
src_ = node;
} else {
tgt_ = cur_node;
tgt_ = TransThroughDepend(node);
}
}



Loading…
Cancel
Save