code check clean up

This commit is contained in:
Margaret_wangrui 2021-07-20 11:04:16 +08:00
parent 61fbff6ab2
commit 737970cd89
3 changed files with 15 additions and 16 deletions

View File

@ -827,7 +827,6 @@ bool KPynativeCellImpl::BackPropagate(bool by_value) {
MS_LOG(DEBUG) << "BackPropagate for CNode: " << cnode->DebugString(); MS_LOG(DEBUG) << "BackPropagate for CNode: " << cnode->DebugString();
auto fg = iter->second->fg(); auto fg = iter->second->fg();
auto fg_type = iter->second->fg_type(); auto fg_type = iter->second->fg_type();
if (fg_type == PynativeAdjoint::kBackwardPropagate) { if (fg_type == PynativeAdjoint::kBackwardPropagate) {
BackPropagateOneCNodeWithBPropFuncGraph(cnode, iter->second, fg, by_value); BackPropagateOneCNodeWithBPropFuncGraph(cnode, iter->second, fg, by_value);
} else { } else {

View File

@ -103,7 +103,7 @@ std::vector<CNodePtr> FindCandidateRecomputedNodes(const FuncGraphManagerPtr &mn
if (std::any_of(inputs.begin(), inputs.end(), [](const AnfNodePtr &node) { return IsBpropNode(node); })) { if (std::any_of(inputs.begin(), inputs.end(), [](const AnfNodePtr &node) { return IsBpropNode(node); })) {
continue; continue;
} }
candidate_recomputed_nodes.emplace_back(cnode); (void)candidate_recomputed_nodes.emplace_back(cnode);
} }
return candidate_recomputed_nodes; return candidate_recomputed_nodes;
} }
@ -204,7 +204,7 @@ std::vector<AnfNodePtr> GetFirstTargetInputs(const std::vector<CNodePtr> &origin
if (recomputed_origin_nodes.find(input->cast<CNodePtr>()) != recomputed_origin_nodes.end()) { if (recomputed_origin_nodes.find(input->cast<CNodePtr>()) != recomputed_origin_nodes.end()) {
continue; continue;
} }
first_target_inputs.emplace_back(input); (void)first_target_inputs.emplace_back(input);
} }
break; break;
} }
@ -261,7 +261,7 @@ void GetTupleGetItemOutputNodes(const FuncGraphManagerPtr &mng, const AnfNodePtr
} }
for (const auto &node_index_set : output_set_iter->second) { for (const auto &node_index_set : output_set_iter->second) {
if (IsPrimitiveCNode(node_index_set.first, prim::kPrimTupleGetItem)) { if (IsPrimitiveCNode(node_index_set.first, prim::kPrimTupleGetItem)) {
tuple_getitem_output_nodes->emplace_back(node_index_set.first); (void)tuple_getitem_output_nodes->emplace_back(node_index_set.first);
} }
} }
} }
@ -304,7 +304,7 @@ void SetRecomputedAttr(const FuncGraphPtr &graph, const std::vector<CNodePtr> &o
auto prim_recompute_attr = prim->GetAttr(kAttrRecompute); auto prim_recompute_attr = prim->GetAttr(kAttrRecompute);
int prim_recompute_val = -1; int prim_recompute_val = -1;
if (prim_recompute_attr != nullptr && prim_recompute_attr->isa<BoolImm>()) { if (prim_recompute_attr != nullptr && prim_recompute_attr->isa<BoolImm>()) {
prim_recompute_val = GetValue<bool>(prim_recompute_attr); prim_recompute_val = static_cast<int>(GetValue<bool>(prim_recompute_attr));
} }
if ((SetRecomputedScope(cnode) && prim_recompute_val != 0) || prim_recompute_val == 1) { if ((SetRecomputedScope(cnode) && prim_recompute_val != 0) || prim_recompute_val == 1) {
cnode->AddAttr(kAttrRecompute, MakeValue(true)); cnode->AddAttr(kAttrRecompute, MakeValue(true));
@ -352,7 +352,7 @@ CNodePtr NewRecomputedNode(const FuncGraphPtr &graph, const CNodePtr &origin_nod
auto input = origin_node->input(i); auto input = origin_node->input(i);
MS_EXCEPTION_IF_NULL(input); MS_EXCEPTION_IF_NULL(input);
if (!input->isa<CNode>()) { if (!input->isa<CNode>()) {
new_inputs.emplace_back(input); (void)new_inputs.emplace_back(input);
continue; continue;
} }
auto input_cnode = input->cast<CNodePtr>(); auto input_cnode = input->cast<CNodePtr>();
@ -360,14 +360,14 @@ CNodePtr NewRecomputedNode(const FuncGraphPtr &graph, const CNodePtr &origin_nod
if (IsPrimitiveCNode(input_cnode, prim::kPrimUpdateState)) { if (IsPrimitiveCNode(input_cnode, prim::kPrimUpdateState)) {
auto u = NewValueNode(kUMonad); auto u = NewValueNode(kUMonad);
u->set_abstract(kUMonad->ToAbstract()); u->set_abstract(kUMonad->ToAbstract());
new_inputs.emplace_back(u); (void)new_inputs.emplace_back(u);
} else { } else {
new_inputs.emplace_back(input); (void)new_inputs.emplace_back(input);
} }
} else { } else {
has_recomputed_inputs = true; has_recomputed_inputs = true;
new_inputs.emplace_back(NewRecomputedNode(graph, input_cnode, first_target_inputs, recomputed_origin_nodes, (void)new_inputs.emplace_back(NewRecomputedNode(graph, input_cnode, first_target_inputs, recomputed_origin_nodes,
origin_to_recomputed_nodes)); origin_to_recomputed_nodes));
} }
} }
// Add the execution dependency. // Add the execution dependency.
@ -404,14 +404,14 @@ void DuplicateRecomputedNodes(const FuncGraphPtr &graph, const std::unordered_se
for (const auto &input : target_cnode->inputs()) { for (const auto &input : target_cnode->inputs()) {
MS_EXCEPTION_IF_NULL(input); MS_EXCEPTION_IF_NULL(input);
if (!input->isa<CNode>()) { if (!input->isa<CNode>()) {
new_target_inputs.emplace_back(input); (void)new_target_inputs.emplace_back(input);
} else { } else {
auto input_cnode = input->cast<CNodePtr>(); auto input_cnode = input->cast<CNodePtr>();
if (origin_recomputed_nodes.find(input_cnode) != origin_recomputed_nodes.end()) { if (origin_recomputed_nodes.find(input_cnode) != origin_recomputed_nodes.end()) {
new_target_inputs.emplace_back(NewRecomputedNode(graph, input_cnode, first_target_inputs, (void)new_target_inputs.emplace_back(NewRecomputedNode(graph, input_cnode, first_target_inputs,
origin_recomputed_nodes, origin_to_recomputed_nodes)); origin_recomputed_nodes, origin_to_recomputed_nodes));
} else { } else {
new_target_inputs.emplace_back(input_cnode); (void)new_target_inputs.emplace_back(input_cnode);
} }
} }
} }

View File

@ -30,8 +30,8 @@ namespace mindspore {
namespace abstract { namespace abstract {
AnfNodePtr GetTraceNode(const AbstractBasePtr &abs) { AnfNodePtr GetTraceNode(const AbstractBasePtr &abs) {
AnfNodePtr node = nullptr; AnfNodePtr node = nullptr;
if (abs->trace_node_provider_ != nullptr) { if (mindspore::abstract::AbstractBase::trace_node_provider_ != nullptr) {
abs->trace_node_provider_(&node); mindspore::abstract::AbstractBase::trace_node_provider_(&node);
} }
return node; return node;
} }