Signed-off-by: leonwanghui <leon.wanghui@huawei.com>tags/v0.2.0-alpha
| @@ -66,7 +66,7 @@ void CPUKernelRuntime::AssignValueNodeAddress(session::KernelGraph *kernel_graph | |||||
| address->ptr_ = resource_manager_.MemMalloc(tensor_size); | address->ptr_ = resource_manager_.MemMalloc(tensor_size); | ||||
| if (!address->SyncHostToDevice(data_shape, LongToSize(tensor->data().nbytes()), tensor->data_type(), | if (!address->SyncHostToDevice(data_shape, LongToSize(tensor->data().nbytes()), tensor->data_type(), | ||||
| tensor->data_c(false))) { | tensor->data_c(false))) { | ||||
| MS_LOG(EXCEPTION) << "value node sync host to device failed!"; | |||||
| MS_LOG(EXCEPTION) << "Value node sync host to device failed!"; | |||||
| } | } | ||||
| } | } | ||||
| address->ref_count_ = INIT_NODE_REF; | address->ref_count_ = INIT_NODE_REF; | ||||
| @@ -141,7 +141,7 @@ BaseRef CPUKernelRuntime::CreatTensorForOutput(const AnfNodePtr &input_node, siz | |||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| size_t output_size = AnfAlgo::GetOutputTensorNum(node); | size_t output_size = AnfAlgo::GetOutputTensorNum(node); | ||||
| if (index >= output_size) { | if (index >= output_size) { | ||||
| MS_LOG(EXCEPTION) << "invalid input index " << index; | |||||
| MS_LOG(EXCEPTION) << "Invalid input index " << index; | |||||
| } | } | ||||
| auto address = AnfAlgo::GetMutableOutputAddr(node, index); | auto address = AnfAlgo::GetMutableOutputAddr(node, index); | ||||
| MS_EXCEPTION_IF_NULL(address); | MS_EXCEPTION_IF_NULL(address); | ||||
| @@ -157,7 +157,7 @@ BaseRef CPUKernelRuntime::CreatTensorForOutput(const AnfNodePtr &input_node, siz | |||||
| type_id = kNumberTypeFloat32; | type_id = kNumberTypeFloat32; | ||||
| } | } | ||||
| if (type_id != kNumberTypeInt32 && type_id != kNumberTypeFloat32) { | if (type_id != kNumberTypeInt32 && type_id != kNumberTypeFloat32) { | ||||
| MS_LOG(EXCEPTION) << "check output type failed."; | |||||
| MS_LOG(EXCEPTION) << "Check output type failed."; | |||||
| } | } | ||||
| tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type_id, temp_shape); | tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type_id, temp_shape); | ||||
| MS_EXCEPTION_IF_NULL(tensor); | MS_EXCEPTION_IF_NULL(tensor); | ||||
| @@ -181,7 +181,7 @@ void CPUKernelRuntime::BindInputOutput(const session::KernelGraph *kernel_graph, | |||||
| // bind input ptr | // bind input ptr | ||||
| auto &input_nodes = kernel_graph->inputs(); | auto &input_nodes = kernel_graph->inputs(); | ||||
| if (input_nodes.size() != inputs.size()) { | if (input_nodes.size() != inputs.size()) { | ||||
| MS_LOG(EXCEPTION) << "input size not equal to input node size!"; | |||||
| MS_LOG(EXCEPTION) << "Input size not equal to input node size!"; | |||||
| } | } | ||||
| std::unordered_map<AnfNode *, tensor::TensorPtr> input_map; | std::unordered_map<AnfNode *, tensor::TensorPtr> input_map; | ||||
| @@ -203,7 +203,7 @@ void CPUKernelRuntime::BindInputOutput(const session::KernelGraph *kernel_graph, | |||||
| address->ptr_ = resource_manager_.MemMalloc(tensor_size); | address->ptr_ = resource_manager_.MemMalloc(tensor_size); | ||||
| if (!address->SyncHostToDevice(data_shape, LongToSize(tensor->data().nbytes()), tensor->data_type(), | if (!address->SyncHostToDevice(data_shape, LongToSize(tensor->data().nbytes()), tensor->data_type(), | ||||
| tensor->data_c(false))) { | tensor->data_c(false))) { | ||||
| MS_LOG(EXCEPTION) << "parameter node sync host to device failed!"; | |||||
| MS_LOG(EXCEPTION) << "Parameter node sync host to device failed!"; | |||||
| } | } | ||||
| tensor->set_dirty(true); | tensor->set_dirty(true); | ||||
| } | } | ||||
| @@ -44,7 +44,7 @@ void CPUResourceManager::MemPlan(const session::KernelGraph *graph) { | |||||
| mem_size_ = graph_mem_size; | mem_size_ = graph_mem_size; | ||||
| dynamic_malloc_ = false; | dynamic_malloc_ = false; | ||||
| } else { | } else { | ||||
| MS_LOG(INFO) << "switch to dynamic malloc"; | |||||
| MS_LOG(INFO) << "Switch to dynamic malloc"; | |||||
| dynamic_malloc_ = true; | dynamic_malloc_ = true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -63,7 +63,7 @@ void *CPUResourceManager::MemMalloc(size_t mem_size) { | |||||
| dynamic_mem_[ptr] = mem_size; | dynamic_mem_[ptr] = mem_size; | ||||
| return ptr; | return ptr; | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "malloc memory failed: size " << mem_size; | |||||
| MS_LOG(EXCEPTION) << "Malloc memory failed: size " << mem_size; | |||||
| } | } | ||||
| } | } | ||||
| @@ -31,12 +31,12 @@ GraphId CPUSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList | |||||
| auto graph_id = graph_sum_; | auto graph_id = graph_sum_; | ||||
| auto graph = ConstructKernelGraph(lst, outputs); | auto graph = ConstructKernelGraph(lst, outputs); | ||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| MS_LOG(INFO) << "set kernel info"; | |||||
| MS_LOG(INFO) << "Set kernel info"; | |||||
| SetKernelInfo(graph.get()); | SetKernelInfo(graph.get()); | ||||
| predictmodel::StepConvertGraph(graph); | predictmodel::StepConvertGraph(graph); | ||||
| MS_LOG(INFO) << "build kernel"; | |||||
| MS_LOG(INFO) << "Build kernel"; | |||||
| BuildKernel(graph.get()); | BuildKernel(graph.get()); | ||||
| MS_LOG(INFO) << "assign kernel address"; | |||||
| MS_LOG(INFO) << "Assign kernel address"; | |||||
| runtime_.AssignKernelAddress(graph.get()); | runtime_.AssignKernelAddress(graph.get()); | ||||
| return graph_id; | return graph_id; | ||||
| } | } | ||||
| @@ -44,18 +44,18 @@ GraphId CPUSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList | |||||
| void CPUSession::RunGraph(const GraphId &graph_id, const std::vector<tensor::TensorPtr> &inputs, VectorRef *outputs) { | void CPUSession::RunGraph(const GraphId &graph_id, const std::vector<tensor::TensorPtr> &inputs, VectorRef *outputs) { | ||||
| auto &kernel_graph = graphs_[graph_id]; | auto &kernel_graph = graphs_[graph_id]; | ||||
| MS_EXCEPTION_IF_NULL(kernel_graph); | MS_EXCEPTION_IF_NULL(kernel_graph); | ||||
| MS_LOG(INFO) << "bind input output address"; | |||||
| MS_LOG(INFO) << "Bind input output address"; | |||||
| runtime_.BindInputOutput(kernel_graph.get(), inputs, outputs); | runtime_.BindInputOutput(kernel_graph.get(), inputs, outputs); | ||||
| MS_LOG(INFO) << "run graph start"; | |||||
| MS_LOG(INFO) << "Run graph start"; | |||||
| predictmodel::StepConvertWeight(inputs); | predictmodel::StepConvertWeight(inputs); | ||||
| auto execution_order = kernel_graph->execution_order(); | auto execution_order = kernel_graph->execution_order(); | ||||
| Reorder(&execution_order); | Reorder(&execution_order); | ||||
| kernel_graph->set_execution_order(execution_order); | kernel_graph->set_execution_order(execution_order); | ||||
| bool ret = runtime_.Run(kernel_graph.get()); | bool ret = runtime_.Run(kernel_graph.get()); | ||||
| if (!ret) { | if (!ret) { | ||||
| MS_LOG(EXCEPTION) << "run graph failed"; | |||||
| MS_LOG(EXCEPTION) << "Run graph failed"; | |||||
| } | } | ||||
| MS_LOG(INFO) << "run graph end"; | |||||
| MS_LOG(INFO) << "Run graph end"; | |||||
| } | } | ||||
| void CPUSession::SetKernelInfo(const KernelGraph *kernel_graph) { | void CPUSession::SetKernelInfo(const KernelGraph *kernel_graph) { | ||||
| @@ -49,7 +49,7 @@ void KernelAdjust::Reorder(const std::shared_ptr<session::KernelGraph> &kernel_g | |||||
| std::vector<CNodePtr> momentum_list; | std::vector<CNodePtr> momentum_list; | ||||
| std::vector<CNodePtr> other_list; | std::vector<CNodePtr> other_list; | ||||
| for (const auto &cnode : origin_cnode_list) { | for (const auto &cnode : origin_cnode_list) { | ||||
| if (kOptOpeatorSet.find(AnfAlgo::GetCNodeName(cnode)) != kOptOpeatorSet.end()) { | |||||
| if (kOptOperatorSet.find(AnfAlgo::GetCNodeName(cnode)) != kOptOperatorSet.end()) { | |||||
| momentum_list.emplace_back(cnode); | momentum_list.emplace_back(cnode); | ||||
| } else { | } else { | ||||
| other_list.emplace_back(cnode); | other_list.emplace_back(cnode); | ||||
| @@ -118,7 +118,7 @@ void KernelAdjust::CreateSwitchOpParameters(const std::shared_ptr<session::Kerne | |||||
| MS_EXCEPTION_IF_NULL(tensor_ptr); | MS_EXCEPTION_IF_NULL(tensor_ptr); | ||||
| mindspore::abstract::AbstractBasePtr paremeter_abstract_ptr = tensor_ptr->ToAbstract(); | mindspore::abstract::AbstractBasePtr paremeter_abstract_ptr = tensor_ptr->ToAbstract(); | ||||
| if (paremeter_abstract_ptr == nullptr) { | if (paremeter_abstract_ptr == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "create abstract brfore insert switch op failed!"; | |||||
| MS_LOG(EXCEPTION) << "create abstract before insert switch op failed!"; | |||||
| } | } | ||||
| ParameterPtr loop_count = std::make_shared<Parameter>(kernel_graph_ptr); | ParameterPtr loop_count = std::make_shared<Parameter>(kernel_graph_ptr); | ||||
| @@ -371,7 +371,7 @@ bool KernelAdjust::StepLoadCtrlInputs(const std::shared_ptr<session::Context> &c | |||||
| auto tensor = inputs[i]; | auto tensor = inputs[i]; | ||||
| size_t deal_index = input_nodes.size() - input_ctrl_size + i; | size_t deal_index = input_nodes.size() - input_ctrl_size + i; | ||||
| if (deal_index >= input_nodes.size()) { | if (deal_index >= input_nodes.size()) { | ||||
| MS_LOG(EXCEPTION) << "deak_index[" << deal_index << "] outof range"; | |||||
| MS_LOG(EXCEPTION) << "deal_index[" << deal_index << "] out of range"; | |||||
| } | } | ||||
| auto input_node = input_nodes[deal_index]; | auto input_node = input_nodes[deal_index]; | ||||
| bool need_sync = false; | bool need_sync = false; | ||||
| @@ -439,7 +439,7 @@ void KernelAdjust::LoadSwitchInputs(std::vector<tensor::TensorPtr> *inputs) { | |||||
| void KernelAdjust::Profiling(const std::shared_ptr<session::KernelGraph> &kernel_graph_ptr) { | void KernelAdjust::Profiling(const std::shared_ptr<session::KernelGraph> &kernel_graph_ptr) { | ||||
| if (!ascend::ProfilingManager::GetInstance().IsProfiling()) { | if (!ascend::ProfilingManager::GetInstance().IsProfiling()) { | ||||
| MS_LOG(INFO) << "no need to profiling"; | |||||
| MS_LOG(INFO) << "No need to profiling"; | |||||
| return; | return; | ||||
| } | } | ||||
| ProfilingTraceInfo profiling_trace_info; | ProfilingTraceInfo profiling_trace_info; | ||||
| @@ -452,10 +452,10 @@ void KernelAdjust::Profiling(const std::shared_ptr<session::KernelGraph> &kernel | |||||
| void KernelAdjust::InsertProfilingKernel(const std::shared_ptr<session::KernelGraph> &kernel_graph_ptr, | void KernelAdjust::InsertProfilingKernel(const std::shared_ptr<session::KernelGraph> &kernel_graph_ptr, | ||||
| const ProfilingTraceInfo &profiling_trace_info) { | const ProfilingTraceInfo &profiling_trace_info) { | ||||
| MS_LOG(INFO) << "[profiling] insert profiling kernel start"; | |||||
| MS_LOG(INFO) << "[profiling] Insert profiling kernel start"; | |||||
| MS_EXCEPTION_IF_NULL(kernel_graph_ptr); | MS_EXCEPTION_IF_NULL(kernel_graph_ptr); | ||||
| if (!profiling_trace_info.IsValid()) { | if (!profiling_trace_info.IsValid()) { | ||||
| MS_LOG(WARNING) << "profiling trace point not found"; | |||||
| MS_LOG(WARNING) << "Profiling trace point not found"; | |||||
| return; | return; | ||||
| } | } | ||||
| std::vector<CNodePtr> new_cnode_list; | std::vector<CNodePtr> new_cnode_list; | ||||
| @@ -241,7 +241,7 @@ void KernelRuntime::AssignStaticMemoryInput(const session::KernelGraph *graph) { | |||||
| auto output_size = AnfAlgo::GetOutputTensorNum(item); | auto output_size = AnfAlgo::GetOutputTensorNum(item); | ||||
| for (size_t index = 0; index < output_size; index++) { | for (size_t index = 0; index < output_size; index++) { | ||||
| TypeId output_type_id = AnfAlgo::GetOutputDeviceDataType(item, index); | TypeId output_type_id = AnfAlgo::GetOutputDeviceDataType(item, index); | ||||
| // if graph output is a weight and doesn't link to any cnode,it's data type will be unkonwn | |||||
| // if graph output is a weight and doesn't link to any cnode, it's data type will be unknown | |||||
| if (output_type_id == kTypeUnknown) { | if (output_type_id == kTypeUnknown) { | ||||
| MS_LOG(WARNING) << "It is not suggested to use a lonely weight parameter as the output of graph"; | MS_LOG(WARNING) << "It is not suggested to use a lonely weight parameter as the output of graph"; | ||||
| output_type_id = AnfAlgo::GetOutputInferDataType(item, index); | output_type_id = AnfAlgo::GetOutputInferDataType(item, index); | ||||
| @@ -372,7 +372,7 @@ void KernelRuntime::AssignNodeOutputMem(int flag, const AnfNodePtr &node, int in | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (AnfAlgo::OutputAddrExist(node, i)) { | if (AnfAlgo::OutputAddrExist(node, i)) { | ||||
| MS_LOG(INFO) << "already malloc index:" << i; | |||||
| MS_LOG(INFO) << "Already malloc index:" << i; | |||||
| continue; | continue; | ||||
| } | } | ||||
| auto ptr = CalDeviceMem(node, output_sizes[i], flag, i); | auto ptr = CalDeviceMem(node, output_sizes[i], flag, i); | ||||
| @@ -392,7 +392,7 @@ void KernelRuntime::AssignValueNodeTensor(const ValueNodePtr &value_node, const | |||||
| MS_EXCEPTION_IF_NULL(node_value); | MS_EXCEPTION_IF_NULL(node_value); | ||||
| auto tensor = node_value->cast<TensorPtr>(); | auto tensor = node_value->cast<TensorPtr>(); | ||||
| if (tensor == nullptr) { | if (tensor == nullptr) { | ||||
| MS_LOG(WARNING) << "tensor is null"; | |||||
| MS_LOG(WARNING) << "Tensor is null"; | |||||
| return; | return; | ||||
| } | } | ||||
| size_t tensor_size = tensor->data().nbytes(); | size_t tensor_size = tensor->data().nbytes(); | ||||
| @@ -595,7 +595,7 @@ void KernelRuntime::GenLaunchArgs(const mindspore::kernel::KernelMod &kernel_mod | |||||
| void KernelRuntime::GenAddrCleanLaunchArgs(const CNodePtr &cnode, AddressPtrList *kernel_inputs) { | void KernelRuntime::GenAddrCleanLaunchArgs(const CNodePtr &cnode, AddressPtrList *kernel_inputs) { | ||||
| if (cnode->inputs().size() != 2) { | if (cnode->inputs().size() != 2) { | ||||
| MS_LOG(EXCEPTION) << "atomic Addr clean Node Input nodes not equal 2."; | |||||
| MS_LOG(EXCEPTION) << "Atomic Addr clean Node Input nodes not equal 2."; | |||||
| } | } | ||||
| auto pre_node = cnode->inputs()[1]; | auto pre_node = cnode->inputs()[1]; | ||||
| // set clean output address | // set clean output address | ||||
| @@ -721,11 +721,11 @@ uint8_t *KernelRuntime::MallocDynamicMem(size_t size, bool communication_mem) { | |||||
| bool KernelRuntime::LaunchKernel(const session::KernelGraph *graph) { | bool KernelRuntime::LaunchKernel(const session::KernelGraph *graph) { | ||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| if (!LaunchKernelMod(*graph)) { | if (!LaunchKernelMod(*graph)) { | ||||
| MS_LOG(ERROR) << "LaunchKernelMod failed."; | |||||
| MS_LOG(ERROR) << "LaunchKernelMod failed!"; | |||||
| return false; | return false; | ||||
| } | } | ||||
| if (!SyncStream()) { | if (!SyncStream()) { | ||||
| MS_LOG(ERROR) << "SyncStream failed."; | |||||
| MS_LOG(ERROR) << "SyncStream failed!"; | |||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| @@ -67,7 +67,7 @@ KernelRuntime *KernelRuntimeManager::GetKernelRuntime(const std::string &device_ | |||||
| MS_EXCEPTION_IF_NULL(kernel_runtime); | MS_EXCEPTION_IF_NULL(kernel_runtime); | ||||
| runtime_map_[runtime_key] = kernel_runtime; | runtime_map_[runtime_key] = kernel_runtime; | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "no kernel runtime creator for " << device_name << " with device id " << device_id; | |||||
| MS_LOG(EXCEPTION) << "No kernel runtime creator for " << device_name << " with device id " << device_id; | |||||
| } | } | ||||
| return kernel_runtime.get(); | return kernel_runtime.get(); | ||||
| @@ -65,7 +65,7 @@ KernelWithIndex AnfRuntimeAlgorithm::VisitKernel(const AnfNodePtr &anf_node, siz | |||||
| return VisitKernel(node, 0); | return VisitKernel(node, 0); | ||||
| } else if (IsPrimitive(input0, prim::kPrimTupleGetItem)) { | } else if (IsPrimitive(input0, prim::kPrimTupleGetItem)) { | ||||
| if (cnode->inputs().size() != kTupleGetItemInputSize) { | if (cnode->inputs().size() != kTupleGetItemInputSize) { | ||||
| MS_LOG(EXCEPTION) << "the node tuple_get_item must have 2 inputs!"; | |||||
| MS_LOG(EXCEPTION) << "The node tuple_get_item must have 2 inputs!"; | |||||
| } | } | ||||
| auto input2 = cnode->input(kInputNodeOutputIndexInTupleGetItem); | auto input2 = cnode->input(kInputNodeOutputIndexInTupleGetItem); | ||||
| MS_EXCEPTION_IF_NULL(input2); | MS_EXCEPTION_IF_NULL(input2); | ||||
| @@ -102,7 +102,7 @@ KernelWithIndex AnfRuntimeAlgorithm::VisitKernelWithReturnType(const AnfNodePtr | |||||
| MS_EXCEPTION_IF_NULL(input0); | MS_EXCEPTION_IF_NULL(input0); | ||||
| if (IsPrimitive(input0, prim::kPrimTupleGetItem)) { | if (IsPrimitive(input0, prim::kPrimTupleGetItem)) { | ||||
| if (cnode->inputs().size() != kTupleGetItemInputSize) { | if (cnode->inputs().size() != kTupleGetItemInputSize) { | ||||
| MS_LOG(EXCEPTION) << "the node tuple_get_item must have 2 inputs!"; | |||||
| MS_LOG(EXCEPTION) << "The node tuple_get_item must have 2 inputs!"; | |||||
| } | } | ||||
| auto input2 = cnode->input(kInputNodeOutputIndexInTupleGetItem); | auto input2 = cnode->input(kInputNodeOutputIndexInTupleGetItem); | ||||
| MS_EXCEPTION_IF_NULL(input2); | MS_EXCEPTION_IF_NULL(input2); | ||||
| @@ -188,7 +188,7 @@ std::string AnfRuntimeAlgorithm::GetNodeDebugString(const AnfNodePtr &node) { | |||||
| void AnfRuntimeAlgorithm::SetNodeAttr(const std::string &key, const ValuePtr &value, const AnfNodePtr &node) { | void AnfRuntimeAlgorithm::SetNodeAttr(const std::string &key, const ValuePtr &value, const AnfNodePtr &node) { | ||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| if (!node->isa<CNode>()) { | if (!node->isa<CNode>()) { | ||||
| MS_LOG(EXCEPTION) << "only cnode has attr,but this anf is " << node->DebugString(); | |||||
| MS_LOG(EXCEPTION) << "Only cnode has attr, but this anf is " << node->DebugString(); | |||||
| } | } | ||||
| auto primitive = AnfAlgo::GetCNodePrimitive(node); | auto primitive = AnfAlgo::GetCNodePrimitive(node); | ||||
| MS_EXCEPTION_IF_NULL(primitive); | MS_EXCEPTION_IF_NULL(primitive); | ||||
| @@ -204,7 +204,7 @@ void AnfRuntimeAlgorithm::CopyNodeAttr(const std::string &old_key, const std::st | |||||
| MS_EXCEPTION_IF_NULL(from); | MS_EXCEPTION_IF_NULL(from); | ||||
| MS_EXCEPTION_IF_NULL(to); | MS_EXCEPTION_IF_NULL(to); | ||||
| if (!from->isa<CNode>() || !to->isa<CNode>()) { | if (!from->isa<CNode>() || !to->isa<CNode>()) { | ||||
| MS_LOG(EXCEPTION) << "only cnode has attr,but this from_anf is " << from->DebugString() << " ,to_node is " | |||||
| MS_LOG(EXCEPTION) << "Only cnode has attr, but this from_anf is " << from->DebugString() << " ,to_node is " | |||||
| << to->DebugString(); | << to->DebugString(); | ||||
| } | } | ||||
| auto from_primitive = AnfAlgo::GetCNodePrimitive(from); | auto from_primitive = AnfAlgo::GetCNodePrimitive(from); | ||||
| @@ -218,7 +218,7 @@ void AnfRuntimeAlgorithm::CopyNodeAttrs(const AnfNodePtr &from, const AnfNodePtr | |||||
| MS_EXCEPTION_IF_NULL(from); | MS_EXCEPTION_IF_NULL(from); | ||||
| MS_EXCEPTION_IF_NULL(to); | MS_EXCEPTION_IF_NULL(to); | ||||
| if (!from->isa<CNode>() || !to->isa<CNode>()) { | if (!from->isa<CNode>() || !to->isa<CNode>()) { | ||||
| MS_LOG(EXCEPTION) << "only cnode has attr,but this from_anf is " << from->DebugString() << ",to_node is " | |||||
| MS_LOG(EXCEPTION) << "Only cnode has attr, but this from_anf is " << from->DebugString() << ",to_node is " | |||||
| << from->DebugString(); | << from->DebugString(); | ||||
| } | } | ||||
| auto from_primitive = AnfAlgo::GetCNodePrimitive(from); | auto from_primitive = AnfAlgo::GetCNodePrimitive(from); | ||||
| @@ -231,7 +231,7 @@ void AnfRuntimeAlgorithm::CopyNodeAttrs(const AnfNodePtr &from, const AnfNodePtr | |||||
| void AnfRuntimeAlgorithm::EraseNodeAttr(const std::string &key, const AnfNodePtr node) { | void AnfRuntimeAlgorithm::EraseNodeAttr(const std::string &key, const AnfNodePtr node) { | ||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| if (!node->isa<CNode>()) { | if (!node->isa<CNode>()) { | ||||
| MS_LOG(EXCEPTION) << "only cnode has attr,but this anf is " << node->DebugString(); | |||||
| MS_LOG(EXCEPTION) << "Only cnode has attr, but this anf is " << node->DebugString(); | |||||
| } | } | ||||
| auto primitive = AnfAlgo::GetCNodePrimitive(node); | auto primitive = AnfAlgo::GetCNodePrimitive(node); | ||||
| MS_EXCEPTION_IF_NULL(primitive); | MS_EXCEPTION_IF_NULL(primitive); | ||||
| @@ -241,7 +241,7 @@ void AnfRuntimeAlgorithm::EraseNodeAttr(const std::string &key, const AnfNodePtr | |||||
| bool AnfRuntimeAlgorithm::HasNodeAttr(const std::string &key, const AnfNodePtr &node) { | bool AnfRuntimeAlgorithm::HasNodeAttr(const std::string &key, const AnfNodePtr &node) { | ||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| if (!node->isa<CNode>()) { | if (!node->isa<CNode>()) { | ||||
| MS_LOG(WARNING) << "only cnode has attr,but this anf is " << node->DebugString(); | |||||
| MS_LOG(WARNING) << "Only cnode has attr, but this anf is " << node->DebugString(); | |||||
| return false; | return false; | ||||
| } | } | ||||
| auto primitive = AnfAlgo::GetCNodePrimitive(node); | auto primitive = AnfAlgo::GetCNodePrimitive(node); | ||||
| @@ -252,7 +252,7 @@ bool AnfRuntimeAlgorithm::HasNodeAttr(const std::string &key, const AnfNodePtr & | |||||
| size_t AnfRuntimeAlgorithm::GetInputTensorNum(const AnfNodePtr &node) { | size_t AnfRuntimeAlgorithm::GetInputTensorNum(const AnfNodePtr &node) { | ||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| if (!node->isa<CNode>()) { | if (!node->isa<CNode>()) { | ||||
| MS_LOG(EXCEPTION) << "only cnode has real input,but this anf is " << node->DebugString(); | |||||
| MS_LOG(EXCEPTION) << "Only cnode has real input, but this anf is " << node->DebugString(); | |||||
| } | } | ||||
| auto cnode = node->cast<CNodePtr>(); | auto cnode = node->cast<CNodePtr>(); | ||||
| MS_EXCEPTION_IF_NULL(cnode); | MS_EXCEPTION_IF_NULL(cnode); | ||||
| @@ -404,7 +404,7 @@ std::vector<kernel::Axis> AnfRuntimeAlgorithm::GetInputReshapeType(const AnfNode | |||||
| MS_EXCEPTION_IF_NULL(build_info); | MS_EXCEPTION_IF_NULL(build_info); | ||||
| std::vector<kernel::Axis> result; | std::vector<kernel::Axis> result; | ||||
| if (!build_info->GetInputReshapeType(input_idx, &result)) { | if (!build_info->GetInputReshapeType(input_idx, &result)) { | ||||
| MS_LOG(EXCEPTION) << "filed to ge the node's[ " << node->DebugString() << "] reshape type !"; | |||||
| MS_LOG(EXCEPTION) << "Failed to get the node's[ " << node->DebugString() << "] reshape type !"; | |||||
| } | } | ||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -417,7 +417,7 @@ std::vector<kernel::Axis> AnfRuntimeAlgorithm::GetOutputReshapeType(const AnfNod | |||||
| MS_EXCEPTION_IF_NULL(build_info); | MS_EXCEPTION_IF_NULL(build_info); | ||||
| std::vector<kernel::Axis> result; | std::vector<kernel::Axis> result; | ||||
| if (!build_info->GetOutputReshapeType(output_idx, &result)) { | if (!build_info->GetOutputReshapeType(output_idx, &result)) { | ||||
| MS_LOG(EXCEPTION) << "filed to ge the node's[ " << node->DebugString() << "] reshape type !"; | |||||
| MS_LOG(EXCEPTION) << "Failed to get the node's[ " << node->DebugString() << "] reshape type !"; | |||||
| } | } | ||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -593,7 +593,7 @@ void AnfRuntimeAlgorithm::SetOutputAddr(const DeviceAddressPtr &addr, size_t out | |||||
| auto kernel_info = node->kernel_info(); | auto kernel_info = node->kernel_info(); | ||||
| MS_EXCEPTION_IF_NULL(kernel_info); | MS_EXCEPTION_IF_NULL(kernel_info); | ||||
| if (!kernel_info->SetOutputAddr(addr, output_idx)) { | if (!kernel_info->SetOutputAddr(addr, output_idx)) { | ||||
| MS_LOG(EXCEPTION) << "node " << node->DebugString() << "set adr" << output_idx << " fail"; | |||||
| MS_LOG(EXCEPTION) << "Node " << node->DebugString() << "set adr" << output_idx << " fail"; | |||||
| } | } | ||||
| } | } | ||||
| @@ -603,7 +603,7 @@ void AnfRuntimeAlgorithm::SetWorkspaceAddr(const DeviceAddressPtr &addr, size_t | |||||
| auto kernel_info = node->kernel_info(); | auto kernel_info = node->kernel_info(); | ||||
| MS_EXCEPTION_IF_NULL(kernel_info); | MS_EXCEPTION_IF_NULL(kernel_info); | ||||
| if (!kernel_info->SetWorkspaceAddr(addr, output_idx)) { | if (!kernel_info->SetWorkspaceAddr(addr, output_idx)) { | ||||
| MS_LOG(EXCEPTION) << "node " << node->DebugString() << "set adr" << output_idx << " fail"; | |||||
| MS_LOG(EXCEPTION) << "Node " << node->DebugString() << "set adr" << output_idx << " fail"; | |||||
| } | } | ||||
| } | } | ||||
| @@ -614,7 +614,7 @@ DeviceAddress *AnfRuntimeAlgorithm::GetWorkspaceAddr(const AnfNodePtr &node, siz | |||||
| MS_EXCEPTION_IF_NULL(kernel_info); | MS_EXCEPTION_IF_NULL(kernel_info); | ||||
| auto addr = kernel_info->GetWorkspaceAddr(output_idx); | auto addr = kernel_info->GetWorkspaceAddr(output_idx); | ||||
| if (addr == nullptr) { | if (addr == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "output_idx " << output_idx << " of node " << node->DebugString() | |||||
| MS_LOG(EXCEPTION) << "Output_idx " << output_idx << " of node " << node->DebugString() | |||||
| << "] workspace addr is not exist"; | << "] workspace addr is not exist"; | ||||
| } | } | ||||
| return addr; | return addr; | ||||
| @@ -625,7 +625,7 @@ void AnfRuntimeAlgorithm::SetOutputInferTypeAndShape(const std::vector<TypeId> & | |||||
| const std::vector<std::vector<size_t>> &shapes, AnfNode *node) { | const std::vector<std::vector<size_t>> &shapes, AnfNode *node) { | ||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| if (types.size() != shapes.size()) { | if (types.size() != shapes.size()) { | ||||
| MS_LOG(EXCEPTION) << "types size " << types.size() << "should be same with shapes size " << shapes.size(); | |||||
| MS_LOG(EXCEPTION) << "Types size " << types.size() << "should be same with shapes size " << shapes.size(); | |||||
| } | } | ||||
| if (shapes.empty()) { | if (shapes.empty()) { | ||||
| MS_LOG(EXCEPTION) << "Illegal empty output_types_shapes"; | MS_LOG(EXCEPTION) << "Illegal empty output_types_shapes"; | ||||
| @@ -636,7 +636,7 @@ void AnfRuntimeAlgorithm::SetOutputInferTypeAndShape(const std::vector<TypeId> & | |||||
| auto abstract = std::make_shared<AbstractTensor>(TypeIdToType(types[0]), shape_int); | auto abstract = std::make_shared<AbstractTensor>(TypeIdToType(types[0]), shape_int); | ||||
| node->set_abstract(abstract); | node->set_abstract(abstract); | ||||
| } else { | } else { | ||||
| // mutiple output handle | |||||
| // multiple output handle | |||||
| std::vector<AbstractBasePtr> abstract_list; | std::vector<AbstractBasePtr> abstract_list; | ||||
| for (size_t i = 0; i < types.size(); ++i) { | for (size_t i = 0; i < types.size(); ++i) { | ||||
| std::vector<int> shape_int; | std::vector<int> shape_int; | ||||
| @@ -647,12 +647,12 @@ void AnfRuntimeAlgorithm::SetOutputInferTypeAndShape(const std::vector<TypeId> & | |||||
| node->set_abstract(abstract_tuple); | node->set_abstract(abstract_tuple); | ||||
| } | } | ||||
| } | } | ||||
| // copy a abstract of a node to another node | |||||
| // copy an abstract of a node to another node | |||||
| void AnfRuntimeAlgorithm::CopyAbstract(const AnfNodePtr &from_node, AnfNode *to_node) { | void AnfRuntimeAlgorithm::CopyAbstract(const AnfNodePtr &from_node, AnfNode *to_node) { | ||||
| to_node->set_abstract(from_node->abstract()); | to_node->set_abstract(from_node->abstract()); | ||||
| } | } | ||||
| // get KernelBuildType of node ,such as ATT,RT,FWK and so on | |||||
| // get KernelBuildType of node, such as ATT,RT,FWK and so on | |||||
| KernelType AnfRuntimeAlgorithm::GetKernelType(const AnfNodePtr &node) { | KernelType AnfRuntimeAlgorithm::GetKernelType(const AnfNodePtr &node) { | ||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| auto kernel_info = node->kernel_info(); | auto kernel_info = node->kernel_info(); | ||||
| @@ -846,7 +846,7 @@ size_t AnfRuntimeAlgorithm::GetRealInputIndex(const mindspore::AnfNodePtr &anf_n | |||||
| auto find = spec_node_list.find(node_name); | auto find = spec_node_list.find(node_name); | ||||
| if (find != spec_node_list.end()) { | if (find != spec_node_list.end()) { | ||||
| ret = find->second[cur_index]; | ret = find->second[cur_index]; | ||||
| MS_LOG(INFO) << "real input index change to" << ret << ", node name:" << node_name; | |||||
| MS_LOG(INFO) << "Real input index change to" << ret << ", node name:" << node_name; | |||||
| } | } | ||||
| } | } | ||||
| return ret; | return ret; | ||||
| @@ -61,7 +61,7 @@ class AnfRuntimeAlgorithm { | |||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| if (!node->isa<CNode>()) { | if (!node->isa<CNode>()) { | ||||
| std::string node_debug_log = node->DebugString(); | std::string node_debug_log = node->DebugString(); | ||||
| MS_LOG(EXCEPTION) << "only cnode has attr,but this anf is " << node_debug_log.c_str(); | |||||
| MS_LOG(EXCEPTION) << "Only cnode has attr, but this anf is " << node_debug_log.c_str(); | |||||
| } | } | ||||
| auto primitive = GetCNodePrimitive(node); | auto primitive = GetCNodePrimitive(node); | ||||
| MS_EXCEPTION_IF_NULL(primitive); | MS_EXCEPTION_IF_NULL(primitive); | ||||
| @@ -105,7 +105,7 @@ class AnfRuntimeAlgorithm { | |||||
| static TypeId GetOutputInferDataType(const AnfNodePtr &node, size_t output_idx); | static TypeId GetOutputInferDataType(const AnfNodePtr &node, size_t output_idx); | ||||
| // get output original data type from prev node,input_index is the input index of current node related to prev node | // get output original data type from prev node,input_index is the input index of current node related to prev node | ||||
| static TypeId GetPrevNodeOutputInferDataType(const AnfNodePtr &node, size_t input_idx); | static TypeId GetPrevNodeOutputInferDataType(const AnfNodePtr &node, size_t input_idx); | ||||
| // get output select data typpe of anf node | |||||
| // get output select data type of anf node | |||||
| static TypeId GetOutputDeviceDataType(const AnfNodePtr &node, size_t output_idx); | static TypeId GetOutputDeviceDataType(const AnfNodePtr &node, size_t output_idx); | ||||
| // get input select data type of anf node | // get input select data type of anf node | ||||
| static TypeId GetInputDeviceDataType(const AnfNodePtr &node, size_t input_idx); | static TypeId GetInputDeviceDataType(const AnfNodePtr &node, size_t input_idx); | ||||
| @@ -55,7 +55,7 @@ void DumpGraphExeOrder(const std::vector<CNodePtr> &execution_order) { | |||||
| } | } | ||||
| void DumpGraphInputArgs(const VectorRef &args) { | void DumpGraphInputArgs(const VectorRef &args) { | ||||
| MS_LOG(INFO) << "args size[%lu]" << args.size(); | |||||
| MS_LOG(INFO) << "Args size[%lu]" << args.size(); | |||||
| for (size_t i = 0; i < args.size(); i++) { | for (size_t i = 0; i < args.size(); i++) { | ||||
| if (utils::isa<AnfNodePtr>(args[i])) { | if (utils::isa<AnfNodePtr>(args[i])) { | ||||
| auto anf = utils::cast<AnfNodePtr>(args[i]); | auto anf = utils::cast<AnfNodePtr>(args[i]); | ||||
| @@ -66,7 +66,7 @@ void DumpGraphInputArgs(const VectorRef &args) { | |||||
| MS_EXCEPTION_IF_NULL(value); | MS_EXCEPTION_IF_NULL(value); | ||||
| MS_LOG(INFO) << "Tensor arg" << i << " = " << value->ToString(); | MS_LOG(INFO) << "Tensor arg" << i << " = " << value->ToString(); | ||||
| } else { | } else { | ||||
| MS_LOG(INFO) << "Unknonwn arg" << i << " = " << args[i].ToString(); | |||||
| MS_LOG(INFO) << "Unknown arg" << i << " = " << args[i].ToString(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -95,7 +95,7 @@ GraphId GetDistinctionLabel(const KernelGraphPtr &graph) { | |||||
| GraphId AscendSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) { | GraphId AscendSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) { | ||||
| MS_LOG(INFO) << "start"; | MS_LOG(INFO) << "start"; | ||||
| auto graph_id = graph_sum_; | auto graph_id = graph_sum_; | ||||
| // construct graph,if construct successs,graph_sum_ + 1 | |||||
| // construct graph, if successfully, graph_sum_ + 1 | |||||
| auto graph = ConstructKernelGraph(lst, outputs); | auto graph = ConstructKernelGraph(lst, outputs); | ||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| opt::AscendBackendIRFusionOptimization(graph); | opt::AscendBackendIRFusionOptimization(graph); | ||||
| @@ -127,7 +127,7 @@ void AscendSession::BuildGraph(GraphId graph_id) { | |||||
| // merge child graph | // merge child graph | ||||
| MergeGraphExecOrder(); | MergeGraphExecOrder(); | ||||
| } else { | } else { | ||||
| // set the distinciton label of single graph | |||||
| // set the distinction label of single graph | |||||
| SetStreamDistinctionLabel(GetGraph(graph_id), graph_id, false); | SetStreamDistinctionLabel(GetGraph(graph_id), graph_id, false); | ||||
| } | } | ||||
| // adjust execution order because merge child graph and other special operations | // adjust execution order because merge child graph and other special operations | ||||
| @@ -143,7 +143,7 @@ void AscendSession::BuildGraph(GraphId graph_id) { | |||||
| if (ms_context->precompile_only()) { | if (ms_context->precompile_only()) { | ||||
| MS_LOG(INFO) << "Precompile only, stop in build kernel step"; | MS_LOG(INFO) << "Precompile only, stop in build kernel step"; | ||||
| } else { | } else { | ||||
| // alloc memeory,include static memory and dynamic memory | |||||
| // alloc memory, including static memory and dynamic memory | |||||
| MemoryAlloc(graph.get()); | MemoryAlloc(graph.get()); | ||||
| // generate task info for task sink mode | // generate task info for task sink mode | ||||
| GenerateTaskInfo(graph); | GenerateTaskInfo(graph); | ||||
| @@ -158,9 +158,9 @@ void AscendSession::RunGraph(const GraphId &graph_id, const std::vector<tensor:: | |||||
| MS_LOG(INFO) << "start"; | MS_LOG(INFO) << "start"; | ||||
| auto kernel_graph = GetGraph(graph_id); | auto kernel_graph = GetGraph(graph_id); | ||||
| MS_EXCEPTION_IF_NULL(kernel_graph); | MS_EXCEPTION_IF_NULL(kernel_graph); | ||||
| // if no child graph exist and no anf output exist | |||||
| // if none of child graph and no anf output exists | |||||
| if (!kernel_graph->executable()) { | if (!kernel_graph->executable()) { | ||||
| MS_LOG(INFO) << "no child graph but has anf output"; | |||||
| MS_LOG(INFO) << "No child graph has anf output"; | |||||
| UpdateOutputs(kernel_graph, outputs, inputs); | UpdateOutputs(kernel_graph, outputs, inputs); | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -183,16 +183,16 @@ void AscendSession::RunGraph(const GraphId &graph_id, const std::vector<tensor:: | |||||
| } | } | ||||
| void AscendSession::RunOpHardwareOptimize(const std::shared_ptr<session::KernelGraph> &kernel_graph) const { | void AscendSession::RunOpHardwareOptimize(const std::shared_ptr<session::KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start"; | |||||
| // data layout optimization | // data layout optimization | ||||
| opt::AscendDataLayout(kernel_graph); | opt::AscendDataLayout(kernel_graph); | ||||
| // mixed precision optimization | // mixed precision optimization | ||||
| opt::AscendMixPrecision(kernel_graph); | opt::AscendMixPrecision(kernel_graph); | ||||
| MS_LOG(INFO) << "Finish!"; | |||||
| MS_LOG(INFO) << "Finish"; | |||||
| } | } | ||||
| void AscendSession::RunOpExecTask(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::RunOpExecTask(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| MS_EXCEPTION_IF_NULL(runtime_instance); | MS_EXCEPTION_IF_NULL(runtime_instance); | ||||
| bool ret_ok = runtime_instance->LaunchKernel(kernel_graph.get()); | bool ret_ok = runtime_instance->LaunchKernel(kernel_graph.get()); | ||||
| @@ -251,26 +251,26 @@ py::tuple AscendSession::RunOp(const OpRunInfo &op_run_info, const GraphInfo &gr | |||||
| // compile graph steps | // compile graph steps | ||||
| void AscendSession::SelectKernel(const KernelGraph &kernel_graph) const { | void AscendSession::SelectKernel(const KernelGraph &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| for (const auto &cnode : kernel_graph.execution_order()) { | for (const auto &cnode : kernel_graph.execution_order()) { | ||||
| device::ascend::SelectKernelInfo(cnode); | device::ascend::SelectKernelInfo(cnode); | ||||
| MS_LOG(INFO) << "select ApplyKernel: " << cnode->DebugString(); | |||||
| MS_LOG(INFO) << "Select ApplyKernel: " << cnode->DebugString(); | |||||
| } | } | ||||
| MS_LOG(INFO) << "Finish!"; | MS_LOG(INFO) << "Finish!"; | ||||
| } | } | ||||
| void AscendSession::InitRuntimeResource() { | void AscendSession::InitRuntimeResource() { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| MS_EXCEPTION_IF_NULL(runtime_instance); | MS_EXCEPTION_IF_NULL(runtime_instance); | ||||
| if (!runtime_instance->Init()) { | if (!runtime_instance->Init()) { | ||||
| MS_LOG(EXCEPTION) << "kernel runtime init error."; | |||||
| MS_LOG(EXCEPTION) << "Kernel runtime init error."; | |||||
| } | } | ||||
| MS_LOG(INFO) << "Finish!"; | MS_LOG(INFO) << "Finish!"; | ||||
| } | } | ||||
| void AscendSession::HardwareOptimize(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::HardwareOptimize(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "HardwareOptimize start !"; | |||||
| MS_LOG(INFO) << "HardwareOptimize start!"; | |||||
| opt::AscendBackendOptimization(kernel_graph); | opt::AscendBackendOptimization(kernel_graph); | ||||
| MS_EXCEPTION_IF_NULL(kernel_graph); | MS_EXCEPTION_IF_NULL(kernel_graph); | ||||
| kernel_graph->SetExecOrderByDefault(); | kernel_graph->SetExecOrderByDefault(); | ||||
| @@ -278,7 +278,7 @@ void AscendSession::HardwareOptimize(const std::shared_ptr<KernelGraph> &kernel_ | |||||
| } | } | ||||
| void AscendSession::AdjustKernel(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::AdjustKernel(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| device::KernelAdjust::GetInstance().Reorder(kernel_graph); | device::KernelAdjust::GetInstance().Reorder(kernel_graph); | ||||
| opt::HideNopNode(kernel_graph.get()); | opt::HideNopNode(kernel_graph.get()); | ||||
| // Insert CLearZero op | // Insert CLearZero op | ||||
| @@ -301,7 +301,7 @@ void AscendSession::AdjustKernel(const std::shared_ptr<KernelGraph> &kernel_grap | |||||
| } | } | ||||
| void AscendSession::RunOpAdjustKernel(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::RunOpAdjustKernel(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| opt::HideNopNode(kernel_graph.get()); | opt::HideNopNode(kernel_graph.get()); | ||||
| // Insert CLearZero op | // Insert CLearZero op | ||||
| // prepare for next step from json get atomic info | // prepare for next step from json get atomic info | ||||
| @@ -311,18 +311,18 @@ void AscendSession::RunOpAdjustKernel(const std::shared_ptr<KernelGraph> &kernel | |||||
| } | } | ||||
| void AscendSession::AssignStream(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::AssignStream(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| device::ascend::AscendStreamAssign::GetInstance().AssignStreamNew(kernel_graph); | device::ascend::AscendStreamAssign::GetInstance().AssignStreamNew(kernel_graph); | ||||
| MS_LOG(INFO) << "Finish!"; | MS_LOG(INFO) << "Finish!"; | ||||
| } | } | ||||
| void AscendSession::BuildKernel(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::BuildKernel(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| struct timeval start_time, end_time; | struct timeval start_time, end_time; | ||||
| (void)gettimeofday(&start_time, nullptr); | (void)gettimeofday(&start_time, nullptr); | ||||
| auto ret = device::ascend::KernelBuild(kernel_graph.get()); | auto ret = device::ascend::KernelBuild(kernel_graph.get()); | ||||
| if (!ret) { | if (!ret) { | ||||
| MS_LOG(EXCEPTION) << "kernel build error."; | |||||
| MS_LOG(EXCEPTION) << "Kernel build error."; | |||||
| } | } | ||||
| (void)gettimeofday(&end_time, nullptr); | (void)gettimeofday(&end_time, nullptr); | ||||
| const uint64_t kUSecondInSecond = 1000000; | const uint64_t kUSecondInSecond = 1000000; | ||||
| @@ -333,7 +333,7 @@ void AscendSession::BuildKernel(const std::shared_ptr<KernelGraph> &kernel_graph | |||||
| } | } | ||||
| void AscendSession::MemoryAlloc(KernelGraph *kernel_graph) const { | void AscendSession::MemoryAlloc(KernelGraph *kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| MS_EXCEPTION_IF_NULL(kernel_graph); | MS_EXCEPTION_IF_NULL(kernel_graph); | ||||
| opt::RemoveNopNode(kernel_graph); | opt::RemoveNopNode(kernel_graph); | ||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| @@ -344,7 +344,7 @@ void AscendSession::MemoryAlloc(KernelGraph *kernel_graph) const { | |||||
| void AscendSession::RunOpMemoryAlloc(const std::vector<tensor::TensorPtr> &input_tensors, | void AscendSession::RunOpMemoryAlloc(const std::vector<tensor::TensorPtr> &input_tensors, | ||||
| KernelGraph *kernel_graph) const { | KernelGraph *kernel_graph) const { | ||||
| MS_LOG(INFO) << "start memory alloc!"; | |||||
| MS_LOG(INFO) << "Start memory alloc!"; | |||||
| MS_EXCEPTION_IF_NULL(kernel_graph); | MS_EXCEPTION_IF_NULL(kernel_graph); | ||||
| opt::RemoveNopNode(kernel_graph); | opt::RemoveNopNode(kernel_graph); | ||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| @@ -354,30 +354,30 @@ void AscendSession::RunOpMemoryAlloc(const std::vector<tensor::TensorPtr> &input | |||||
| } | } | ||||
| void AscendSession::GenerateTaskInfo(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::GenerateTaskInfo(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| (void)device::KernelAdjust::GetInstance().StepLoadCtrlInputs(context_, kernel_graph); | (void)device::KernelAdjust::GetInstance().StepLoadCtrlInputs(context_, kernel_graph); | ||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| MS_EXCEPTION_IF_NULL(runtime_instance); | MS_EXCEPTION_IF_NULL(runtime_instance); | ||||
| bool ret_ok = runtime_instance->GenTask(kernel_graph.get()); | bool ret_ok = runtime_instance->GenTask(kernel_graph.get()); | ||||
| if (!ret_ok) { | if (!ret_ok) { | ||||
| MS_LOG(EXCEPTION) << "generate task error!"; | |||||
| MS_LOG(EXCEPTION) << "Generate task error!"; | |||||
| } | } | ||||
| MS_LOG(INFO) << "Finish!"; | MS_LOG(INFO) << "Finish!"; | ||||
| } | } | ||||
| void AscendSession::LoadTask(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::LoadTask(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| MS_EXCEPTION_IF_NULL(runtime_instance); | MS_EXCEPTION_IF_NULL(runtime_instance); | ||||
| bool ret_ok = runtime_instance->LoadTask(kernel_graph.get()); | bool ret_ok = runtime_instance->LoadTask(kernel_graph.get()); | ||||
| if (!ret_ok) { | if (!ret_ok) { | ||||
| MS_LOG(EXCEPTION) << "load task error!"; | |||||
| MS_LOG(EXCEPTION) << "Load task error!"; | |||||
| } | } | ||||
| MS_LOG(INFO) << "Finish!"; | MS_LOG(INFO) << "Finish!"; | ||||
| } | } | ||||
| void AscendSession::ExecTask(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::ExecTask(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| MS_EXCEPTION_IF_NULL(runtime_instance); | MS_EXCEPTION_IF_NULL(runtime_instance); | ||||
| bool ret_ok = runtime_instance->Run(kernel_graph.get()); | bool ret_ok = runtime_instance->Run(kernel_graph.get()); | ||||
| @@ -388,7 +388,7 @@ void AscendSession::ExecTask(const std::shared_ptr<KernelGraph> &kernel_graph) c | |||||
| } | } | ||||
| void AscendSession::Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const { | void AscendSession::Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const { | ||||
| MS_LOG(INFO) << "start !"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| MS_EXCEPTION_IF_NULL(kernel_graph); | MS_EXCEPTION_IF_NULL(kernel_graph); | ||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_); | ||||
| MS_EXCEPTION_IF_NULL(runtime_instance); | MS_EXCEPTION_IF_NULL(runtime_instance); | ||||
| @@ -397,7 +397,7 @@ void AscendSession::Dump(const std::shared_ptr<KernelGraph> &kernel_graph) const | |||||
| } | } | ||||
| GraphId AscendSession::SetFinalGraphInput(const std::vector<AnfNodePtr> &args) { | GraphId AscendSession::SetFinalGraphInput(const std::vector<AnfNodePtr> &args) { | ||||
| MS_LOG(INFO) << "start!args size " << args.size(); | |||||
| MS_LOG(INFO) << "Start! Args size " << args.size(); | |||||
| auto final_graph = std::make_shared<KernelGraph>(); | auto final_graph = std::make_shared<KernelGraph>(); | ||||
| final_graph_id_ = graph_sum_++; | final_graph_id_ = graph_sum_++; | ||||
| graphs_[final_graph_id_] = final_graph; | graphs_[final_graph_id_] = final_graph; | ||||
| @@ -417,12 +417,12 @@ GraphId AscendSession::SetFinalGraphInput(const std::vector<AnfNodePtr> &args) { | |||||
| if (parameter_belong_graph_id == kInvalidGraphId) { | if (parameter_belong_graph_id == kInvalidGraphId) { | ||||
| parameter_backend = final_graph->NewParameter(parameter->cast<ParameterPtr>()); | parameter_backend = final_graph->NewParameter(parameter->cast<ParameterPtr>()); | ||||
| final_graph->FrontBackendlMapAdd(parameter, parameter_backend); | final_graph->FrontBackendlMapAdd(parameter, parameter_backend); | ||||
| MS_LOG(INFO) << "new parameter" << parameter->DebugString() << "in final_graph"; | |||||
| MS_LOG(INFO) << "New parameter" << parameter->DebugString() << "in final_graph"; | |||||
| } else { | } else { | ||||
| // parametr is a parameter of child graph | // parametr is a parameter of child graph | ||||
| auto graph = GetGraph(parameter_belong_graph_id); | auto graph = GetGraph(parameter_belong_graph_id); | ||||
| MS_EXCEPTION_IF_NULL(graph); | MS_EXCEPTION_IF_NULL(graph); | ||||
| MS_LOG(INFO) << "reuse parameter [" << parameter->DebugString() << "] of child graph [" | |||||
| MS_LOG(INFO) << "Reuse parameter [" << parameter->DebugString() << "] of child graph [" | |||||
| << parameter_belong_graph_id << "]"; | << parameter_belong_graph_id << "]"; | ||||
| parameter_backend = graph->GetBackendAnfByFrontAnf(parameter); | parameter_backend = graph->GetBackendAnfByFrontAnf(parameter); | ||||
| } | } | ||||
| @@ -434,7 +434,7 @@ GraphId AscendSession::SetFinalGraphInput(const std::vector<AnfNodePtr> &args) { | |||||
| MS_EXCEPTION_IF_NULL(final_graph_inputs); | MS_EXCEPTION_IF_NULL(final_graph_inputs); | ||||
| final_graph_inputs->push_back(parameter_backend); | final_graph_inputs->push_back(parameter_backend); | ||||
| } | } | ||||
| MS_LOG(INFO) << "end final_graph_id " << final_graph_id_; | |||||
| MS_LOG(INFO) << "End final_graph_id " << final_graph_id_; | |||||
| return final_graph_id_; | return final_graph_id_; | ||||
| } | } | ||||
| @@ -453,7 +453,7 @@ void AscendSession::SetFinalGraphOutput(const BaseRef &output) { | |||||
| value_node->set_abstract(abstract::FromValue(value_ptr)); | value_node->set_abstract(abstract::FromValue(value_ptr)); | ||||
| final_graph->set_output(final_graph->NewCNode({NewValueNode(prim::kPrimMakeTuple), value_node})); | final_graph->set_output(final_graph->NewCNode({NewValueNode(prim::kPrimMakeTuple), value_node})); | ||||
| final_graph->set_executable(false); | final_graph->set_executable(false); | ||||
| MS_LOG(INFO) << "not anf output[" << output.ToString() << "]"; | |||||
| MS_LOG(INFO) << "Not anf output[" << output.ToString() << "]"; | |||||
| return; | return; | ||||
| } | } | ||||
| // get the backend anf node related to the output node of front | // get the backend anf node related to the output node of front | ||||
| @@ -461,12 +461,12 @@ void AscendSession::SetFinalGraphOutput(const BaseRef &output) { | |||||
| auto output_from_graph_id = GetGraphIdByNode(output_anf_node); | auto output_from_graph_id = GetGraphIdByNode(output_anf_node); | ||||
| auto output_from_graph = GetGraph(output_from_graph_id); | auto output_from_graph = GetGraph(output_from_graph_id); | ||||
| MS_EXCEPTION_IF_NULL(output_anf_node); | MS_EXCEPTION_IF_NULL(output_anf_node); | ||||
| MS_LOG(INFO) << "set the output[" << output_anf_node->DebugString() << "] of graph[" << output_from_graph_id | |||||
| MS_LOG(INFO) << "Set the output[" << output_anf_node->DebugString() << "] of graph[" << output_from_graph_id | |||||
| << "] to final graph"; | << "] to final graph"; | ||||
| MS_EXCEPTION_IF_NULL(output_from_graph); | MS_EXCEPTION_IF_NULL(output_from_graph); | ||||
| // if output is from final graph,it remarks no child graph exist | // if output is from final graph,it remarks no child graph exist | ||||
| if (final_graph_id_ == output_from_graph_id) { | if (final_graph_id_ == output_from_graph_id) { | ||||
| MS_LOG(INFO) << "no child graph,output is " << output_anf_node->DebugString(); | |||||
| MS_LOG(INFO) << "No child graph,output is " << output_anf_node->DebugString(); | |||||
| final_graph->set_output(ConstructOutput({output_anf_node}, final_graph)); | final_graph->set_output(ConstructOutput({output_anf_node}, final_graph)); | ||||
| final_graph->set_executable(false); | final_graph->set_executable(false); | ||||
| return; | return; | ||||
| @@ -477,15 +477,15 @@ void AscendSession::SetFinalGraphOutput(const BaseRef &output) { | |||||
| KernelGraphPtr AscendSession::GetGraph(mindspore::GraphId graph_id) { | KernelGraphPtr AscendSession::GetGraph(mindspore::GraphId graph_id) { | ||||
| auto it = graphs_.find(graph_id); | auto it = graphs_.find(graph_id); | ||||
| if (it == graphs_.end()) { | if (it == graphs_.end()) { | ||||
| MS_LOG(WARNING) << "can't find graph " << graph_id; | |||||
| MS_LOG(WARNING) << "Can't find graph " << graph_id; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| return it->second; | return it->second; | ||||
| } | } | ||||
| void AscendSession::InsertSwitchToGraph(GraphId condition_graph_id, GraphId true_graph_id) { | void AscendSession::InsertSwitchToGraph(GraphId condition_graph_id, GraphId true_graph_id) { | ||||
| MS_LOG(INFO) << "start"; | |||||
| MS_LOG(INFO) << "condition graph id[" << condition_graph_id << "],true graph id[" << true_graph_id << "]"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| MS_LOG(INFO) << "Condition graph id[" << condition_graph_id << "],true graph id[" << true_graph_id << "]"; | |||||
| auto condition_graph = GetGraph(condition_graph_id); | auto condition_graph = GetGraph(condition_graph_id); | ||||
| MS_EXCEPTION_IF_NULL(condition_graph); | MS_EXCEPTION_IF_NULL(condition_graph); | ||||
| tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(kNumberTypeInt32, std::vector<int>{1}); | tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(kNumberTypeInt32, std::vector<int>{1}); | ||||
| @@ -507,7 +507,7 @@ void AscendSession::InsertSwitchToGraph(GraphId condition_graph_id, GraphId true | |||||
| kernel_build_info_builder->SetKernelType(KernelType::RT_KERNEL); | kernel_build_info_builder->SetKernelType(KernelType::RT_KERNEL); | ||||
| // condition graph's output must be single output | // condition graph's output must be single output | ||||
| if (condition_graph->outputs().size() != 1) { | if (condition_graph->outputs().size() != 1) { | ||||
| MS_LOG(EXCEPTION) << "condition_graph output num " << condition_graph_id << " should be 1"; | |||||
| MS_LOG(EXCEPTION) << "Condition_graph output num " << condition_graph_id << " should be 1"; | |||||
| } | } | ||||
| AnfNodePtr cond_output_kernel = condition_graph->outputs()[0]; | AnfNodePtr cond_output_kernel = condition_graph->outputs()[0]; | ||||
| std::vector<AnfNodePtr> inputs = {NewValueNode(switch_primitive), cond_output_kernel, counter_const}; | std::vector<AnfNodePtr> inputs = {NewValueNode(switch_primitive), cond_output_kernel, counter_const}; | ||||
| @@ -527,7 +527,7 @@ void AscendSession::InsertSwitchToGraph(GraphId condition_graph_id, GraphId true | |||||
| std::vector<CNodePtr> exec_order = condition_graph->execution_order(); | std::vector<CNodePtr> exec_order = condition_graph->execution_order(); | ||||
| exec_order.push_back(switch_node); | exec_order.push_back(switch_node); | ||||
| condition_graph->set_execution_order(exec_order); | condition_graph->set_execution_order(exec_order); | ||||
| MS_LOG(INFO) << "end"; | |||||
| MS_LOG(INFO) << "Finish!"; | |||||
| } | } | ||||
| void AscendSession::CopyOutputOfIf(GraphId false_graph_id) { | void AscendSession::CopyOutputOfIf(GraphId false_graph_id) { | ||||
| @@ -540,11 +540,11 @@ void AscendSession::CopyOutputOfIf(GraphId false_graph_id) { | |||||
| for (int i = SizeToInt(false_index) - 1; i >= 0; i--) { | for (int i = SizeToInt(false_index) - 1; i >= 0; i--) { | ||||
| size_t graph_index = IntToSize(i); | size_t graph_index = IntToSize(i); | ||||
| if (graph_index >= graph_execute_order.size()) { | if (graph_index >= graph_execute_order.size()) { | ||||
| MS_LOG(EXCEPTION) << "graph index[" << graph_index << "] out of range[" << graph_execute_order.size() << "]"; | |||||
| MS_LOG(EXCEPTION) << "Graph index[" << graph_index << "] out of range[" << graph_execute_order.size() << "]"; | |||||
| } | } | ||||
| if (graph_order_type[graph_index] == COMMON_GRAPH) { | if (graph_order_type[graph_index] == COMMON_GRAPH) { | ||||
| auto true_last_id = graph_execute_order[graph_index]; | auto true_last_id = graph_execute_order[graph_index]; | ||||
| MS_LOG(INFO) << "the last graph of if true branch is " << true_last_id; | |||||
| MS_LOG(INFO) << "The last graph of if true branch is " << true_last_id; | |||||
| auto true_last = GetGraph(true_last_id); | auto true_last = GetGraph(true_last_id); | ||||
| auto final_graph = GetGraph(final_graph_id_); | auto final_graph = GetGraph(final_graph_id_); | ||||
| MS_EXCEPTION_IF_NULL(final_graph); | MS_EXCEPTION_IF_NULL(final_graph); | ||||
| @@ -552,10 +552,10 @@ void AscendSession::CopyOutputOfIf(GraphId false_graph_id) { | |||||
| auto false_last = GetGraph(false_last_id); | auto false_last = GetGraph(false_last_id); | ||||
| MS_EXCEPTION_IF_NULL(true_last); | MS_EXCEPTION_IF_NULL(true_last); | ||||
| MS_EXCEPTION_IF_NULL(false_last); | MS_EXCEPTION_IF_NULL(false_last); | ||||
| MS_LOG(INFO) << "the last graph of false branch is " << false_last_id; | |||||
| MS_LOG(INFO) << "The last graph of false branch is " << false_last_id; | |||||
| // now only consider the single output | // now only consider the single output | ||||
| InsertMultipleAssignToGraph(true_last_id, true_last->output(), false_last->output()); | InsertMultipleAssignToGraph(true_last_id, true_last->output(), false_last->output()); | ||||
| // insert stream acitve for loop sink | |||||
| // insert stream active for loop sink | |||||
| auto context_ptr = MsContext::GetInstance(); | auto context_ptr = MsContext::GetInstance(); | ||||
| MS_EXCEPTION_IF_NULL(context_ptr); | MS_EXCEPTION_IF_NULL(context_ptr); | ||||
| if (context_ptr->enable_task_sink() && context_ptr->loop_sink_flag() && | if (context_ptr->enable_task_sink() && context_ptr->loop_sink_flag() && | ||||
| @@ -569,32 +569,32 @@ void AscendSession::CopyOutputOfIf(GraphId false_graph_id) { | |||||
| } | } | ||||
| void AscendSession::SwitchCompile(GraphId cond_graph_id, GraphId true_graph_id, GraphId false_graph_id) { | void AscendSession::SwitchCompile(GraphId cond_graph_id, GraphId true_graph_id, GraphId false_graph_id) { | ||||
| if (switchs_.find(cond_graph_id) != switchs_.end()) { | |||||
| MS_LOG(WARNING) << "condition graph" << cond_graph_id << " has been set before "; | |||||
| if (switches_.find(cond_graph_id) != switches_.end()) { | |||||
| MS_LOG(WARNING) << "Condition graph" << cond_graph_id << " has been set before "; | |||||
| return; | return; | ||||
| } | } | ||||
| switchs_[cond_graph_id] = std::pair<GraphId, GraphId>(true_graph_id, false_graph_id); | |||||
| MS_LOG(INFO) << "new switch compile " << cond_graph_id << " " << true_graph_id << " " << false_graph_id; | |||||
| // set the type of condtion graph | |||||
| switches_[cond_graph_id] = std::pair<GraphId, GraphId>(true_graph_id, false_graph_id); | |||||
| MS_LOG(INFO) << "New switch compile " << cond_graph_id << " " << true_graph_id << " " << false_graph_id; | |||||
| // set the type of condition graph | |||||
| auto cond_graph_index = ExecOrderOfChildGraph(final_graph_id_, cond_graph_id); | auto cond_graph_index = ExecOrderOfChildGraph(final_graph_id_, cond_graph_id); | ||||
| auto &graph_order_type = GetGraphOrderType(final_graph_id_); | auto &graph_order_type = GetGraphOrderType(final_graph_id_); | ||||
| if (cond_graph_index >= graph_order_type.size()) { | if (cond_graph_index >= graph_order_type.size()) { | ||||
| MS_LOG(EXCEPTION) << "cond_graph_index " << cond_graph_index << " out of range " << graph_order_types_.size(); | MS_LOG(EXCEPTION) << "cond_graph_index " << cond_graph_index << " out of range " << graph_order_types_.size(); | ||||
| } | } | ||||
| graph_order_type[cond_graph_index] = CONDITION_GRAPH; | graph_order_type[cond_graph_index] = CONDITION_GRAPH; | ||||
| // update disinction label of false graph,update before merge to sure the distinction | |||||
| // update distinction label of false graph,update before merge to sure the distinction | |||||
| if (false_graph_id != kInvalidGraphId) { | if (false_graph_id != kInvalidGraphId) { | ||||
| // false graph and condition in graph same stream | // false graph and condition in graph same stream | ||||
| auto conditon_graph = GetGraph(cond_graph_id); | |||||
| SetStreamDistinctionLabel(GetGraph(false_graph_id), GetDistinctionLabel(conditon_graph), true); | |||||
| auto condition_graph = GetGraph(cond_graph_id); | |||||
| SetStreamDistinctionLabel(GetGraph(false_graph_id), GetDistinctionLabel(condition_graph), true); | |||||
| // if false graph is a condition graph and has been switch compiled before,it's false should be updated again | // if false graph is a condition graph and has been switch compiled before,it's false should be updated again | ||||
| auto cond_it = switchs_.find(false_graph_id); | |||||
| while (cond_it != switchs_.end() && cond_it->second.second != kInvalidGraphId) { | |||||
| auto cond_it = switches_.find(false_graph_id); | |||||
| while (cond_it != switches_.end() && cond_it->second.second != kInvalidGraphId) { | |||||
| cond_graph_id = cond_it->first; | cond_graph_id = cond_it->first; | ||||
| false_graph_id = cond_it->second.second; | false_graph_id = cond_it->second.second; | ||||
| conditon_graph = GetGraph(cond_graph_id); | |||||
| SetStreamDistinctionLabel(GetGraph(false_graph_id), GetDistinctionLabel(conditon_graph), true); | |||||
| cond_it = switchs_.find(false_graph_id); | |||||
| condition_graph = GetGraph(cond_graph_id); | |||||
| SetStreamDistinctionLabel(GetGraph(false_graph_id), GetDistinctionLabel(condition_graph), true); | |||||
| cond_it = switches_.find(false_graph_id); | |||||
| } | } | ||||
| } | } | ||||
| } // namespace session | } // namespace session | ||||
| @@ -602,11 +602,11 @@ void AscendSession::SwitchCompile(GraphId cond_graph_id, GraphId true_graph_id, | |||||
| void AscendSession::MergeSwitchCompile() { | void AscendSession::MergeSwitchCompile() { | ||||
| auto graph_execute_order = GetGraphOrder(final_graph_id_); | auto graph_execute_order = GetGraphOrder(final_graph_id_); | ||||
| auto &graph_order_type = GetGraphOrderType(final_graph_id_); | auto &graph_order_type = GetGraphOrderType(final_graph_id_); | ||||
| for (auto switch_compile : switchs_) { | |||||
| for (auto switch_compile : switches_) { | |||||
| auto cond_graph_id = switch_compile.first; | auto cond_graph_id = switch_compile.first; | ||||
| auto true_graph_id = switch_compile.second.first; | auto true_graph_id = switch_compile.second.first; | ||||
| auto false_graph_id = switch_compile.second.second; | auto false_graph_id = switch_compile.second.second; | ||||
| MS_LOG(INFO) << "switch compile: " << cond_graph_id << " " << true_graph_id << " " << false_graph_id; | |||||
| MS_LOG(INFO) << "Switch compile: " << cond_graph_id << " " << true_graph_id << " " << false_graph_id; | |||||
| auto condition_graph = GetGraph(cond_graph_id); | auto condition_graph = GetGraph(cond_graph_id); | ||||
| auto final_graph = GetGraph(final_graph_id_); | auto final_graph = GetGraph(final_graph_id_); | ||||
| MS_EXCEPTION_IF_NULL(condition_graph); | MS_EXCEPTION_IF_NULL(condition_graph); | ||||
| @@ -630,8 +630,8 @@ void AscendSession::MergeSwitchCompile() { | |||||
| InsertStreamActiveToGraph(prev_graph_id, GetDistinctionLabel(condition_graph)); | InsertStreamActiveToGraph(prev_graph_id, GetDistinctionLabel(condition_graph)); | ||||
| } | } | ||||
| // if this is a 'if' condition | // if this is a 'if' condition | ||||
| auto it = while_condtion_graphs_.find(cond_graph_id); | |||||
| if (it == while_condtion_graphs_.end()) { | |||||
| auto it = while_condition_graphs_.find(cond_graph_id); | |||||
| if (it == while_condition_graphs_.end()) { | |||||
| CopyOutputOfIf(false_graph_id); | CopyOutputOfIf(false_graph_id); | ||||
| } else { | } else { | ||||
| // if it is a while,insert a stream active to true graph | // if it is a while,insert a stream active to true graph | ||||
| @@ -639,17 +639,17 @@ void AscendSession::MergeSwitchCompile() { | |||||
| InsertStreamActiveToGraph(from_graph, GetDistinctionLabel(condition_graph)); | InsertStreamActiveToGraph(from_graph, GetDistinctionLabel(condition_graph)); | ||||
| } | } | ||||
| } | } | ||||
| MS_LOG(INFO) << "end"; | |||||
| MS_LOG(INFO) << "Finish!"; | |||||
| } | } | ||||
| // insert active to graph | // insert active to graph | ||||
| void AscendSession::SetActive(GraphId from, GraphId to) { | void AscendSession::SetActive(GraphId from, GraphId to) { | ||||
| if (while_condtion_graphs_.find(to) != while_condtion_graphs_.end()) { | |||||
| if (while_condition_graphs_.find(to) != while_condition_graphs_.end()) { | |||||
| MS_LOG(WARNING) << " to " << to << " has been exits in map,from " << from << ",exist from " | MS_LOG(WARNING) << " to " << to << " has been exits in map,from " << from << ",exist from " | ||||
| << while_condtion_graphs_[to]; | |||||
| << while_condition_graphs_[to]; | |||||
| return; | return; | ||||
| } | } | ||||
| MS_LOG(INFO) << "from " << from << " to " << to; | |||||
| MS_LOG(INFO) << "From " << from << " to " << to; | |||||
| auto &graph_order = GetGraphOrder(final_graph_id_); | auto &graph_order = GetGraphOrder(final_graph_id_); | ||||
| auto &graph_type = GetGraphOrderType(final_graph_id_); | auto &graph_type = GetGraphOrderType(final_graph_id_); | ||||
| std::vector<GraphId> graph_order_new; | std::vector<GraphId> graph_order_new; | ||||
| @@ -668,21 +668,21 @@ void AscendSession::SetActive(GraphId from, GraphId to) { | |||||
| // set the graph type of condition graph | // set the graph type of condition graph | ||||
| graph_type[ExecOrderOfChildGraph(final_graph_id_, to)] = CONDITION_GRAPH; | graph_type[ExecOrderOfChildGraph(final_graph_id_, to)] = CONDITION_GRAPH; | ||||
| // record the condition graph into while condition set | // record the condition graph into while condition set | ||||
| while_condtion_graphs_[to] = from; | |||||
| while_condition_graphs_[to] = from; | |||||
| } | } | ||||
| void AscendSession::SetChildGraphParameter(const AnfNodePtr &front_anf, const AnfNodePtr &backend_parameter) { | void AscendSession::SetChildGraphParameter(const AnfNodePtr &front_anf, const AnfNodePtr &backend_parameter) { | ||||
| MS_LOG(INFO) << "start"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| MS_EXCEPTION_IF_NULL(backend_parameter); | MS_EXCEPTION_IF_NULL(backend_parameter); | ||||
| MS_EXCEPTION_IF_NULL(front_anf); | MS_EXCEPTION_IF_NULL(front_anf); | ||||
| if (!backend_parameter->isa<Parameter>()) { | if (!backend_parameter->isa<Parameter>()) { | ||||
| MS_LOG(EXCEPTION) << "backend parameter's type is not a parameter,but is " << backend_parameter->ToString(); | |||||
| MS_LOG(EXCEPTION) << "Backend parameter's type is not a parameter,but is " << backend_parameter->ToString(); | |||||
| } | } | ||||
| auto from_graph_id = GetGraphIdByNode(front_anf); | auto from_graph_id = GetGraphIdByNode(front_anf); | ||||
| auto from_graph = GetGraph(from_graph_id); | auto from_graph = GetGraph(from_graph_id); | ||||
| MS_EXCEPTION_IF_NULL(from_graph); | MS_EXCEPTION_IF_NULL(from_graph); | ||||
| MS_LOG(INFO) << "set node[" << front_anf->DebugString() << "] of graph[" << from_graph_id << "]to node[" | |||||
| MS_LOG(INFO) << "Set node[" << front_anf->DebugString() << "] of graph[" << from_graph_id << "]to node[" | |||||
| << backend_parameter->DebugString() << "] of graph[" << AnfAlgo::GetGraphId(backend_parameter.get()) | << backend_parameter->DebugString() << "] of graph[" << AnfAlgo::GetGraphId(backend_parameter.get()) | ||||
| << "]"; | << "]"; | ||||
| // a node should not assign to itself | // a node should not assign to itself | ||||
| @@ -696,26 +696,27 @@ void AscendSession::SetChildGraphParameter(const AnfNodePtr &front_anf, const An | |||||
| if (!AnfAlgo::OutputAddrExist(backend_arg, 0)) { | if (!AnfAlgo::OutputAddrExist(backend_arg, 0)) { | ||||
| // set parameter's addr in child graph to parameter in final graph | // set parameter's addr in child graph to parameter in final graph | ||||
| AnfAlgo::SetOutputAddr(AnfAlgo::GetMutableOutputAddr(backend_parameter, 0), 0, backend_arg.get()); | AnfAlgo::SetOutputAddr(AnfAlgo::GetMutableOutputAddr(backend_parameter, 0), 0, backend_arg.get()); | ||||
| MS_LOG(INFO) << "assign mem of node" << backend_parameter->DebugString() << " of graph " | |||||
| MS_LOG(INFO) << "Assign mem of node" << backend_parameter->DebugString() << " of graph " | |||||
| << AnfAlgo::GetGraphId(backend_parameter.get()) << " to node" << backend_arg->DebugString() | << AnfAlgo::GetGraphId(backend_parameter.get()) << " to node" << backend_arg->DebugString() | ||||
| << "of graph " << AnfAlgo::GetGraphId(backend_arg.get()); | << "of graph " << AnfAlgo::GetGraphId(backend_arg.get()); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| InsertMultipleAssignToGraph(from_graph_id, backend_arg, backend_parameter); | InsertMultipleAssignToGraph(from_graph_id, backend_arg, backend_parameter); | ||||
| // if front anf is a parameter,we can assign the value back,because backend_parameter won't be change in it's graph | |||||
| // unless it's a weigth.If backend_parameter is a weight,we do should assign the value back | |||||
| // if front anf is a parameter, we can assign the value back, because backend_parameter | |||||
| // won't be changed in it's graph unless it's a weight. If backend_parameter is a weight, | |||||
| // we do should assign the value back. | |||||
| auto to_graph_id = AnfAlgo::GetGraphId(backend_parameter.get()); | auto to_graph_id = AnfAlgo::GetGraphId(backend_parameter.get()); | ||||
| auto to_graph = GetGraph(to_graph_id); | auto to_graph = GetGraph(to_graph_id); | ||||
| MS_EXCEPTION_IF_NULL(to_graph); | MS_EXCEPTION_IF_NULL(to_graph); | ||||
| if (backend_arg->isa<Parameter>() && !to_graph->execution_order().empty()) { | if (backend_arg->isa<Parameter>() && !to_graph->execution_order().empty()) { | ||||
| InsertMultipleAssignToGraph(to_graph_id, backend_parameter, backend_arg); | InsertMultipleAssignToGraph(to_graph_id, backend_parameter, backend_arg); | ||||
| } | } | ||||
| MS_LOG(INFO) << "end"; | |||||
| MS_LOG(INFO) << "Finish!"; | |||||
| } | } | ||||
| void AscendSession::SetChildGraphParameter(const tensor::TensorPtr &front_tensor, const AnfNodePtr &backend_parameter) { | void AscendSession::SetChildGraphParameter(const tensor::TensorPtr &front_tensor, const AnfNodePtr &backend_parameter) { | ||||
| MS_LOG(INFO) << "start"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| // sync data from host to device | // sync data from host to device | ||||
| MS_EXCEPTION_IF_NULL(front_tensor); | MS_EXCEPTION_IF_NULL(front_tensor); | ||||
| size_t tensor_size = front_tensor->data().nbytes(); | size_t tensor_size = front_tensor->data().nbytes(); | ||||
| @@ -723,9 +724,9 @@ void AscendSession::SetChildGraphParameter(const tensor::TensorPtr &front_tensor | |||||
| MS_EXCEPTION_IF_NULL(addr); | MS_EXCEPTION_IF_NULL(addr); | ||||
| if (!addr->SyncHostToDevice(front_tensor->shape(), tensor_size, front_tensor->data_type(), | if (!addr->SyncHostToDevice(front_tensor->shape(), tensor_size, front_tensor->data_type(), | ||||
| front_tensor->data_c(false))) { | front_tensor->data_c(false))) { | ||||
| MS_LOG(EXCEPTION) << "tensor SyncHostToDevice fail!"; | |||||
| MS_LOG(EXCEPTION) << "Tensor SyncHostToDevice fail!"; | |||||
| } | } | ||||
| MS_LOG(INFO) << "end"; | |||||
| MS_LOG(INFO) << "Finish!"; | |||||
| } | } | ||||
| void AscendSession::UpdateGraphOrder(GraphId to_graph_id) { | void AscendSession::UpdateGraphOrder(GraphId to_graph_id) { | ||||
| @@ -742,7 +743,7 @@ void AscendSession::UpdateGraphOrder(GraphId to_graph_id) { | |||||
| graph_order.push_back(to_graph_id); | graph_order.push_back(to_graph_id); | ||||
| graph_type.push_back(COMMON_GRAPH); | graph_type.push_back(COMMON_GRAPH); | ||||
| for (size_t i = 0; i < graph_order.size(); i++) { | for (size_t i = 0; i < graph_order.size(); i++) { | ||||
| MS_LOG(INFO) << "index " << i << ",graph_id " << graph_order[i] << ",graph_type" << graph_type[i]; | |||||
| MS_LOG(INFO) << "Index " << i << ",graph_id " << graph_order[i] << ",graph_type" << graph_type[i]; | |||||
| } | } | ||||
| } | } | ||||
| @@ -774,10 +775,10 @@ void AscendSession::SetChildGraphInput(GraphId g, const VectorRef &args) { | |||||
| SetChildGraphParameter(value->cast<TensorPtr>(), graph_inputs[input_index]); | SetChildGraphParameter(value->cast<TensorPtr>(), graph_inputs[input_index]); | ||||
| input_index++; | input_index++; | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "Unxpected arg type " << args[i].ToString(); | |||||
| MS_LOG(EXCEPTION) << "Unexpected arg type " << args[i].ToString(); | |||||
| } | } | ||||
| } | } | ||||
| MS_LOG(INFO) << "end"; | |||||
| MS_LOG(INFO) << "Finish!"; | |||||
| } | } | ||||
| GraphId AscendSession::GetGraphIdByNode(const AnfNodePtr &front_anf) const { | GraphId AscendSession::GetGraphIdByNode(const AnfNodePtr &front_anf) const { | ||||
| @@ -795,7 +796,7 @@ GraphId AscendSession::GetGraphIdByNode(const AnfNodePtr &front_anf) const { | |||||
| } | } | ||||
| void AscendSession::MergeGraphExecOrder() { | void AscendSession::MergeGraphExecOrder() { | ||||
| MS_LOG(INFO) << "start"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| // insert switch to graph | // insert switch to graph | ||||
| MergeSwitchCompile(); | MergeSwitchCompile(); | ||||
| // merge graph order | // merge graph order | ||||
| @@ -804,7 +805,7 @@ void AscendSession::MergeGraphExecOrder() { | |||||
| auto final_graph = GetGraph(final_graph_id_); | auto final_graph = GetGraph(final_graph_id_); | ||||
| MS_EXCEPTION_IF_NULL(final_graph); | MS_EXCEPTION_IF_NULL(final_graph); | ||||
| if (graph_order.empty()) { | if (graph_order.empty()) { | ||||
| MS_LOG(WARNING) << "graph output is a lonely variable not linked to any op!"; | |||||
| MS_LOG(WARNING) << "Graph output is a lonely variable not linked to any op!"; | |||||
| return; | return; | ||||
| } | } | ||||
| // if first graph is common,the final graph has no label,then set the stream of final graph same with the first graph | // if first graph is common,the final graph has no label,then set the stream of final graph same with the first graph | ||||
| @@ -820,7 +821,7 @@ void AscendSession::MergeGraphExecOrder() { | |||||
| last_graph = child_graph; | last_graph = child_graph; | ||||
| MS_EXCEPTION_IF_NULL(child_graph); | MS_EXCEPTION_IF_NULL(child_graph); | ||||
| auto exec_order = child_graph->execution_order(); | auto exec_order = child_graph->execution_order(); | ||||
| MS_LOG(INFO) << "merge graph,graph_id " << graph_id; | |||||
| MS_LOG(INFO) << "Merge graph,graph_id " << graph_id; | |||||
| (void)std::copy(exec_order.begin(), exec_order.end(), std::back_inserter(final_exec_order)); | (void)std::copy(exec_order.begin(), exec_order.end(), std::back_inserter(final_exec_order)); | ||||
| // add all value nodes of child graphs to final graph | // add all value nodes of child graphs to final graph | ||||
| for (auto &value_node : child_graph->graph_value_nodes()) { | for (auto &value_node : child_graph->graph_value_nodes()) { | ||||
| @@ -874,11 +875,11 @@ void AscendSession::InsertAssignToGraph(GraphId graph_id, const AnfNodePtr &from | |||||
| void AscendSession::InsertMultipleAssignToGraph(GraphId graph_id, const AnfNodePtr &from, const AnfNodePtr &to) { | void AscendSession::InsertMultipleAssignToGraph(GraphId graph_id, const AnfNodePtr &from, const AnfNodePtr &to) { | ||||
| std::vector<AnfNodePtr> from_outputs = AnfAlgo::GetAllOutput(from, {prim::kPrimTupleGetItem}); | std::vector<AnfNodePtr> from_outputs = AnfAlgo::GetAllOutput(from, {prim::kPrimTupleGetItem}); | ||||
| std::vector<AnfNodePtr> to_outputs = AnfAlgo::GetAllOutput(to, {prim::kPrimTupleGetItem}); | std::vector<AnfNodePtr> to_outputs = AnfAlgo::GetAllOutput(to, {prim::kPrimTupleGetItem}); | ||||
| MS_LOG(INFO) << "insert assigns from [" << AnfAlgo::GetGraphId(from.get()) << "] to [" | |||||
| MS_LOG(INFO) << "Insert assigns from [" << AnfAlgo::GetGraphId(from.get()) << "] to [" | |||||
| << AnfAlgo::GetGraphId(to.get()) << "]"; | << AnfAlgo::GetGraphId(to.get()) << "]"; | ||||
| if (from_outputs.size() != to_outputs.size()) { | if (from_outputs.size() != to_outputs.size()) { | ||||
| MS_LOG(INFO) << "from[" << from->DebugString(5) << "] to[" << to->DebugString(5) << "]"; | |||||
| MS_LOG(EXCEPTION) << "from outputs size[" << from_outputs.size() << "] is not equal to to outputs size[" | |||||
| MS_LOG(INFO) << "From[" << from->DebugString(5) << "] to[" << to->DebugString(5) << "]"; | |||||
| MS_LOG(EXCEPTION) << "From outputs size[" << from_outputs.size() << "] is not equal to to outputs size[" | |||||
| << to_outputs.size() << "]"; | << to_outputs.size() << "]"; | ||||
| } | } | ||||
| for (size_t i = 0; i < from_outputs.size(); i++) { | for (size_t i = 0; i < from_outputs.size(); i++) { | ||||
| @@ -897,7 +898,7 @@ void AscendSession::InsertStreamActiveToGraph(GraphId graph_id, uint32_t actived | |||||
| auto kernel_build_info_builder = std::make_shared<kernel::KernelBuildInfo::KernelBuildInfoBuilder>(); | auto kernel_build_info_builder = std::make_shared<kernel::KernelBuildInfo::KernelBuildInfoBuilder>(); | ||||
| kernel_build_info_builder->SetKernelType(KernelType::RT_KERNEL); | kernel_build_info_builder->SetKernelType(KernelType::RT_KERNEL); | ||||
| AnfAlgo::SetSelectKernelBuildInfo(kernel_build_info_builder->Build(), active_node.get()); | AnfAlgo::SetSelectKernelBuildInfo(kernel_build_info_builder->Build(), active_node.get()); | ||||
| // set the actived stream id into the attr of active node | |||||
| // set the active stream id into the attr of active node | |||||
| std::vector<uint32_t> active_index_value = {}; | std::vector<uint32_t> active_index_value = {}; | ||||
| active_index_value.push_back(actived_stream); | active_index_value.push_back(actived_stream); | ||||
| AnfAlgo::SetNodeAttr(kAttrActiveStreamList, MakeValue<std::vector<uint32_t>>(active_index_value), active_node); | AnfAlgo::SetNodeAttr(kAttrActiveStreamList, MakeValue<std::vector<uint32_t>>(active_index_value), active_node); | ||||
| @@ -921,7 +922,7 @@ size_t AscendSession::ExecOrderOfChildGraph(GraphId final_graph, GraphId child_g | |||||
| std::vector<GraphId> &AscendSession::GetGraphOrder(GraphId final_graph_id) { | std::vector<GraphId> &AscendSession::GetGraphOrder(GraphId final_graph_id) { | ||||
| auto graph_order_iter = graph_execute_orders_.find(final_graph_id); | auto graph_order_iter = graph_execute_orders_.find(final_graph_id); | ||||
| if (graph_order_iter == graph_execute_orders_.end()) { | if (graph_order_iter == graph_execute_orders_.end()) { | ||||
| MS_LOG(EXCEPTION) << "final graph" << final_graph_id << "has no child graph"; | |||||
| MS_LOG(EXCEPTION) << "Final graph" << final_graph_id << "has no child graph"; | |||||
| } | } | ||||
| return graph_order_iter->second; | return graph_order_iter->second; | ||||
| } | } | ||||
| @@ -930,7 +931,7 @@ std::vector<GraphId> &AscendSession::GetGraphOrder(GraphId final_graph_id) { | |||||
| std::vector<GraphType> &AscendSession::GetGraphOrderType(GraphId final_graph_id) { | std::vector<GraphType> &AscendSession::GetGraphOrderType(GraphId final_graph_id) { | ||||
| auto graph_type_iter = graph_order_types_.find(final_graph_id); | auto graph_type_iter = graph_order_types_.find(final_graph_id); | ||||
| if (graph_type_iter == graph_order_types_.end()) { | if (graph_type_iter == graph_order_types_.end()) { | ||||
| MS_LOG(EXCEPTION) << "final graph" << final_graph_id << "has no graph_order_types_"; | |||||
| MS_LOG(EXCEPTION) << "Final graph" << final_graph_id << "has no graph_order_types_"; | |||||
| } | } | ||||
| return graph_type_iter->second; | return graph_type_iter->second; | ||||
| } | } | ||||
| @@ -48,13 +48,14 @@ class AscendSession : public SessionBasic { | |||||
| GraphId SetFinalGraphInput(const std::vector<AnfNodePtr> &args) override; | GraphId SetFinalGraphInput(const std::vector<AnfNodePtr> &args) override; | ||||
| // set output of final graph | // set output of final graph | ||||
| void SetFinalGraphOutput(const BaseRef &output) override; | void SetFinalGraphOutput(const BaseRef &output) override; | ||||
| // insert switch and set the relative acitve ops | |||||
| // insert switch and set the relative active ops | |||||
| void SwitchCompile(GraphId cond_g, GraphId true_g, GraphId false_g) override; | void SwitchCompile(GraphId cond_g, GraphId true_g, GraphId false_g) override; | ||||
| // set args of child graph.the arg maybe come from a output of other child graphs,or from final graph's parameter | |||||
| // set args of child graph. the arg maybe come from a output of other child graphs, | |||||
| // or from final graph's parameter | |||||
| void SetChildGraphInput(GraphId g, const VectorRef &args) override; | void SetChildGraphInput(GraphId g, const VectorRef &args) override; | ||||
| // get graph id in child graphs by ME front anf node pointer | // get graph id in child graphs by ME front anf node pointer | ||||
| GraphId GetGraphIdByNode(const AnfNodePtr &front_anf) const override; | GraphId GetGraphIdByNode(const AnfNodePtr &front_anf) const override; | ||||
| // get grpah id of final graph | |||||
| // get graph id of final graph | |||||
| GraphId GetFinalRunGraph() const override { return final_graph_id_; } | GraphId GetFinalRunGraph() const override { return final_graph_id_; } | ||||
| // insert active to graph | // insert active to graph | ||||
| void SetActive(GraphId, GraphId) override; | void SetActive(GraphId, GraphId) override; | ||||
| @@ -112,9 +113,9 @@ class AscendSession : public SessionBasic { | |||||
| // key is final_graph_id,value is the graph types of child graphs | // key is final_graph_id,value is the graph types of child graphs | ||||
| std::unordered_map<GraphId, std::vector<GraphType>> graph_order_types_; | std::unordered_map<GraphId, std::vector<GraphType>> graph_order_types_; | ||||
| // record condition graph of while | // record condition graph of while | ||||
| std::unordered_map<GraphId, GraphId> while_condtion_graphs_; | |||||
| // record all conditons | |||||
| std::unordered_map<GraphId, std::pair<GraphId, GraphId>> switchs_; | |||||
| std::unordered_map<GraphId, GraphId> while_condition_graphs_; | |||||
| // record all conditions | |||||
| std::unordered_map<GraphId, std::pair<GraphId, GraphId>> switches_; | |||||
| // final_graph_id is used in every root graph has it's own session situation | // final_graph_id is used in every root graph has it's own session situation | ||||
| GraphId final_graph_id_; | GraphId final_graph_id_; | ||||
| }; | }; | ||||
| @@ -83,7 +83,7 @@ void GPUSession::Execute(const std::shared_ptr<KernelGraph> &kernel_graph) const | |||||
| } | } | ||||
| GraphId GPUSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) { | GraphId GPUSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) { | ||||
| // Construct graph, if construct successs, graph_sum_ + 1 | |||||
| // Construct graph, if successfully, graph_sum_ + 1 | |||||
| auto graph_id = graph_sum_; | auto graph_id = graph_sum_; | ||||
| auto graph = ConstructKernelGraph(lst, outputs); | auto graph = ConstructKernelGraph(lst, outputs); | ||||
| // Select kernel build info | // Select kernel build info | ||||
| @@ -100,7 +100,7 @@ GraphId GPUSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList | |||||
| auto execution_order = graph->execution_order(); | auto execution_order = graph->execution_order(); | ||||
| Reorder(&execution_order); | Reorder(&execution_order); | ||||
| graph->set_execution_order(execution_order); | graph->set_execution_order(execution_order); | ||||
| // Alloc memeory, include static memory and dynamic memory | |||||
| // Alloc memory, including static memory and dynamic memory | |||||
| AllocateMemory(graph.get()); | AllocateMemory(graph.get()); | ||||
| // Reset memory resource | // Reset memory resource | ||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetSingleKernelRuntime(kGPUDevice, device_id_); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetSingleKernelRuntime(kGPUDevice, device_id_); | ||||
| @@ -34,7 +34,7 @@ void PushNoVisitedNode(const AnfNodePtr &node, std::queue<AnfNodePtr> *que, | |||||
| if (visited_nodes->find(node) == visited_nodes->end()) { | if (visited_nodes->find(node) == visited_nodes->end()) { | ||||
| que->push(node); | que->push(node); | ||||
| (void)visited_nodes->insert(node); | (void)visited_nodes->insert(node); | ||||
| MS_LOG(DEBUG) << "push que:" << node->DebugString(); | |||||
| MS_LOG(DEBUG) << "Push que:" << node->DebugString(); | |||||
| } | } | ||||
| } | } | ||||
| } // namespace | } // namespace | ||||
| @@ -58,7 +58,7 @@ void KernelGraph::SetExecOrderByDefault() { | |||||
| auto clear_output = [&zero_output_nodes, &allreduce_nodes, &visited_nodes, this](const AnfNodePtr &input) -> void { | auto clear_output = [&zero_output_nodes, &allreduce_nodes, &visited_nodes, this](const AnfNodePtr &input) -> void { | ||||
| if (node_output_num_[input] == 0 && visited_nodes.find(input) == visited_nodes.end()) { | if (node_output_num_[input] == 0 && visited_nodes.find(input) == visited_nodes.end()) { | ||||
| MS_EXCEPTION_IF_NULL(input); | MS_EXCEPTION_IF_NULL(input); | ||||
| MS_LOG(DEBUG) << "clear output num:" << input->DebugString(); | |||||
| MS_LOG(DEBUG) << "Clear output num:" << input->DebugString(); | |||||
| (void)visited_nodes.insert(input); | (void)visited_nodes.insert(input); | ||||
| if (input->isa<CNode>() && AnfAlgo::GetCNodeName(input) == kAllReduceOpName) { | if (input->isa<CNode>() && AnfAlgo::GetCNodeName(input) == kAllReduceOpName) { | ||||
| allreduce_nodes.push(input); | allreduce_nodes.push(input); | ||||
| @@ -85,21 +85,21 @@ void KernelGraph::SetExecOrderByDefault() { | |||||
| if (it == node_input_edges_.end()) { | if (it == node_input_edges_.end()) { | ||||
| // value node and parameter has no input,no need to print log | // value node and parameter has no input,no need to print log | ||||
| if (node->isa<CNode>()) { | if (node->isa<CNode>()) { | ||||
| MS_LOG(DEBUG) << "can not find node [" << node->DebugString() << "]"; | |||||
| MS_LOG(DEBUG) << "Can not find node [" << node->DebugString() << "]"; | |||||
| } | } | ||||
| continue; | continue; | ||||
| } | } | ||||
| for (const auto &input_edge : it->second) { | for (const auto &input_edge : it->second) { | ||||
| if (node_output_num_.find(input_edge.first) == node_output_num_.end()) { | if (node_output_num_.find(input_edge.first) == node_output_num_.end()) { | ||||
| MS_EXCEPTION_IF_NULL(input_edge.first); | MS_EXCEPTION_IF_NULL(input_edge.first); | ||||
| MS_LOG(EXCEPTION) << "can't find node[" << input_edge.first->DebugString() << "]"; | |||||
| MS_LOG(EXCEPTION) << "Can't find node[" << input_edge.first->DebugString() << "]"; | |||||
| } | } | ||||
| MS_EXCEPTION_IF_NULL(input_edge.first); | MS_EXCEPTION_IF_NULL(input_edge.first); | ||||
| MS_LOG(DEBUG) << "decrese input:" << input_edge.first->DebugString() << ",node:" << node->DebugString() | |||||
| MS_LOG(DEBUG) << "Decrease input:" << input_edge.first->DebugString() << ",node:" << node->DebugString() | |||||
| << ",num: " << node_output_num_[input_edge.first] << ",decrease num:" << input_edge.second; | << ",num: " << node_output_num_[input_edge.first] << ",decrease num:" << input_edge.second; | ||||
| if (node_output_num_[input_edge.first] < input_edge.second) { | if (node_output_num_[input_edge.first] < input_edge.second) { | ||||
| MS_LOG(EXCEPTION) << "input node:" << input_edge.first->DebugString() << ",node_output_num" | |||||
| << node_output_num_[input_edge.first] << "depend edege:" << input_edge.second; | |||||
| MS_LOG(EXCEPTION) << "Input node:" << input_edge.first->DebugString() << ",node_output_num" | |||||
| << node_output_num_[input_edge.first] << "depend edge:" << input_edge.second; | |||||
| } | } | ||||
| node_output_num_[input_edge.first] = node_output_num_[input_edge.first] - input_edge.second; | node_output_num_[input_edge.first] = node_output_num_[input_edge.first] - input_edge.second; | ||||
| clear_output(input_edge.first); | clear_output(input_edge.first); | ||||
| @@ -120,20 +120,20 @@ void KernelGraph::CheckLoop() { | |||||
| string str; | string str; | ||||
| auto node_output_it = node_output_edges_.find(it.first); | auto node_output_it = node_output_edges_.find(it.first); | ||||
| if (node_output_it == node_output_edges_.end()) { | if (node_output_it == node_output_edges_.end()) { | ||||
| MS_LOG(EXCEPTION) << "can't find node [" << it.first->DebugString() << "]"; | |||||
| MS_LOG(EXCEPTION) << "Can't find node [" << it.first->DebugString() << "]"; | |||||
| } | } | ||||
| for (const auto &output_edge : node_output_edges_[it.first]) { | for (const auto &output_edge : node_output_edges_[it.first]) { | ||||
| MS_EXCEPTION_IF_NULL(output_edge.first); | MS_EXCEPTION_IF_NULL(output_edge.first); | ||||
| str = str.append(output_edge.first->DebugString()).append("|"); | str = str.append(output_edge.first->DebugString()).append("|"); | ||||
| } | } | ||||
| if (it.second != 0) { | if (it.second != 0) { | ||||
| MS_LOG(WARNING) << "node:" << it.first->DebugString() << ",outputs:" << str << ",output num:" << it.second; | |||||
| MS_LOG(WARNING) << "Node:" << it.first->DebugString() << ",outputs:" << str << ",output num:" << it.second; | |||||
| none_zero_output[it.first] = it.second; | none_zero_output[it.first] = it.second; | ||||
| } | } | ||||
| } | } | ||||
| // if don't consider control depend and loop exit,a exception will be throw | // if don't consider control depend and loop exit,a exception will be throw | ||||
| if (!none_zero_output.empty()) { | if (!none_zero_output.empty()) { | ||||
| MS_LOG(EXCEPTION) << "nodes have loop,left node num:" << none_zero_output.size(); | |||||
| MS_LOG(EXCEPTION) << "Nodes have loop, left node num:" << none_zero_output.size(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -152,7 +152,7 @@ CNodePtr KernelGraph::NewCNode(const CNodePtr &cnode) { | |||||
| MS_EXCEPTION_IF_NULL(cnode); | MS_EXCEPTION_IF_NULL(cnode); | ||||
| auto new_cnode = std::make_shared<CNode>(*cnode); | auto new_cnode = std::make_shared<CNode>(*cnode); | ||||
| // if a cnode is created not from front,this cnode won't be in map,so when replace it,we shouldn't update map | // if a cnode is created not from front,this cnode won't be in map,so when replace it,we shouldn't update map | ||||
| if (BakcendNodeExistInFrontBackendMap(cnode)) { | |||||
| if (BackendNodeExistInFrontBackendMap(cnode)) { | |||||
| FrontBackendlMapUpdate(cnode, new_cnode); | FrontBackendlMapUpdate(cnode, new_cnode); | ||||
| } | } | ||||
| AnfAlgo::SetGraphId(graph_id_, cnode.get()); | AnfAlgo::SetGraphId(graph_id_, cnode.get()); | ||||
| @@ -299,7 +299,7 @@ AnfNodePtr KernelGraph::GetBackendAnfByFrontAnf(const AnfNodePtr &front_anf) { | |||||
| return front_backend_anf_map_[front_anf]; | return front_backend_anf_map_[front_anf]; | ||||
| } | } | ||||
| bool KernelGraph::BakcendNodeExistInFrontBackendMap(const AnfNodePtr &backend_anf) { | |||||
| bool KernelGraph::BackendNodeExistInFrontBackendMap(const AnfNodePtr &backend_anf) { | |||||
| return backend_front_anf_map_.find(backend_anf) != backend_front_anf_map_.end(); | return backend_front_anf_map_.find(backend_anf) != backend_front_anf_map_.end(); | ||||
| } | } | ||||
| @@ -317,9 +317,9 @@ void KernelGraph::TensorValueNodeMapAdd(const tensor::TensorPtr &tensor, const V | |||||
| } | } | ||||
| void KernelGraph::AddDependEdge(const AnfNodePtr &node, const AnfNodePtr &input, size_t depend_edge_num) { | void KernelGraph::AddDependEdge(const AnfNodePtr &node, const AnfNodePtr &input, size_t depend_edge_num) { | ||||
| MS_LOG(DEBUG) << "input:" << input->DebugString() << ", node:" << node->DebugString() << ",num:" << depend_edge_num; | |||||
| MS_LOG(DEBUG) << "Input:" << input->DebugString() << ", node:" << node->DebugString() << ",num:" << depend_edge_num; | |||||
| auto output_depend_edge = std::pair<AnfNodePtr, size_t>(node, depend_edge_num); | auto output_depend_edge = std::pair<AnfNodePtr, size_t>(node, depend_edge_num); | ||||
| // add output depend eddge of input | |||||
| // add output depend edge of input | |||||
| auto output_it = node_output_edges_.find(input); | auto output_it = node_output_edges_.find(input); | ||||
| if (output_it == node_output_edges_.end()) { | if (output_it == node_output_edges_.end()) { | ||||
| node_output_edges_[input] = std::vector<std::pair<AnfNodePtr, size_t>>{output_depend_edge}; | node_output_edges_[input] = std::vector<std::pair<AnfNodePtr, size_t>>{output_depend_edge}; | ||||
| @@ -346,7 +346,7 @@ std::vector<AnfNodePtr> KernelGraph::GetOutputNodes(const AnfNodePtr &node) { | |||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| auto it = node_output_edges_.find(node); | auto it = node_output_edges_.find(node); | ||||
| if (it == node_output_edges_.end()) { | if (it == node_output_edges_.end()) { | ||||
| MS_LOG(EXCEPTION) << "can'f find node[" << node->DebugString() << "]"; | |||||
| MS_LOG(EXCEPTION) << "Can't find node[" << node->DebugString() << "]"; | |||||
| } | } | ||||
| std::vector<AnfNodePtr> output_nodes; | std::vector<AnfNodePtr> output_nodes; | ||||
| auto trans = [](const std::pair<AnfNodePtr, size_t> &pair) -> AnfNodePtr { return pair.first; }; | auto trans = [](const std::pair<AnfNodePtr, size_t> &pair) -> AnfNodePtr { return pair.first; }; | ||||
| @@ -372,7 +372,7 @@ void KernelGraph::UpdateControlDependRelations(const std::vector<AnfNodePtr> &de | |||||
| MS_EXCEPTION_IF_NULL(depend_node); | MS_EXCEPTION_IF_NULL(depend_node); | ||||
| std::vector<AnfNodePtr> prior_nodes = {prior_node}; | std::vector<AnfNodePtr> prior_nodes = {prior_node}; | ||||
| std::vector<AnfNodePtr> depend_nodes = {depend_node}; | std::vector<AnfNodePtr> depend_nodes = {depend_node}; | ||||
| MS_LOG(INFO) << "prior node[" << prior_node->DebugString() << "],depend node[" << depend_node->DebugString() | |||||
| MS_LOG(INFO) << "Prior node[" << prior_node->DebugString() << "],depend node[" << depend_node->DebugString() | |||||
| << "],depend_mode=[" << AnfAlgo::GetNodeAttr<int>(cnode, "depend_mode") << "]"; | << "],depend_mode=[" << AnfAlgo::GetNodeAttr<int>(cnode, "depend_mode") << "]"; | ||||
| if (prior_node->isa<Parameter>()) { | if (prior_node->isa<Parameter>()) { | ||||
| prior_nodes = GetOutputNodes(prior_node); | prior_nodes = GetOutputNodes(prior_node); | ||||
| @@ -384,7 +384,7 @@ void KernelGraph::UpdateControlDependRelations(const std::vector<AnfNodePtr> &de | |||||
| for (auto &second_node : depend_nodes) { | for (auto &second_node : depend_nodes) { | ||||
| MS_EXCEPTION_IF_NULL(first_node); | MS_EXCEPTION_IF_NULL(first_node); | ||||
| MS_EXCEPTION_IF_NULL(second_node); | MS_EXCEPTION_IF_NULL(second_node); | ||||
| MS_LOG(INFO) << "add first node:" << first_node->DebugString() << ",second node:" << second_node->DebugString(); | |||||
| MS_LOG(INFO) << "Add first node:" << first_node->DebugString() << ",second node:" << second_node->DebugString(); | |||||
| AddDependEdge(second_node, first_node, 1); | AddDependEdge(second_node, first_node, 1); | ||||
| } | } | ||||
| } | } | ||||
| @@ -437,18 +437,18 @@ void KernelGraph::BfsToUpdateNodeOutput() { | |||||
| MS_EXCEPTION_IF_NULL(cnode); | MS_EXCEPTION_IF_NULL(cnode); | ||||
| // handle data links | // handle data links | ||||
| for (const auto &input : cnode->inputs()) { | for (const auto &input : cnode->inputs()) { | ||||
| size_t dpend_edge_num = 1; | |||||
| size_t depend_edge_num = 1; | |||||
| // handle control depend,all inputs of control depend has no depend edge | // handle control depend,all inputs of control depend has no depend edge | ||||
| if (HandleControlDependNode(input, &que, &visited_nodes)) { | if (HandleControlDependNode(input, &que, &visited_nodes)) { | ||||
| control_depends.push_back(input); | control_depends.push_back(input); | ||||
| dpend_edge_num = 0; | |||||
| depend_edge_num = 0; | |||||
| } | } | ||||
| // the 2rd input of depend is no depend edge | // the 2rd input of depend is no depend edge | ||||
| if (AnfAlgo::CheckPrimitiveType(node, prim::kPrimDepend) && input == cnode->input(kDependAttachNodeIndex)) { | if (AnfAlgo::CheckPrimitiveType(node, prim::kPrimDepend) && input == cnode->input(kDependAttachNodeIndex)) { | ||||
| dpend_edge_num = 0; | |||||
| depend_edge_num = 0; | |||||
| } | } | ||||
| PushNoVisitedNode(input, &que, &visited_nodes); | PushNoVisitedNode(input, &que, &visited_nodes); | ||||
| AddDependEdge(node, input, dpend_edge_num); | |||||
| AddDependEdge(node, input, depend_edge_num); | |||||
| } | } | ||||
| } | } | ||||
| UpdateControlDependRelations(control_depends); | UpdateControlDependRelations(control_depends); | ||||
| @@ -62,8 +62,8 @@ class KernelGraph : public FuncGraph { | |||||
| void FrontBackendlMapUpdate(const AnfNodePtr &old_backend_anf, const AnfNodePtr &new_backend_anf); | void FrontBackendlMapUpdate(const AnfNodePtr &old_backend_anf, const AnfNodePtr &new_backend_anf); | ||||
| // get backend anf by front anf | // get backend anf by front anf | ||||
| AnfNodePtr GetBackendAnfByFrontAnf(const AnfNodePtr &front_anf); | AnfNodePtr GetBackendAnfByFrontAnf(const AnfNodePtr &front_anf); | ||||
| // check backend node wheteher exist in map | |||||
| bool BakcendNodeExistInFrontBackendMap(const AnfNodePtr &backend_anf); | |||||
| // check backend node whether exist in map | |||||
| bool BackendNodeExistInFrontBackendMap(const AnfNodePtr &backend_anf); | |||||
| // get value node by tensor | // get value node by tensor | ||||
| ValueNodePtr GetValueNodeByTensor(const tensor::TensorPtr &tensor); | ValueNodePtr GetValueNodeByTensor(const tensor::TensorPtr &tensor); | ||||
| // add value node tensor relation map | // add value node tensor relation map | ||||
| @@ -281,7 +281,7 @@ std::vector<AnfNodePtr> CreateParameterFromTuple(const AnfNodePtr &node, KernelG | |||||
| } | } | ||||
| continue; | continue; | ||||
| } | } | ||||
| // creata single parameter if is a abstract real kernel | |||||
| // create single parameter if is a abstract real kernel | |||||
| create_parameter(out_node->abstract()); | create_parameter(out_node->abstract()); | ||||
| } | } | ||||
| return parameters; | return parameters; | ||||
| @@ -413,7 +413,7 @@ CNodePtr SessionBasic::CreateNewCNode(const CNodePtr &cnode, KernelGraph *graph) | |||||
| cnode_inputs.emplace_back(graph->GetBackendAnfByFrontAnf(anf)); | cnode_inputs.emplace_back(graph->GetBackendAnfByFrontAnf(anf)); | ||||
| continue; | continue; | ||||
| } else if (anf->isa<ValueNode>() && !IsValueNode<FuncGraph>(anf)) { | } else if (anf->isa<ValueNode>() && !IsValueNode<FuncGraph>(anf)) { | ||||
| // if input is a value ndoe, | |||||
| // if input is a value node, | |||||
| auto new_value_node = CreateNewValueNode(anf, graph); | auto new_value_node = CreateNewValueNode(anf, graph); | ||||
| if (new_value_node != nullptr) { | if (new_value_node != nullptr) { | ||||
| cnode_inputs.emplace_back(new_value_node); | cnode_inputs.emplace_back(new_value_node); | ||||
| @@ -549,7 +549,7 @@ void SessionBasic::Reorder(std::vector<CNodePtr> *node_list) { | |||||
| for (const auto &node : *node_list) { | for (const auto &node : *node_list) { | ||||
| MS_EXCEPTION_IF_NULL(node); | MS_EXCEPTION_IF_NULL(node); | ||||
| if (kOptOpeatorSet.find(AnfAlgo::GetCNodeName(node)) != kOptOpeatorSet.end()) { | |||||
| if (kOptOperatorSet.find(AnfAlgo::GetCNodeName(node)) != kOptOperatorSet.end()) { | |||||
| all_opt_list.emplace_back(node); | all_opt_list.emplace_back(node); | ||||
| } else { | } else { | ||||
| non_opt_list.emplace_back(node); | non_opt_list.emplace_back(node); | ||||
| @@ -599,7 +599,7 @@ void SessionBasic::ToTensorPtr(const OpRunInfo &op_run_info, std::vector<tensor: | |||||
| MS_EXCEPTION_IF_NULL(inputs); | MS_EXCEPTION_IF_NULL(inputs); | ||||
| MS_EXCEPTION_IF_NULL(tensor_mask); | MS_EXCEPTION_IF_NULL(tensor_mask); | ||||
| if (op_run_info.op_inputs.size() != op_run_info.inputs_mask.size()) { | if (op_run_info.op_inputs.size() != op_run_info.inputs_mask.size()) { | ||||
| MS_LOG(EXCEPTION) << "op input size " << op_run_info.op_inputs.size() << " should be equal to op input mask size " | |||||
| MS_LOG(EXCEPTION) << "Op input size " << op_run_info.op_inputs.size() << " should be equal to op input mask size " | |||||
| << op_run_info.inputs_mask.size(); | << op_run_info.inputs_mask.size(); | ||||
| } | } | ||||
| size_t input_num = op_run_info.op_inputs.size(); | size_t input_num = op_run_info.op_inputs.size(); | ||||
| @@ -636,7 +636,7 @@ CNodePtr SessionBasic::ConstructOutput(const AnfNodePtrList &outputs, const std: | |||||
| if (backend_anf != nullptr) { | if (backend_anf != nullptr) { | ||||
| return backend_anf; | return backend_anf; | ||||
| } | } | ||||
| MS_LOG(EXCEPTION) << "did not find the node in the equiv map!"; | |||||
| MS_LOG(EXCEPTION) << "Can not find the node in the equiv map!"; | |||||
| }; | }; | ||||
| output_args.push_back(NewValueNode(prim::kPrimMakeTuple)); | output_args.push_back(NewValueNode(prim::kPrimMakeTuple)); | ||||
| (void)std::transform(outputs.begin(), outputs.end(), std::back_inserter(output_args), | (void)std::transform(outputs.begin(), outputs.end(), std::back_inserter(output_args), | ||||
| @@ -645,7 +645,7 @@ CNodePtr SessionBasic::ConstructOutput(const AnfNodePtrList &outputs, const std: | |||||
| } | } | ||||
| void SessionBasic::CreateOutputNode(const CNodePtr &cnode, const std::shared_ptr<KernelGraph> &graph) { | void SessionBasic::CreateOutputNode(const CNodePtr &cnode, const std::shared_ptr<KernelGraph> &graph) { | ||||
| MS_LOG(INFO) << "start"; | |||||
| MS_LOG(INFO) << "Start!"; | |||||
| std::vector<AnfNodePtr> make_tuple_inputs; | std::vector<AnfNodePtr> make_tuple_inputs; | ||||
| make_tuple_inputs.push_back(NewValueNode(prim::kPrimMakeTuple)); | make_tuple_inputs.push_back(NewValueNode(prim::kPrimMakeTuple)); | ||||
| if (AnfRuntimeAlgorithm::GetOutputTensorNum(cnode) > 1) { | if (AnfRuntimeAlgorithm::GetOutputTensorNum(cnode) > 1) { | ||||
| @@ -667,14 +667,14 @@ void SessionBasic::CreateOutputNode(const CNodePtr &cnode, const std::shared_ptr | |||||
| // create output | // create output | ||||
| auto g_output = graph->NewCNode(make_tuple_inputs); | auto g_output = graph->NewCNode(make_tuple_inputs); | ||||
| graph->set_output(g_output); | graph->set_output(g_output); | ||||
| // set graph manager,which now is only used to get valuendoes and hardware optimizing | |||||
| // set graph manager,which now is only used to get valuenodes and hardware optimizing | |||||
| MS_EXCEPTION_IF_NULL(context_); | MS_EXCEPTION_IF_NULL(context_); | ||||
| FuncGraphManagerPtr manager = context_->manager(); | FuncGraphManagerPtr manager = context_->manager(); | ||||
| if (manager != nullptr) { | if (manager != nullptr) { | ||||
| manager->AddFuncGraph(graph); | manager->AddFuncGraph(graph); | ||||
| graph->set_manager(manager); | graph->set_manager(manager); | ||||
| } | } | ||||
| MS_LOG(INFO) << "end"; | |||||
| MS_LOG(INFO) << "Finish!"; | |||||
| } | } | ||||
| std::shared_ptr<KernelGraph> SessionBasic::ConstructSingleOpGraph(const OpRunInfo &op_run_info) { | std::shared_ptr<KernelGraph> SessionBasic::ConstructSingleOpGraph(const OpRunInfo &op_run_info) { | ||||
| @@ -694,9 +694,9 @@ std::shared_ptr<KernelGraph> SessionBasic::ConstructSingleOpGraph(const OpRunInf | |||||
| std::vector<tensor::TensorPtr> input_tensors; | std::vector<tensor::TensorPtr> input_tensors; | ||||
| std::vector<bool> tensors_mask; | std::vector<bool> tensors_mask; | ||||
| ToTensorPtr(op_run_info, &input_tensors, &tensors_mask); | ToTensorPtr(op_run_info, &input_tensors, &tensors_mask); | ||||
| MS_LOG(INFO) << "input tensor size" << input_tensors.size(); | |||||
| MS_LOG(INFO) << "Input tensor size" << input_tensors.size(); | |||||
| if (input_tensors.size() != tensors_mask.size()) { | if (input_tensors.size() != tensors_mask.size()) { | ||||
| MS_LOG(EXCEPTION) << "input tensors size " << input_tensors.size() << " should be equal to tensors mask size " | |||||
| MS_LOG(EXCEPTION) << "Input tensors size " << input_tensors.size() << " should be equal to tensors mask size " | |||||
| << tensors_mask.size(); | << tensors_mask.size(); | ||||
| } | } | ||||
| for (size_t i = 0; i < input_tensors.size(); ++i) { | for (size_t i = 0; i < input_tensors.size(); ++i) { | ||||
| @@ -711,7 +711,7 @@ std::shared_ptr<KernelGraph> SessionBasic::ConstructSingleOpGraph(const OpRunInf | |||||
| cnode->set_abstract(op_run_info.abstract); | cnode->set_abstract(op_run_info.abstract); | ||||
| // set const input to attr if value is not a tensor,such as scalar or tuple | // set const input to attr if value is not a tensor,such as scalar or tuple | ||||
| RunOpConvertConstInputToAttr(op_run_info, cnode); | RunOpConvertConstInputToAttr(op_run_info, cnode); | ||||
| // set exectuion order | |||||
| // set execution order | |||||
| std::vector<CNodePtr> exe_order = {cnode}; | std::vector<CNodePtr> exe_order = {cnode}; | ||||
| graph->set_execution_order(exe_order); | graph->set_execution_order(exe_order); | ||||
| // set output | // set output | ||||
| @@ -734,14 +734,14 @@ BaseRef SessionBasic::TransformBaseRefListToTuple(const BaseRef &base_ref) { | |||||
| py::tuple tensor_tuple = py::cast<py::tuple>(obj); | py::tuple tensor_tuple = py::cast<py::tuple>(obj); | ||||
| output_tensors[i] = tensor_tuple; | output_tensors[i] = tensor_tuple; | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "The output is not a base ref list or a tensor !"; | |||||
| MS_LOG(EXCEPTION) << "The output is not a base ref list or a tensor!"; | |||||
| } | } | ||||
| } | } | ||||
| return output_tensors; // turn tuple to py::object and store in PyObjectRef | return output_tensors; // turn tuple to py::object and store in PyObjectRef | ||||
| } else if (utils::isa<tensor::TensorPtr>(base_ref)) { | } else if (utils::isa<tensor::TensorPtr>(base_ref)) { | ||||
| return base_ref; | return base_ref; | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "The output is not a base ref list or a tensor !"; | |||||
| MS_LOG(EXCEPTION) << "The output is not a base ref list or a tensor!"; | |||||
| } | } | ||||
| } | } | ||||
| } // namespace session | } // namespace session | ||||
| @@ -56,7 +56,7 @@ class SessionBasic { | |||||
| virtual ~SessionBasic() { summary_callback_ = nullptr; } | virtual ~SessionBasic() { summary_callback_ = nullptr; } | ||||
| virtual GraphId CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) = 0; | virtual GraphId CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) = 0; | ||||
| // build graph ,used to handle mupltiple child graphs | |||||
| // build graph, used to handle multiple child graphs | |||||
| virtual void BuildGraph(GraphId) {} | virtual void BuildGraph(GraphId) {} | ||||
| virtual void RunGraph(const GraphId &graph_id, const std::vector<tensor::TensorPtr> &inputs, VectorRef *outputs) = 0; | virtual void RunGraph(const GraphId &graph_id, const std::vector<tensor::TensorPtr> &inputs, VectorRef *outputs) = 0; | ||||
| @@ -75,7 +75,7 @@ class SessionBasic { | |||||
| virtual GraphId SetFinalGraphInput(const std::vector<AnfNodePtr> &) { return kInvalidGraphId; } | virtual GraphId SetFinalGraphInput(const std::vector<AnfNodePtr> &) { return kInvalidGraphId; } | ||||
| // set output of final graph | // set output of final graph | ||||
| virtual void SetFinalGraphOutput(const BaseRef &) {} | virtual void SetFinalGraphOutput(const BaseRef &) {} | ||||
| // insert switch and set the relative acitve ops | |||||
| // insert switch and set the relative active ops | |||||
| virtual void SwitchCompile(GraphId, GraphId, GraphId) {} | virtual void SwitchCompile(GraphId, GraphId, GraphId) {} | ||||
| // set args of child graph.the arg maybe come from a output of other child graphs,or from final graph's parameter | // set args of child graph.the arg maybe come from a output of other child graphs,or from final graph's parameter | ||||
| virtual void SetChildGraphInput(GraphId, const VectorRef &) {} | virtual void SetChildGraphInput(GraphId, const VectorRef &) {} | ||||
| @@ -186,7 +186,7 @@ const std::vector<std::set<std::string>> kShapeSupportFormatMap = {k1DSupportFor | |||||
| k4DSupportFormat}; | k4DSupportFormat}; | ||||
| const std::set<std::string> kDefaultCompatibleFormat = {kOpFormat_ND, kOpFormat_NCHW, kOpFormat_NHWC, kOpFormat_HWCN}; | const std::set<std::string> kDefaultCompatibleFormat = {kOpFormat_ND, kOpFormat_NCHW, kOpFormat_NHWC, kOpFormat_HWCN}; | ||||
| const std::set<std::string> kOptOpeatorSet = { | |||||
| const std::set<std::string> kOptOperatorSet = { | |||||
| kMomentumOpName, kApplyMomentumOpName, kApplyAdadeltaOpName, | kMomentumOpName, kApplyMomentumOpName, kApplyAdadeltaOpName, | ||||
| kApplyAdagradOpName, kApplyAdagradDAName, kApplyAdamOpName, | kApplyAdagradOpName, kApplyAdagradDAName, kApplyAdamOpName, | ||||
| kApplyAdaMaxOpName, kApplyAddSignOpName, kApplyCenteredRMSPOpName, | kApplyAdaMaxOpName, kApplyAddSignOpName, kApplyCenteredRMSPOpName, | ||||