diff --git a/mindspore/ccsrc/runtime/framework/actor/switch_actor.cc b/mindspore/ccsrc/runtime/framework/actor/switch_actor.cc index 05c54d2de73..f8855e69ced 100644 --- a/mindspore/ccsrc/runtime/framework/actor/switch_actor.cc +++ b/mindspore/ccsrc/runtime/framework/actor/switch_actor.cc @@ -291,8 +291,8 @@ size_t SwitchActor::GetIndex(OpContext *context) { char buf[kMaxSwitchCondSize] = {0}; ShapeVector host_shape; if (!device_tensor->SyncDeviceToHost(host_shape, size, type_id, static_cast(buf))) { - MS_LOG(ERROR) << GetAID().Name() + " get index from device address failed, type id:" + std::to_string(type_id) + - ", device type:" + std::to_string(static_cast(device_context_->GetDeviceAddressType())); + MS_LOG(ERROR) << GetAID().Name() << " get index from device address failed, type id:" << std::to_string(type_id) + << ", device type:" << std::to_string(static_cast(device_context_->GetDeviceAddressType())); } if (type_id == TypeId::kNumberTypeInt32) { @@ -413,7 +413,8 @@ void SwitchActor::SendOutput(OpContext *context) { for (size_t j = 0; j < AnfAlgo::GetOutputTensorNum(backend_node.first); ++j) { if (backend_node.first->kernel_info() != nullptr && AnfAlgo::OutputAddrExist(backend_node.first, j, false) && AnfAlgo::GetMutableOutputAddr(backend_node.first, j, false).get() == input_device_tensors_[from_index]) { - Async(result_arrow->to_op_id_, &OutputActor::CollectOutput, backend_node.first, j, + auto output_index = j; + Async(result_arrow->to_op_id_, &OutputActor::CollectOutput, backend_node.first, output_index, result_arrow->to_input_index_, context); is_send = true; MS_LOG(DEBUG) << "Switch actor:" << GetAID() << " send result addr:" << input_device_tensors_[from_index] diff --git a/mindspore/ccsrc/runtime/framework/control_node_parser.cc b/mindspore/ccsrc/runtime/framework/control_node_parser.cc index 185017147c1..1cbf40b8e3c 100644 --- a/mindspore/ccsrc/runtime/framework/control_node_parser.cc +++ b/mindspore/ccsrc/runtime/framework/control_node_parser.cc @@ -528,7 +528,6 @@ bool IsSubCallNode(const AnfNodePtr &node) { } const auto inputs = node->cast()->inputs(); - if (!AnfAlgo::CheckPrimitiveType(inputs[0], prim::kPrimSwitchLayer)) { return false; } @@ -670,7 +669,6 @@ size_t FetchOutputSizebyCallNode(const AnfNodePtr &node, std::vector FuncGraphPtr FetchFuncGraphByNode(const AnfNodePtr &node) { auto front_node = GetFrontNodeByBackendNode(node); - // If the front node is nullptr, we can check its inputs. if (front_node == nullptr) { if (node->isa()) { @@ -839,7 +837,6 @@ DeviceContext *ControlNodeParser::GetFrontValueNodeDeviceContext(const AnfNodePt auto iter = std::find_if( front_value_nodes_.begin(), front_value_nodes_.end(), [value_node](const auto &front_node_with_context) { return front_node_with_context.first == value_node; }); - if (iter != front_value_nodes_.end()) { return iter->second; } @@ -1224,7 +1221,6 @@ void ControlNodeParser::FetchFrontToBackendParameter(const std::vectorinput_nodes()) { auto front_node = graph->GetFrontAnfByBackendAnf(parameter); - if (front_node != nullptr && front_node->isa() && front_to_backend_parameters_.find(front_node) == front_to_backend_parameters_.end()) { front_to_backend_parameters_[front_node] = {parameter, device_context}; @@ -1363,7 +1359,6 @@ void ControlNodeParser::FetchBackendOutputByFrontOutput(const AnfNodePtr &front_ } else if (front_output->isa()) { // Output is a parameter. const auto iter = formal_to_real_parameters_.find(front_output); - if (iter != formal_to_real_parameters_.end()) { for (const auto &node : iter->second) { (void)(*results).emplace(node); @@ -1396,7 +1391,6 @@ void ControlNodeParser::FetchBackendOutputByFrontOutput(const AnfNodePtr &front_ } else if (front_output->isa()) { // Output is a kernel. const auto iter = front_to_backend_kernels_.find(AnfAlgo::VisitKernelWithReturnType(front_output, 0)); - if (iter != front_to_backend_kernels_.end()) { (void)(*results).emplace(iter->second.first); } else { @@ -1418,7 +1412,6 @@ void ControlNodeParser::FetchBackendInputNodebyFrontNode( for (const auto &front_input : front_inputs) { const auto node_with_index = AnfAlgo::VisitKernelWithReturnType(front_input, 0); - if (node_with_index.first->isa()) { const auto &iter = front_to_backend_parameters.find(real_parameter); if (iter == front_to_backend_parameters.end()) { @@ -1465,7 +1458,6 @@ void ControlNodeParser::FetchBackendParameterNode(const std::vectorinput_nodes()) { auto front_node = graph->GetFrontAnfByBackendAnf(parameter); - if (front_node != nullptr && front_node->isa() && (*front_to_backend_parameters).find(front_node) == (*front_to_backend_parameters).end()) { (*front_to_backend_parameters)[front_node] = {parameter, device_context}; @@ -1506,7 +1498,6 @@ void ControlNodeParser::FetchBackendInputNode(const std::vector const auto &graph = graphs[i]; for (const auto &value_node : graph->graph_value_nodes()) { auto front_node = graph->GetFrontAnfByBackendAnf(value_node); - if (front_node != nullptr) { (void)formal_to_real_parameters_[front_node].emplace_back(value_node, 0); } diff --git a/mindspore/ccsrc/runtime/framework/graph_scheduler.cc b/mindspore/ccsrc/runtime/framework/graph_scheduler.cc index 90e9c6973bd..4e1f47b6152 100644 --- a/mindspore/ccsrc/runtime/framework/graph_scheduler.cc +++ b/mindspore/ccsrc/runtime/framework/graph_scheduler.cc @@ -996,7 +996,6 @@ std::vector GraphScheduler::BuildDataSourceActor(const Graph const auto &backend_node = backend_iter->second.first; auto iter = find(host_queue_ds_actor->data_nodes_.begin(), host_queue_ds_actor->data_nodes_.end(), backend_node); - if (iter != host_queue_ds_actor->data_nodes_.end()) { (void)host_queue_ds_actor->data_node_position_map_.emplace(parameter, iter - host_queue_ds_actor->data_nodes_.begin()); @@ -2047,7 +2046,6 @@ void GraphScheduler::PrepareInputNodeForSwitchActor(const std::vectorcast(); auto inputs = cnode->inputs(); - // Before link data arrow, parameters of the call node in switch-call need to be add to the switch actor. if (inputs[0]->isa()) { auto actor = FetchActor(inputs[0]->DebugString()); @@ -2076,7 +2074,10 @@ void GraphScheduler::LinkArrowByControlNode(const GraphCompilerInfo &graph_compi if (AnfAlgo::CheckPrimitiveType(node, prim::kPrimSwitch) || AnfAlgo::CheckPrimitiveType(node, prim::kPrimSwitchLayer)) { auto actor = actor_name_to_actor_[node->DebugString()]; - LinkDataArrowForSwitchActor(graph_compiler_info, dynamic_cast(actor)); + MS_EXCEPTION_IF_NULL(actor); + auto switch_actor = dynamic_cast(actor); + MS_EXCEPTION_IF_NULL(switch_actor); + LinkDataArrowForSwitchActor(graph_compiler_info, switch_actor); } else if (inputs[0]->isa() && IsValueNode(inputs[0])) { // Link the data arrow for the input of the call node. const auto &actor_name = node->DebugString(); @@ -2533,6 +2534,7 @@ void GraphScheduler::LinkBranchArrowForGatherActor(const GraphCompilerInfo &grap auto actor = FetchActor(actor_name); MS_EXCEPTION_IF_NULL(actor); auto gather_actor = dynamic_cast(actor); + MS_EXCEPTION_IF_NULL(gather_actor); (void)gather_actor->output_branch_arrows_.emplace_back(gather_actor->gather_aid_); } }