Signed-off-by: leonwanghui <leon.wanghui@huawei.com>tags/v0.2.0-alpha
| @@ -64,14 +64,14 @@ AbstractFunctionPtr FuncGraph::abstract() { | |||||
| for (auto& p : parameters_) { | for (auto& p : parameters_) { | ||||
| MS_EXCEPTION_IF_NULL(p); | MS_EXCEPTION_IF_NULL(p); | ||||
| if (p->abstract() == nullptr) { | if (p->abstract() == nullptr) { | ||||
| MS_LOG(ERROR) << "error!!"; | |||||
| MS_LOG(ERROR) << "Error!!"; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| args_spec_list.push_back(p->abstract()); | args_spec_list.push_back(p->abstract()); | ||||
| } | } | ||||
| if (nullptr == output()) { | if (nullptr == output()) { | ||||
| MS_LOG(ERROR) << "error func graph no output"; | |||||
| MS_LOG(ERROR) << "Error func graph no output"; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -543,6 +543,7 @@ void FuncGraph::GenerateKwargReplNode(const FuncGraphPtr& specialized_graph, | |||||
| TraceManager::EndTrace(); | TraceManager::EndTrace(); | ||||
| } | } | ||||
| } | } | ||||
| bool FuncGraph::NeedGenerate(const std::vector<abstract::AbstractKeywordArgPtr>& kwarg_list) { | bool FuncGraph::NeedGenerate(const std::vector<abstract::AbstractKeywordArgPtr>& kwarg_list) { | ||||
| // if the function does not have any vararg/kwarg/kwonly/default value/kw args input | // if the function does not have any vararg/kwarg/kwonly/default value/kw args input | ||||
| // return the original graph | // return the original graph | ||||
| @@ -556,6 +557,7 @@ bool FuncGraph::NeedGenerate(const std::vector<abstract::AbstractKeywordArgPtr>& | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| void FuncGraph::GenerateDefaultValue(const FuncGraphPtr& specialized_graph, | void FuncGraph::GenerateDefaultValue(const FuncGraphPtr& specialized_graph, | ||||
| const std::vector<AnfNodePtr>& specialized_parameter_list, | const std::vector<AnfNodePtr>& specialized_parameter_list, | ||||
| std::unordered_map<AnfNodePtr, AnfNodePtr>* repl_nodes) { | std::unordered_map<AnfNodePtr, AnfNodePtr>* repl_nodes) { | ||||
| @@ -664,7 +666,7 @@ void FuncGraph::EraseUnusedNodeInOrder() { | |||||
| auto mng = manager_.lock(); | auto mng = manager_.lock(); | ||||
| if (mng) { | if (mng) { | ||||
| auto nodes = mng->nodes()[shared_from_base<FuncGraph>()]; | auto nodes = mng->nodes()[shared_from_base<FuncGraph>()]; | ||||
| // Erase unusued cnode. | |||||
| // Erase unused cnode. | |||||
| for (auto it = order_.begin(); it != order_.end();) { | for (auto it = order_.begin(); it != order_.end();) { | ||||
| if (nodes.count(*it)) { | if (nodes.count(*it)) { | ||||
| (void)it++; | (void)it++; | ||||
| @@ -695,7 +697,7 @@ void FuncGraph::CheckOrder() { | |||||
| if (found == it) { | if (found == it) { | ||||
| DumpCNodeList(); | DumpCNodeList(); | ||||
| MS_LOG(EXCEPTION) << "The cnode " << (*it)->DebugString() << " order in " << ToString() | MS_LOG(EXCEPTION) << "The cnode " << (*it)->DebugString() << " order in " << ToString() | ||||
| << " doesn't obey the input denpency, " | |||||
| << " doesn't obey the input dependency, " | |||||
| << "as input " << input_node->DebugString() << " is not ahead of itself."; | << "as input " << input_node->DebugString() << " is not ahead of itself."; | ||||
| } | } | ||||
| } | } | ||||
| @@ -842,5 +844,5 @@ void FuncGraph::SetEffectDepends(const std::vector<AnfNodePtr>& depend_inputs) { | |||||
| } | } | ||||
| const PrimitivePtr FuncGraphTransform::func_graph_prim_ = std::make_shared<Primitive>("FuncGraph"); | const PrimitivePtr FuncGraphTransform::func_graph_prim_ = std::make_shared<Primitive>("FuncGraph"); | ||||
| const char kFuncGraphFlagUndetermin[] = "Undeterminate"; | |||||
| const char kFuncGraphFlagUndetermined[] = "Undeterminate"; | |||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -96,7 +96,7 @@ class FuncGraphBase : public Value { | |||||
| MS_DECLARE_PARENT(FuncGraphBase, Value); | MS_DECLARE_PARENT(FuncGraphBase, Value); | ||||
| }; | }; | ||||
| extern const char kFuncGraphFlagUndetermin[]; | |||||
| extern const char kFuncGraphFlagUndetermined[]; | |||||
| class FuncGraph : public FuncGraphBase { | class FuncGraph : public FuncGraphBase { | ||||
| public: | public: | ||||
| @@ -200,7 +200,7 @@ class FuncGraph : public FuncGraphBase { | |||||
| // get all func graphs directly used by this func graph | // get all func graphs directly used by this func graph | ||||
| const FuncGraphCounterMap &func_graphs_used(); | const FuncGraphCounterMap &func_graphs_used(); | ||||
| // get all func graphs nestedly used by this func graph | |||||
| // get all func graphs nested used by this func graph | |||||
| const FuncGraphSet &func_graphs_used_total(); | const FuncGraphSet &func_graphs_used_total(); | ||||
| // get all users of this func graph | // get all users of this func graph | ||||
| @@ -183,7 +183,7 @@ bool SymbolResolveAction(const ResourcePtr& res) { | |||||
| FuncGraphPtr func_graph = res->func_graph(); | FuncGraphPtr func_graph = res->func_graph(); | ||||
| auto succ = parse::ResolveFuncGraph(func_graph, res); | auto succ = parse::ResolveFuncGraph(func_graph, res); | ||||
| // Remove usued nodes in cnode order list. | |||||
| // Remove unused nodes in cnode order list. | |||||
| func_graph->EraseUnusedNodeInOrder(); | func_graph->EraseUnusedNodeInOrder(); | ||||
| func_graph->ReleaseFullOrderToEffectOrder(); | func_graph->ReleaseFullOrderToEffectOrder(); | ||||
| for (auto fg : func_graph->func_graphs_used_total()) { | for (auto fg : func_graph->func_graphs_used_total()) { | ||||
| @@ -40,7 +40,7 @@ using ExecutorInfoPtr = std::shared_ptr<ExecutorInfo>; | |||||
| inline std::string GetPhasePrefix(const std::string& phase) { | inline std::string GetPhasePrefix(const std::string& phase) { | ||||
| auto pos = phase.find('.'); | auto pos = phase.find('.'); | ||||
| if (pos == std::string::npos) { | if (pos == std::string::npos) { | ||||
| MS_LOG(EXCEPTION) << "phase has no . for prefix" << phase; | |||||
| MS_LOG(EXCEPTION) << "Phase has no . for prefix" << phase; | |||||
| } | } | ||||
| return phase.substr(0, pos); | return phase.substr(0, pos); | ||||
| } | } | ||||
| @@ -39,7 +39,7 @@ using TensorPtr = mindspore::tensor::TensorPtr; | |||||
| namespace { | namespace { | ||||
| bool ConvertTuple(const py::object& obj, ValuePtr* const data, bool use_signature) { | bool ConvertTuple(const py::object& obj, ValuePtr* const data, bool use_signature) { | ||||
| MS_LOG(DEBUG) << "converting python tuple"; | |||||
| MS_LOG(DEBUG) << "Converting python tuple"; | |||||
| py::tuple tuple = obj.cast<py::tuple>(); | py::tuple tuple = obj.cast<py::tuple>(); | ||||
| std::vector<ValuePtr> value_list; | std::vector<ValuePtr> value_list; | ||||
| for (size_t it = 0; it < tuple.size(); ++it) { | for (size_t it = 0; it < tuple.size(); ++it) { | ||||
| @@ -56,7 +56,7 @@ bool ConvertTuple(const py::object& obj, ValuePtr* const data, bool use_signatur | |||||
| } | } | ||||
| bool ConvertList(const py::object& obj, ValuePtr* const data, bool use_signature) { | bool ConvertList(const py::object& obj, ValuePtr* const data, bool use_signature) { | ||||
| MS_LOG(DEBUG) << "converting python list"; | |||||
| MS_LOG(DEBUG) << "Converting python list"; | |||||
| py::list list = obj.cast<py::list>(); | py::list list = obj.cast<py::list>(); | ||||
| std::vector<ValuePtr> value_list; | std::vector<ValuePtr> value_list; | ||||
| @@ -73,7 +73,7 @@ bool ConvertList(const py::object& obj, ValuePtr* const data, bool use_signature | |||||
| } | } | ||||
| bool ConvertCellList(const py::object& obj, ValuePtr* const data, bool use_signature) { | bool ConvertCellList(const py::object& obj, ValuePtr* const data, bool use_signature) { | ||||
| MS_LOG(DEBUG) << "converting cell list"; | |||||
| MS_LOG(DEBUG) << "Converting cell list"; | |||||
| py::sequence list = obj; | py::sequence list = obj; | ||||
| std::vector<ValuePtr> value_list; | std::vector<ValuePtr> value_list; | ||||
| for (size_t it = 0; it < list.size(); ++it) { | for (size_t it = 0; it < list.size(); ++it) { | ||||
| @@ -89,7 +89,7 @@ bool ConvertCellList(const py::object& obj, ValuePtr* const data, bool use_signa | |||||
| } | } | ||||
| bool ConvertDict(const py::object& obj, ValuePtr* data, bool use_signature) { | bool ConvertDict(const py::object& obj, ValuePtr* data, bool use_signature) { | ||||
| MS_LOG(DEBUG) << "converting python dict"; | |||||
| MS_LOG(DEBUG) << "Converting python dict"; | |||||
| py::dict dict_values = obj.cast<py::dict>(); | py::dict dict_values = obj.cast<py::dict>(); | ||||
| std::vector<std::pair<std::string, ValuePtr>> key_values; | std::vector<std::pair<std::string, ValuePtr>> key_values; | ||||
| @@ -110,14 +110,14 @@ bool ConvertDict(const py::object& obj, ValuePtr* data, bool use_signature) { | |||||
| } | } | ||||
| void ConvertNameSpace(const py::object& obj, ValuePtr* const data) { | void ConvertNameSpace(const py::object& obj, ValuePtr* const data) { | ||||
| MS_LOG(DEBUG) << "converting python module"; | |||||
| MS_LOG(DEBUG) << "Converting python module"; | |||||
| py::module mod = python_adapter::GetPyModule(PYTHON_MOD_PARSE_MODULE); | py::module mod = python_adapter::GetPyModule(PYTHON_MOD_PARSE_MODULE); | ||||
| py::object module_namespace = python_adapter::CallPyModFn(mod, PYTHON_MOD_GET_MODULE_NAMESPACE, obj); | py::object module_namespace = python_adapter::CallPyModFn(mod, PYTHON_MOD_GET_MODULE_NAMESPACE, obj); | ||||
| *data = std::make_shared<NameSpace>(RESOLVE_NAMESPACE_NAME_MODULE, py::cast<py::module>(module_namespace)); | *data = std::make_shared<NameSpace>(RESOLVE_NAMESPACE_NAME_MODULE, py::cast<py::module>(module_namespace)); | ||||
| } | } | ||||
| void ConvertDataClass(py::object obj, ValuePtr* const data) { | void ConvertDataClass(py::object obj, ValuePtr* const data) { | ||||
| MS_LOG(DEBUG) << "converting dataclass"; | |||||
| MS_LOG(DEBUG) << "Converting dataclass"; | |||||
| // Maybe the obj is dataclass define | // Maybe the obj is dataclass define | ||||
| auto desc = py::cast<std::string>(python_adapter::CallPyObjMethod(obj, PYTHON_GET_OBJ_DESC, obj)); | auto desc = py::cast<std::string>(python_adapter::CallPyObjMethod(obj, PYTHON_GET_OBJ_DESC, obj)); | ||||
| // desc has format "<class xxxx>", strip the '<' and '>' by offset 1; | // desc has format "<class xxxx>", strip the '<' and '>' by offset 1; | ||||
| @@ -247,7 +247,7 @@ bool ConvertOtherObj(py::object obj, ValuePtr* const data) { | |||||
| bool ConvertData(const py::object& obj, ValuePtr* const data, bool use_signature) { | bool ConvertData(const py::object& obj, ValuePtr* const data, bool use_signature) { | ||||
| // check parameter valid | // check parameter valid | ||||
| if (data == nullptr) { | if (data == nullptr) { | ||||
| MS_LOG(ERROR) << " data is null pointer"; | |||||
| MS_LOG(ERROR) << "Data is null pointer"; | |||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -386,9 +386,9 @@ py::object CreatePythonObject(const py::object& type, const py::tuple& params) { | |||||
| py::module mod = python_adapter::GetPyModule(PYTHON_MOD_PARSE_MODULE); | py::module mod = python_adapter::GetPyModule(PYTHON_MOD_PARSE_MODULE); | ||||
| py::object obj; | py::object obj; | ||||
| if (params.size() == 0) { | if (params.size() == 0) { | ||||
| obj = python_adapter::CallPyModFn(mod, PYTHON_MOD_CRETAE_OBJ_INSTANCE, type); | |||||
| obj = python_adapter::CallPyModFn(mod, PYTHON_MOD_CREATE_OBJ_INSTANCE, type); | |||||
| } else { | } else { | ||||
| obj = python_adapter::CallPyModFn(mod, PYTHON_MOD_CRETAE_OBJ_INSTANCE, type, params); | |||||
| obj = python_adapter::CallPyModFn(mod, PYTHON_MOD_CREATE_OBJ_INSTANCE, type, params); | |||||
| } | } | ||||
| return obj; | return obj; | ||||
| } | } | ||||
| @@ -421,6 +421,7 @@ ValuePtr PyDataToValue(const py::object& obj) { | |||||
| (void)ConvertData(to_convert, &value); | (void)ConvertData(to_convert, &value); | ||||
| return value; | return value; | ||||
| } | } | ||||
| void ClearObjectCache() { | void ClearObjectCache() { | ||||
| object_map_.clear(); | object_map_.clear(); | ||||
| object_graphs_map_.clear(); | object_graphs_map_.clear(); | ||||
| @@ -445,7 +446,7 @@ ClassPtr ParseDataClass(const py::object& cls_obj) { | |||||
| for (auto& item : names) { | for (auto& item : names) { | ||||
| TypePtr type_value = item.second.cast<TypePtr>(); | TypePtr type_value = item.second.cast<TypePtr>(); | ||||
| MS_EXCEPTION_IF_NULL(type_value); | MS_EXCEPTION_IF_NULL(type_value); | ||||
| MS_LOG(DEBUG) << "(name: " << py::cast<std::string>(item.first) << ", type: " << type_value->ToString() << ")"; | |||||
| MS_LOG(DEBUG) << "(Name: " << py::cast<std::string>(item.first) << ", type: " << type_value->ToString() << ")"; | |||||
| attributes.push_back(std::make_pair(py::cast<std::string>(item.first), type_value)); | attributes.push_back(std::make_pair(py::cast<std::string>(item.first), type_value)); | ||||
| } | } | ||||
| @@ -254,7 +254,7 @@ void FunctionBlock::Mature() { | |||||
| matured_ = true; | matured_ = true; | ||||
| } | } | ||||
| // Force the conditon node to bool using bool operation | |||||
| // Force the conditIon node to bool using bool operation | |||||
| CNodePtr FunctionBlock::ForceToBoolNode(const AnfNodePtr& cond) { | CNodePtr FunctionBlock::ForceToBoolNode(const AnfNodePtr& cond) { | ||||
| TraceManager::DebugTrace(std::make_shared<TraceForceBool>(cond->debug_info())); | TraceManager::DebugTrace(std::make_shared<TraceForceBool>(cond->debug_info())); | ||||
| CNodePtr op_apply_node = func_graph()->NewCNode({MakeResolveOperation(NAMED_PRIMITIVE_BOOL), cond}); | CNodePtr op_apply_node = func_graph()->NewCNode({MakeResolveOperation(NAMED_PRIMITIVE_BOOL), cond}); | ||||
| @@ -347,7 +347,7 @@ void FunctionBlock::InsertDependItemsBeforeReturn() { | |||||
| auto return_node = func_graph()->get_return(); | auto return_node = func_graph()->get_return(); | ||||
| if (return_node) { | if (return_node) { | ||||
| if (return_node->inputs().size() < 1) { | if (return_node->inputs().size() < 1) { | ||||
| MS_LOG(EXCEPTION) << "length of inputs of output node is less than 2"; | |||||
| MS_LOG(EXCEPTION) << "Length of inputs of output node is less than 2"; | |||||
| } | } | ||||
| old_ret = return_node->input(1); | old_ret = return_node->input(1); | ||||
| } else { | } else { | ||||
| @@ -294,14 +294,14 @@ FunctionBlockPtr Parser::ParseStatement(const FunctionBlockPtr &block, const py: | |||||
| TraceManager::EndTrace(); | TraceManager::EndTrace(); | ||||
| return stmt_block; | return stmt_block; | ||||
| } else { | } else { | ||||
| errcode_ = PARSE_NODE_METHOD_UNSUPPORT; | |||||
| errcode_ = PARSE_NODE_METHOD_UNSUPPORTED; | |||||
| py::list location = ast_->CallParserObjMethod(PYTHON_PARSE_GET_LOCATION, node); | py::list location = ast_->CallParserObjMethod(PYTHON_PARSE_GET_LOCATION, node); | ||||
| if (location.size() < 2) { | if (location.size() < 2) { | ||||
| MS_LOG(EXCEPTION) << "List size should not be less than 2."; | MS_LOG(EXCEPTION) << "List size should not be less than 2."; | ||||
| } | } | ||||
| auto filename = location[0].cast<std::string>(); | auto filename = location[0].cast<std::string>(); | ||||
| auto line_no = location[1].cast<int>(); | auto line_no = location[1].cast<int>(); | ||||
| MS_LOG(EXCEPTION) << "unsupported syntax '" << node_name << "' at " << filename << ":" << line_no; | |||||
| MS_LOG(EXCEPTION) << "Unsupported syntax '" << node_name << "' at " << filename << ":" << line_no; | |||||
| } | } | ||||
| } | } | ||||
| @@ -324,11 +324,11 @@ AnfNodePtr Parser::ParseExprNode(const FunctionBlockPtr &block, const py::object | |||||
| TraceManager::EndTrace(); | TraceManager::EndTrace(); | ||||
| return expr_node; | return expr_node; | ||||
| } else { | } else { | ||||
| errcode_ = PARSE_NODE_METHOD_UNSUPPORT; | |||||
| errcode_ = PARSE_NODE_METHOD_UNSUPPORTED; | |||||
| py::list ret = ast_->CallParserObjMethod(PYTHON_PARSE_GET_LOCATION, node); | py::list ret = ast_->CallParserObjMethod(PYTHON_PARSE_GET_LOCATION, node); | ||||
| auto filename = ret[0].cast<std::string>(); | auto filename = ret[0].cast<std::string>(); | ||||
| auto line_no = ret[1].cast<int>(); | auto line_no = ret[1].cast<int>(); | ||||
| MS_LOG(EXCEPTION) << "unsupported syntax '" << node_name << "' at " << filename << ":" << line_no; | |||||
| MS_LOG(EXCEPTION) << "Unsupported syntax '" << node_name << "' at " << filename << ":" << line_no; | |||||
| } | } | ||||
| } | } | ||||
| @@ -339,7 +339,7 @@ FunctionBlockPtr Parser::ParseExpr(const FunctionBlockPtr &block, const py::obje | |||||
| // Expr only have value , no target | // Expr only have value , no target | ||||
| py::tuple expand_info = ast_->CallParserObjMethod(PYTHON_PARSE_EXPAND_EXPR_STATEMENT, node); | py::tuple expand_info = ast_->CallParserObjMethod(PYTHON_PARSE_EXPAND_EXPR_STATEMENT, node); | ||||
| // refer pypthon function expand_expr_statement, expand_info is one of the following: | |||||
| // refer python function expand_expr_statement, expand_info is one of the following: | |||||
| // True, expr.value, x | // True, expr.value, x | ||||
| // True, expr.value | // True, expr.value | ||||
| // False, None, None | // False, None, None | ||||
| @@ -453,8 +453,8 @@ AnfNodePtr Parser::ParseNum(const FunctionBlockPtr &, const py::object &node) { | |||||
| return NewValueNode(data); | return NewValueNode(data); | ||||
| } else { | } else { | ||||
| // no else actually | // no else actually | ||||
| MS_LOG(ERROR) << "unsupported Num type : " << (std::string)py::str(obj) << GetLocation(node)->ToString(); | |||||
| errcode_ = PARSE_NODE_TYPE_UNKONW; | |||||
| MS_LOG(ERROR) << "Unsupported Num type : " << (std::string)py::str(obj) << GetLocation(node)->ToString(); | |||||
| errcode_ = PARSE_NODE_TYPE_UNKOWN; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| } | } | ||||
| @@ -478,8 +478,8 @@ AnfNodePtr Parser::ParseNameConstant(const FunctionBlockPtr &, const py::object | |||||
| return NewValueNode(kNone); | return NewValueNode(kNone); | ||||
| } else { | } else { | ||||
| // no else actually | // no else actually | ||||
| MS_LOG(ERROR) << "unsupported NameConstant type: " << (std::string)py::str(obj) << GetLocation(node)->ToString(); | |||||
| errcode_ = PARSE_NODE_TYPE_UNKONW; | |||||
| MS_LOG(ERROR) << "Unsupported NameConstant type: " << (std::string)py::str(obj) << GetLocation(node)->ToString(); | |||||
| errcode_ = PARSE_NODE_TYPE_UNKOWN; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| } | } | ||||
| @@ -497,7 +497,7 @@ AnfNodePtr Parser::ParseCall(const FunctionBlockPtr &block, const py::object &no | |||||
| // process function call | // process function call | ||||
| py::object function_ast_node = python_adapter::GetPyObjAttr(node, "func"); | py::object function_ast_node = python_adapter::GetPyObjAttr(node, "func"); | ||||
| AnfNodePtr call_function_anf_node = ParseExprNode(block, function_ast_node); | AnfNodePtr call_function_anf_node = ParseExprNode(block, function_ast_node); | ||||
| // function call arguments should be passed in as groups and upacked later using unpack call | |||||
| // function call arguments should be passed in as groups and unpacked later using unpack call | |||||
| py::list args = python_adapter::GetPyObjAttr(node, "args"); | py::list args = python_adapter::GetPyObjAttr(node, "args"); | ||||
| std::vector<AnfNodePtr> packed_arguments; | std::vector<AnfNodePtr> packed_arguments; | ||||
| std::vector<AnfNodePtr> group_arguments; | std::vector<AnfNodePtr> group_arguments; | ||||
| @@ -614,7 +614,7 @@ AnfNodePtr Parser::ParseAttribute(const FunctionBlockPtr &block, const py::objec | |||||
| py::object value_body = python_adapter::GetPyObjAttr(node, "value"); | py::object value_body = python_adapter::GetPyObjAttr(node, "value"); | ||||
| AnfNodePtr value_node = ParseExprNode(block, value_body); | AnfNodePtr value_node = ParseExprNode(block, value_body); | ||||
| if (value_node == nullptr) { | if (value_node == nullptr) { | ||||
| MS_LOG(WARNING) << "Parse Attribut failed"; | |||||
| MS_LOG(WARNING) << "Parse attribute failed"; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -637,7 +637,7 @@ AnfNodePtr Parser::ParseCompare(const FunctionBlockPtr &block, const py::object | |||||
| // which there is two ops , but we only support one now | // which there is two ops , but we only support one now | ||||
| py::list ops = python_adapter::GetPyObjAttr(node, "ops"); | py::list ops = python_adapter::GetPyObjAttr(node, "ops"); | ||||
| if (ops.size() > MAX_COMPARISON_OPS_SUPPORTED) { | if (ops.size() > MAX_COMPARISON_OPS_SUPPORTED) { | ||||
| MS_LOG(ERROR) << "mindspore does not support comparison with operators more than one now, ops size =" << ops.size(); | |||||
| MS_LOG(ERROR) << "MindSpore does not support comparison with operators more than one now, ops size =" << ops.size(); | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -817,7 +817,7 @@ AnfNodePtr Parser::ParseIndex(const FunctionBlockPtr &block, const py::object &n | |||||
| // process a UnaryOp, +a, -b | // process a UnaryOp, +a, -b | ||||
| AnfNodePtr Parser::ParseUnaryOp(const FunctionBlockPtr &block, const py::object &node) { | AnfNodePtr Parser::ParseUnaryOp(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast UnaryOp"; | |||||
| MS_LOG(DEBUG) << "Process ast UnaryOp"; | |||||
| py::object op = python_adapter::GetPyObjAttr(node, "op"); | py::object op = python_adapter::GetPyObjAttr(node, "op"); | ||||
| MS_EXCEPTION_IF_NULL(block); | MS_EXCEPTION_IF_NULL(block); | ||||
| @@ -831,7 +831,7 @@ AnfNodePtr Parser::ParseUnaryOp(const FunctionBlockPtr &block, const py::object | |||||
| // process a dict ast node expression | // process a dict ast node expression | ||||
| AnfNodePtr Parser::ParseDict(const FunctionBlockPtr &block, const py::object &node) { | AnfNodePtr Parser::ParseDict(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast Dict"; | |||||
| MS_LOG(DEBUG) << "Process ast Dict"; | |||||
| py::list keys = node.attr("keys"); | py::list keys = node.attr("keys"); | ||||
| py::list values = node.attr("values"); | py::list values = node.attr("values"); | ||||
| std::vector<AnfNodePtr> key_nodes; | std::vector<AnfNodePtr> key_nodes; | ||||
| @@ -849,7 +849,7 @@ AnfNodePtr Parser::ParseDict(const FunctionBlockPtr &block, const py::object &no | |||||
| // process a augment assign such as a += b; | // process a augment assign such as a += b; | ||||
| FunctionBlockPtr Parser::ParseAugAssign(const FunctionBlockPtr &block, const py::object &node) { | FunctionBlockPtr Parser::ParseAugAssign(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast AugAssign"; | |||||
| MS_LOG(DEBUG) << "Process ast AugAssign"; | |||||
| py::object op = python_adapter::GetPyObjAttr(node, "op"); | py::object op = python_adapter::GetPyObjAttr(node, "op"); | ||||
| MS_EXCEPTION_IF_NULL(block); | MS_EXCEPTION_IF_NULL(block); | ||||
| @@ -864,10 +864,10 @@ FunctionBlockPtr Parser::ParseAugAssign(const FunctionBlockPtr &block, const py: | |||||
| } else if (ast_->IsClassMember(target_node)) { | } else if (ast_->IsClassMember(target_node)) { | ||||
| read_node = ParseAttribute(block, target_node); | read_node = ParseAttribute(block, target_node); | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "not supported augassign"; | |||||
| MS_LOG(EXCEPTION) << "Not supported augassign"; | |||||
| } | } | ||||
| if (read_node == nullptr) { | if (read_node == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "can not get target node "; | |||||
| MS_LOG(EXCEPTION) << "Can not get target node "; | |||||
| } | } | ||||
| py::object value = python_adapter::GetPyObjAttr(node, "value"); | py::object value = python_adapter::GetPyObjAttr(node, "value"); | ||||
| @@ -879,7 +879,7 @@ FunctionBlockPtr Parser::ParseAugAssign(const FunctionBlockPtr &block, const py: | |||||
| // process global declaration such as 'global x'; | // process global declaration such as 'global x'; | ||||
| FunctionBlockPtr Parser::ParseGlobal(const FunctionBlockPtr &block, const py::object &node) { | FunctionBlockPtr Parser::ParseGlobal(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast Global"; | |||||
| MS_LOG(DEBUG) << "Process ast Global"; | |||||
| MS_EXCEPTION_IF_NULL(block); | MS_EXCEPTION_IF_NULL(block); | ||||
| py::list vars = python_adapter::GetPyObjAttr(node, "names"); | py::list vars = python_adapter::GetPyObjAttr(node, "names"); | ||||
| for (auto &item : vars) { | for (auto &item : vars) { | ||||
| @@ -890,7 +890,7 @@ FunctionBlockPtr Parser::ParseGlobal(const FunctionBlockPtr &block, const py::ob | |||||
| // process a if statement | // process a if statement | ||||
| FunctionBlockPtr Parser::ParseIf(const FunctionBlockPtr &block, const py::object &node) { | FunctionBlockPtr Parser::ParseIf(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast If"; | |||||
| MS_LOG(DEBUG) << "Process ast If"; | |||||
| py::object test_node = python_adapter::GetPyObjAttr(node, "test"); | py::object test_node = python_adapter::GetPyObjAttr(node, "test"); | ||||
| AnfNodePtr condition_node = ParseExprNode(block, test_node); | AnfNodePtr condition_node = ParseExprNode(block, test_node); | ||||
| MS_EXCEPTION_IF_NULL(block); | MS_EXCEPTION_IF_NULL(block); | ||||
| @@ -934,7 +934,7 @@ FunctionBlockPtr Parser::ParseIf(const FunctionBlockPtr &block, const py::object | |||||
| } | } | ||||
| FunctionBlockPtr Parser::ParseWhile(const FunctionBlockPtr &block, const py::object &node) { | FunctionBlockPtr Parser::ParseWhile(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast While"; | |||||
| MS_LOG(DEBUG) << "Process ast While"; | |||||
| MS_EXCEPTION_IF_NULL(block); | MS_EXCEPTION_IF_NULL(block); | ||||
| MS_LOG(INFO) << "Parse while statement"; | MS_LOG(INFO) << "Parse while statement"; | ||||
| TraceManager::DebugTrace(std::make_shared<TraceWhileHeader>(block->func_graph()->debug_info())); | TraceManager::DebugTrace(std::make_shared<TraceWhileHeader>(block->func_graph()->debug_info())); | ||||
| @@ -999,7 +999,7 @@ FunctionBlockPtr Parser::GenerateBlockInFor(const TraceInfoPtr &trace_info) { | |||||
| // x, it = next(it) | // x, it = next(it) | ||||
| // body | // body | ||||
| FunctionBlockPtr Parser::ParseFor(const FunctionBlockPtr &block, const py::object &node) { | FunctionBlockPtr Parser::ParseFor(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast For"; | |||||
| MS_LOG(DEBUG) << "Process ast For"; | |||||
| MS_EXCEPTION_IF_NULL(block); | MS_EXCEPTION_IF_NULL(block); | ||||
| AnfNodePtr op_iter = block->MakeResolveOperation(NAMED_PRIMITIVE_ITER); | AnfNodePtr op_iter = block->MakeResolveOperation(NAMED_PRIMITIVE_ITER); | ||||
| AnfNodePtr op_next = block->MakeResolveOperation(NAMED_PRIMITIVE_NEXT); | AnfNodePtr op_next = block->MakeResolveOperation(NAMED_PRIMITIVE_NEXT); | ||||
| @@ -1054,7 +1054,7 @@ FunctionBlockPtr Parser::ParseFor(const FunctionBlockPtr &block, const py::objec | |||||
| return after_block; | return after_block; | ||||
| } | } | ||||
| AnfNodePtr Parser::ParseIfExp(const FunctionBlockPtr &block, const py::object &node) { | AnfNodePtr Parser::ParseIfExp(const FunctionBlockPtr &block, const py::object &node) { | ||||
| MS_LOG(DEBUG) << "process ast IfExp"; | |||||
| MS_LOG(DEBUG) << "Process ast IfExp"; | |||||
| MS_EXCEPTION_IF_NULL(block); | MS_EXCEPTION_IF_NULL(block); | ||||
| py::object test_node = python_adapter::GetPyObjAttr(node, "test"); | py::object test_node = python_adapter::GetPyObjAttr(node, "test"); | ||||
| AnfNodePtr condition_node = ParseExprNode(block, test_node); | AnfNodePtr condition_node = ParseExprNode(block, test_node); | ||||
| @@ -1163,7 +1163,7 @@ void Parser::HandleAssignSubscript(const FunctionBlockPtr &block, const py::obje | |||||
| void Parser::WriteAssignVars(const FunctionBlockPtr &block, const py::object &targ, const AnfNodePtr &value_node) { | void Parser::WriteAssignVars(const FunctionBlockPtr &block, const py::object &targ, const AnfNodePtr &value_node) { | ||||
| MS_EXCEPTION_IF_NULL(value_node); | MS_EXCEPTION_IF_NULL(value_node); | ||||
| MS_LOG(DEBUG) << "process WriteAssignVars"; | |||||
| MS_LOG(DEBUG) << "Process WriteAssignVars"; | |||||
| auto ast_type = AstSubType(py::cast<int32_t>(ast_->CallParserObjMethod(PYTHON_PARSE_GET_AST_TYPE, targ))); | auto ast_type = AstSubType(py::cast<int32_t>(ast_->CallParserObjMethod(PYTHON_PARSE_GET_AST_TYPE, targ))); | ||||
| if (ast_type == AST_SUB_TYPE_NAME) { | if (ast_type == AST_SUB_TYPE_NAME) { | ||||
| HandleAssignName(block, targ, value_node); | HandleAssignName(block, targ, value_node); | ||||
| @@ -1174,7 +1174,7 @@ void Parser::WriteAssignVars(const FunctionBlockPtr &block, const py::object &ta | |||||
| } else if (ast_->IsClassMember(targ)) { | } else if (ast_->IsClassMember(targ)) { | ||||
| HandleAssignClassMember(block, targ, value_node); | HandleAssignClassMember(block, targ, value_node); | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "not supported assign type: " << ast_type | |||||
| MS_LOG(EXCEPTION) << "Not supported assign type: " << ast_type | |||||
| << " NodeInfo: " << trace::GetDebugInfo(value_node->debug_info()); | << " NodeInfo: " << trace::GetDebugInfo(value_node->debug_info()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1340,7 +1340,7 @@ bool ParseAst::UpdateFuncGraphFlags(const FuncGraphPtr &func_graph) { | |||||
| py::dict flags = python_adapter::GetPyObjAttr(obj_, PYTHON_EXTERN_MINDSPORE_FLAG); | py::dict flags = python_adapter::GetPyObjAttr(obj_, PYTHON_EXTERN_MINDSPORE_FLAG); | ||||
| for (auto &item : flags) { | for (auto &item : flags) { | ||||
| if (!py::isinstance<py::str>(item.first) || !py::isinstance<py::bool_>(item.second)) { | if (!py::isinstance<py::str>(item.first) || !py::isinstance<py::bool_>(item.second)) { | ||||
| MS_LOG(ERROR) << "type error in flags dict convert"; | |||||
| MS_LOG(ERROR) << "Type error in flags dict convert"; | |||||
| return false; | return false; | ||||
| } | } | ||||
| auto name = py::cast<std::string>(item.first); | auto name = py::cast<std::string>(item.first); | ||||
| @@ -40,8 +40,8 @@ enum ParseStatusCode : int { | |||||
| PARSE_PARAMETER_INVALID, // parameter is invalid | PARSE_PARAMETER_INVALID, // parameter is invalid | ||||
| PARSE_NO_RETURN, // function no return node | PARSE_NO_RETURN, // function no return node | ||||
| PARSE_NODE_TYPE_NO_MATCH, // ast node type is error | PARSE_NODE_TYPE_NO_MATCH, // ast node type is error | ||||
| PARSE_NODE_TYPE_UNKONW, // node type is unkonw | |||||
| PARSE_NODE_METHOD_UNSUPPORT, // no method to parse the node | |||||
| PARSE_NODE_TYPE_UNKOWN, // node type is unkown | |||||
| PARSE_NODE_METHOD_UNSUPPORTED, // no method to parse the node | |||||
| PARSE_DONT_RESOLVE_SYMBOL, // can't resolve the string | PARSE_DONT_RESOLVE_SYMBOL, // can't resolve the string | ||||
| PARSE_NOT_SUPPORTED_COMPARE_EXPR, // the comparison is not supported | PARSE_NOT_SUPPORTED_COMPARE_EXPR, // the comparison is not supported | ||||
| PARSE_FAILURE = 0xFF | PARSE_FAILURE = 0xFF | ||||
| @@ -102,7 +102,7 @@ class Parser { | |||||
| AnfNodePtr ParseCall(const FunctionBlockPtr &block, const py::object &node); | AnfNodePtr ParseCall(const FunctionBlockPtr &block, const py::object &node); | ||||
| // process the if expression | // process the if expression | ||||
| AnfNodePtr ParseIfExp(const FunctionBlockPtr &block, const py::object &node); | AnfNodePtr ParseIfExp(const FunctionBlockPtr &block, const py::object &node); | ||||
| // process calss type define | |||||
| // process class type define | |||||
| AnfNodePtr ParseAttribute(const FunctionBlockPtr &block, const py::object &node); | AnfNodePtr ParseAttribute(const FunctionBlockPtr &block, const py::object &node); | ||||
| // process a compare expression | // process a compare expression | ||||
| AnfNodePtr ParseCompare(const FunctionBlockPtr &block, const py::object &node); | AnfNodePtr ParseCompare(const FunctionBlockPtr &block, const py::object &node); | ||||
| @@ -45,7 +45,7 @@ enum AstSubType : int { | |||||
| // define the parse target type | // define the parse target type | ||||
| enum ParseTargetTypeDef { | enum ParseTargetTypeDef { | ||||
| PARSE_TARGET_FUNCTION = 0, // funciton | |||||
| PARSE_TARGET_FUNCTION = 0, // function | |||||
| PARSE_TARGET_METHOD = 1, // method | PARSE_TARGET_METHOD = 1, // method | ||||
| PARSE_TARGET_OBJECT_INSTANCE = 2, // object instance | PARSE_TARGET_OBJECT_INSTANCE = 2, // object instance | ||||
| PARSE_TARGET_UNKNOW = 0xFF // ERROR TYPE | PARSE_TARGET_UNKNOW = 0xFF // ERROR TYPE | ||||
| @@ -59,7 +59,7 @@ const char PYTHON_MOD_RESOLVE_GET_OBJ_KEY[] = "get_object_key"; | |||||
| const char PYTHON_MOD_PARSE_CHECK_IS_CLASS_MEMBER[] = "is_class_member"; | const char PYTHON_MOD_PARSE_CHECK_IS_CLASS_MEMBER[] = "is_class_member"; | ||||
| const char PYTHON_MOD_RESOLVE_GET_OBJ_TYPE[] = "get_obj_type"; | const char PYTHON_MOD_RESOLVE_GET_OBJ_TYPE[] = "get_obj_type"; | ||||
| const char PYTHON_MOD_GET_CLASS_INSTANCE_TYPE[] = "get_class_instance_type"; | const char PYTHON_MOD_GET_CLASS_INSTANCE_TYPE[] = "get_class_instance_type"; | ||||
| const char PYTHON_MOD_CRETAE_OBJ_INSTANCE[] = "create_obj_instance"; | |||||
| const char PYTHON_MOD_CREATE_OBJ_INSTANCE[] = "create_obj_instance"; | |||||
| const char PYTHON_MOD_GET_DATACLASS_ATTRS[] = "get_dataclass_attributes"; | const char PYTHON_MOD_GET_DATACLASS_ATTRS[] = "get_dataclass_attributes"; | ||||
| const char PYTHON_MOD_GET_DATACLASS_METHODS[] = "get_dataclass_methods"; | const char PYTHON_MOD_GET_DATACLASS_METHODS[] = "get_dataclass_methods"; | ||||
| const char PYTHON_MOD_GET_MODULE_NAMESPACE[] = "get_module_namespace"; | const char PYTHON_MOD_GET_MODULE_NAMESPACE[] = "get_module_namespace"; | ||||
| @@ -50,6 +50,7 @@ void SetPythonPath(const std::string& path) { | |||||
| (void)sys_path.attr("append")(path.c_str()); | (void)sys_path.attr("append")(path.c_str()); | ||||
| } | } | ||||
| } | } | ||||
| std::shared_ptr<py::scoped_interpreter> set_python_scoped() { | std::shared_ptr<py::scoped_interpreter> set_python_scoped() { | ||||
| // if start process from python, no need set the python scope. | // if start process from python, no need set the python scope. | ||||
| if (!python_env_) { | if (!python_env_) { | ||||
| @@ -79,6 +80,7 @@ py::object GetPyObjAttr(const py::object& obj, const std::string& attr) { | |||||
| } | } | ||||
| return py::none(); | return py::none(); | ||||
| } | } | ||||
| py::object GetPyFn(const std::string& module, const std::string& name) { | py::object GetPyFn(const std::string& module, const std::string& name) { | ||||
| (void)python_adapter::set_python_scoped(); | (void)python_adapter::set_python_scoped(); | ||||
| if (!module.empty() && !name.empty()) { | if (!module.empty() && !name.empty()) { | ||||
| @@ -53,6 +53,7 @@ abstract::AbstractBasePtr ClassType::ToAbstract() { | |||||
| ret_val->set_value_desc(ToString()); | ret_val->set_value_desc(ToString()); | ||||
| return ret_val; | return ret_val; | ||||
| } | } | ||||
| // call python PYTHON_MOD_RESOLVE_FUNCTION interface to resolve the symbol in corresponding namespace | // call python PYTHON_MOD_RESOLVE_FUNCTION interface to resolve the symbol in corresponding namespace | ||||
| bool SymbolResolver::Resolve() { | bool SymbolResolver::Resolve() { | ||||
| py::module mod = python_adapter::GetPyModule(PYTHON_MOD_PARSE_MODULE); | py::module mod = python_adapter::GetPyModule(PYTHON_MOD_PARSE_MODULE); | ||||
| @@ -127,7 +128,7 @@ bool ResolveObjectToNode(const FuncGraphPtr& func_graph, const py::object& obj, | |||||
| MS_LOG(ERROR) << "Resolve parameter object failed, got nullptr"; | MS_LOG(ERROR) << "Resolve parameter object failed, got nullptr"; | ||||
| return false; | return false; | ||||
| } | } | ||||
| MS_LOG(DEBUG) << "add param graph:" << func_graph->ToString() << ", " << param->DebugString(); | |||||
| MS_LOG(DEBUG) << "Add param graph:" << func_graph->ToString() << ", " << param->DebugString(); | |||||
| output = param; | output = param; | ||||
| } else if (py::hasattr(obj, "__parameter_tuple__")) { | } else if (py::hasattr(obj, "__parameter_tuple__")) { | ||||
| @@ -160,6 +161,7 @@ bool ResolveObjectToNode(const FuncGraphPtr& func_graph, const py::object& obj, | |||||
| *node = output; | *node = output; | ||||
| return true; | return true; | ||||
| } | } | ||||
| // transform the ValueTuple or ValueList of graph node to make tuple of const graph node | // transform the ValueTuple or ValueList of graph node to make tuple of const graph node | ||||
| bool TransformVectorGraphValueNode(const FuncGraphManagerPtr& manager, const AnfNodePtr& node, | bool TransformVectorGraphValueNode(const FuncGraphManagerPtr& manager, const AnfNodePtr& node, | ||||
| const ValueNodePtr& value_node, AnfNodePtr* const transformed) { | const ValueNodePtr& value_node, AnfNodePtr* const transformed) { | ||||
| @@ -175,7 +177,7 @@ bool TransformVectorGraphValueNode(const FuncGraphManagerPtr& manager, const Anf | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (has_graph_in_list) { | if (has_graph_in_list) { | ||||
| MS_LOG(EXCEPTION) << "list has graph in it , but not all is graph"; | |||||
| MS_LOG(EXCEPTION) << "List has graph in it, but not all is graph"; | |||||
| } | } | ||||
| } | } | ||||
| // The celllist or ordered_cell will be parsed as valuetuple of const graph in it, | // The celllist or ordered_cell will be parsed as valuetuple of const graph in it, | ||||
| @@ -195,13 +195,13 @@ void ReclaimOptimizer() { | |||||
| bool OptPassGroup(const ResourcePtr& res, const std::string& name) { | bool OptPassGroup(const ResourcePtr& res, const std::string& name) { | ||||
| if (res->func_graph() == nullptr) { | if (res->func_graph() == nullptr) { | ||||
| MS_LOG(ERROR) << "opt passes int error"; | |||||
| MS_LOG(ERROR) << "Opt passes int error"; | |||||
| return false; | return false; | ||||
| } | } | ||||
| abstract::AbstractBasePtrList args = res->args_spec(); | abstract::AbstractBasePtrList args = res->args_spec(); | ||||
| FuncGraphPtr func_graph = res->func_graph(); | FuncGraphPtr func_graph = res->func_graph(); | ||||
| MS_LOG(DEBUG) << "start " << name << " func graph:" << func_graph->ToString() << ", " | |||||
| MS_LOG(DEBUG) << "Start " << name << " func graph:" << func_graph->ToString() << ", " | |||||
| << func_graph->get_return()->DebugString(true); | << func_graph->get_return()->DebugString(true); | ||||
| InitOpt(res); | InitOpt(res); | ||||
| if (g_pass_opts.find(name) != g_pass_opts.end()) { | if (g_pass_opts.find(name) != g_pass_opts.end()) { | ||||
| @@ -98,7 +98,7 @@ py::tuple GenerateKey(const std::string& name, const std::unordered_map<std::str | |||||
| } | } | ||||
| if (g_args_cache.count(args_spec) == 0) { | if (g_args_cache.count(args_spec) == 0) { | ||||
| static int key = 0; | static int key = 0; | ||||
| MS_LOG(INFO) << "start new args and compile key:" << key; | |||||
| MS_LOG(INFO) << "Start new args and compile key:" << key; | |||||
| g_args_cache[args_spec] = key++; | g_args_cache[args_spec] = key++; | ||||
| } | } | ||||
| py::tuple argSpec = py::tuple(2); | py::tuple argSpec = py::tuple(2); | ||||
| @@ -110,7 +110,7 @@ py::tuple GenerateKey(const std::string& name, const std::unordered_map<std::str | |||||
| py::bool_ VerifyInputSignature(const py::list input_signature, const py::tuple inputs) { | py::bool_ VerifyInputSignature(const py::list input_signature, const py::tuple inputs) { | ||||
| MS_LOG(DEBUG) << "Verify args size:" << inputs.size(); | MS_LOG(DEBUG) << "Verify args size:" << inputs.size(); | ||||
| if (inputs.size() != input_signature.size()) { | if (inputs.size() != input_signature.size()) { | ||||
| MS_LOG(ERROR) << "signature size not equal to args size"; | |||||
| MS_LOG(ERROR) << "Signature size not equal to args size"; | |||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -148,7 +148,7 @@ py::bool_ VerifyInputSignature(const py::list input_signature, const py::tuple i | |||||
| ExecutorPy::ExecutorPy() {} | ExecutorPy::ExecutorPy() {} | ||||
| ResourcePtr ExecutorPy::GetResource(const std::string& phase) { | ResourcePtr ExecutorPy::GetResource(const std::string& phase) { | ||||
| MS_LOG(DEBUG) << "phase size:" << info_.size(); | |||||
| MS_LOG(DEBUG) << "Phase size:" << info_.size(); | |||||
| if (info_.count(phase) == 0) { | if (info_.count(phase) == 0) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -157,14 +157,14 @@ ResourcePtr ExecutorPy::GetResource(const std::string& phase) { | |||||
| FuncGraphPtr ExecutorPy::GetFuncGraph(const std::string& phase) { | FuncGraphPtr ExecutorPy::GetFuncGraph(const std::string& phase) { | ||||
| if (info_.count(phase) == 0) { | if (info_.count(phase) == 0) { | ||||
| MS_LOG(EXCEPTION) << "no phase in executor:" << GetPhasePrefix(phase); | |||||
| MS_LOG(EXCEPTION) << "No phase in executor:" << GetPhasePrefix(phase); | |||||
| } | } | ||||
| return info_[phase]->func_graph; | return info_[phase]->func_graph; | ||||
| } | } | ||||
| std::size_t ExecutorPy::ArgListSize(const std::string& phase) { | std::size_t ExecutorPy::ArgListSize(const std::string& phase) { | ||||
| if (info_.count(phase) == 0) { | if (info_.count(phase) == 0) { | ||||
| MS_LOG(EXCEPTION) << "no phase in executor:" << GetPhasePrefix(phase); | |||||
| MS_LOG(EXCEPTION) << "No phase in executor:" << GetPhasePrefix(phase); | |||||
| } | } | ||||
| return info_[phase]->arg_list_size; | return info_[phase]->arg_list_size; | ||||
| } | } | ||||
| @@ -243,7 +243,7 @@ void ExecutorPy::DelNetRes(const std::string& id) { | |||||
| auto tmp_info = info_; | auto tmp_info = info_; | ||||
| for (auto& item : tmp_info) { | for (auto& item : tmp_info) { | ||||
| if (item.first.find(id) != string::npos) { | if (item.first.find(id) != string::npos) { | ||||
| MS_LOG(INFO) << "delete network res:" << item.first; | |||||
| MS_LOG(INFO) << "Delete network res:" << item.first; | |||||
| (void)info_.erase(item.first); | (void)info_.erase(item.first); | ||||
| flag = true; | flag = true; | ||||
| } | } | ||||
| @@ -262,7 +262,7 @@ void ExecutorPy::DelNetRes(const std::string& id) { | |||||
| } | } | ||||
| void ExecutorPy::ClearRes() { | void ExecutorPy::ClearRes() { | ||||
| MS_LOG(INFO) << "clean executor Resrouce!"; | |||||
| MS_LOG(INFO) << "Clean executor resource!"; | |||||
| executor_ = nullptr; | executor_ = nullptr; | ||||
| } | } | ||||
| @@ -278,27 +278,27 @@ void ExecutorPy::SaveCompiledGraph(const std::string& phase_s) { | |||||
| MS_EXCEPTION_IF_NULL(parallel::ParallelContext::GetInstance()); | MS_EXCEPTION_IF_NULL(parallel::ParallelContext::GetInstance()); | ||||
| std::string parallel_mode = parallel::ParallelContext::GetInstance()->parallel_mode(); | std::string parallel_mode = parallel::ParallelContext::GetInstance()->parallel_mode(); | ||||
| MS_LOG(INFO) << "save compiled func graph(" << func_graph->ToString() << ") phase(" << phase_s << ")!"; | |||||
| MS_LOG(INFO) << "Save compiled func graph(" << func_graph->ToString() << ") phase(" << phase_s << ")!"; | |||||
| info_[phase_s]->func_graph = func_graph; | info_[phase_s]->func_graph = func_graph; | ||||
| if ((func_graph != nullptr) && | if ((func_graph != nullptr) && | ||||
| ((parallel_mode == parallel::AUTO_PARALLEL) || (parallel_mode == parallel::SEMI_AUTO_PARALLEL))) { | ((parallel_mode == parallel::AUTO_PARALLEL) || (parallel_mode == parallel::SEMI_AUTO_PARALLEL))) { | ||||
| MS_LOG(DEBUG) << "save model parallel parameter layout graph!"; | |||||
| MS_LOG(DEBUG) << "Save model parallel parameter layout graph!"; | |||||
| func_graph = info_[phase_s]->resource->results()[kStepParallelGraph].cast<FuncGraphPtr>(); | func_graph = info_[phase_s]->resource->results()[kStepParallelGraph].cast<FuncGraphPtr>(); | ||||
| ExecutorInfoPtr excutor_info = std::make_shared<ExecutorInfo>(); | |||||
| ExecutorInfoPtr executor_info = std::make_shared<ExecutorInfo>(); | |||||
| std::string layout_graph = phase_s + kStepParallelGraph; | std::string layout_graph = phase_s + kStepParallelGraph; | ||||
| excutor_info->func_graph = func_graph; | |||||
| info_[layout_graph] = excutor_info; | |||||
| executor_info->func_graph = func_graph; | |||||
| info_[layout_graph] = executor_info; | |||||
| } else { | } else { | ||||
| MS_LOG(DEBUG) << "save model parallel parameter layout graph null!"; | |||||
| MS_LOG(DEBUG) << "Save model parallel parameter layout graph null!"; | |||||
| } | } | ||||
| MS_LOG(INFO) << "end save compiled func graph!"; | |||||
| MS_LOG(INFO) << "End save compiled func graph!"; | |||||
| } | } | ||||
| bool ExecutorPy::ChangeExportGeirUseVmFlag(bool use_vm, const std::string& phase_s) const { | bool ExecutorPy::ChangeExportGeirUseVmFlag(bool use_vm, const std::string& phase_s) const { | ||||
| std::string phase_prefix = GetPhasePrefix(phase_s); | std::string phase_prefix = GetPhasePrefix(phase_s); | ||||
| if (use_vm && phase_prefix == "export") { | if (use_vm && phase_prefix == "export") { | ||||
| MS_LOG(INFO) << "use ge backend to export geir"; | |||||
| MS_LOG(INFO) << "Use ge backend to export geir"; | |||||
| use_vm = false; | use_vm = false; | ||||
| } | } | ||||
| return use_vm; | return use_vm; | ||||
| @@ -316,7 +316,7 @@ void ExecutorPy::GetGeBackendPolicy() const { | |||||
| bool ExecutorPy::CompileInner(const py::object& obj, const py::tuple& args, const py::object& phase, bool use_vm) { | bool ExecutorPy::CompileInner(const py::object& obj, const py::tuple& args, const py::object& phase, bool use_vm) { | ||||
| MS_LOG(DEBUG) << "Start ExecutorPy compile!"; | MS_LOG(DEBUG) << "Start ExecutorPy compile!"; | ||||
| if ((!py::isinstance<py::str>(phase))) { | if ((!py::isinstance<py::str>(phase))) { | ||||
| MS_LOG(ERROR) << "arg phase must be string."; | |||||
| MS_LOG(ERROR) << "Arg phase must be string."; | |||||
| return false; | return false; | ||||
| } | } | ||||
| // check the arg valid? | // check the arg valid? | ||||
| @@ -327,7 +327,7 @@ bool ExecutorPy::CompileInner(const py::object& obj, const py::tuple& args, cons | |||||
| #ifdef ENABLE_GE | #ifdef ENABLE_GE | ||||
| GetGeBackendPolicy(); | GetGeBackendPolicy(); | ||||
| #endif | #endif | ||||
| ExecutorInfoPtr excutor_info = std::make_shared<ExecutorInfo>(); | |||||
| ExecutorInfoPtr executor_info = std::make_shared<ExecutorInfo>(); | |||||
| std::string phase_s = py::cast<std::string>(phase); | std::string phase_s = py::cast<std::string>(phase); | ||||
| MS_LOG(INFO) << "ExecutorPy compile phase:" << phase_s << "!"; | MS_LOG(INFO) << "ExecutorPy compile phase:" << phase_s << "!"; | ||||
| ResourcePtr resource = std::make_shared<Resource>(obj); | ResourcePtr resource = std::make_shared<Resource>(obj); | ||||
| @@ -353,16 +353,16 @@ bool ExecutorPy::CompileInner(const py::object& obj, const py::tuple& args, cons | |||||
| ValuePtr converted = nullptr; | ValuePtr converted = nullptr; | ||||
| bool succ = parse::ConvertData(args[i], &converted); | bool succ = parse::ConvertData(args[i], &converted); | ||||
| if (!succ) { | if (!succ) { | ||||
| MS_LOG(EXCEPTION) << "args convert error"; | |||||
| MS_LOG(EXCEPTION) << "Args convert error"; | |||||
| } | } | ||||
| bool broaden = true; | bool broaden = true; | ||||
| args_spec.push_back(abstract::FromValue(converted, broaden)); | args_spec.push_back(abstract::FromValue(converted, broaden)); | ||||
| } | } | ||||
| resource->set_args_spec(args_spec); | resource->set_args_spec(args_spec); | ||||
| excutor_info->arg_list_size = size; | |||||
| excutor_info->resource = resource; | |||||
| info_[phase_s] = excutor_info; | |||||
| executor_info->arg_list_size = size; | |||||
| executor_info->resource = resource; | |||||
| info_[phase_s] = executor_info; | |||||
| pip->Run(); | pip->Run(); | ||||
| // save the run graph func to MsPipeLine | // save the run graph func to MsPipeLine | ||||
| @@ -439,7 +439,7 @@ std::string GetMsIrFile(void) { | |||||
| char real_path[PATH_MAX] = {0}; | char real_path[PATH_MAX] = {0}; | ||||
| if (realpath(path, real_path) == nullptr) { | if (realpath(path, real_path) == nullptr) { | ||||
| MS_LOG(ERROR) << "MS IR Path error, " << path; | |||||
| MS_LOG(ERROR) << "MS IR path error, " << path; | |||||
| return file; | return file; | ||||
| } | } | ||||
| file = real_path; | file = real_path; | ||||
| @@ -485,7 +485,7 @@ void RunPipelineAction(const ActionItem& action, pipeline::ResourcePtr resource, | |||||
| #endif | #endif | ||||
| void Pipeline::Run() { | void Pipeline::Run() { | ||||
| MS_LOG(INFO) << "pipeline run"; | |||||
| MS_LOG(INFO) << "Pipeline run"; | |||||
| MS_EXCEPTION_IF_NULL(resource_); | MS_EXCEPTION_IF_NULL(resource_); | ||||
| FuncGraphPtr user_graph = nullptr; | FuncGraphPtr user_graph = nullptr; | ||||
| @@ -507,7 +507,7 @@ void Pipeline::Run() { | |||||
| MS_LOG(DEBUG) << "Action " << action.first << " end."; | MS_LOG(DEBUG) << "Action " << action.first << " end."; | ||||
| }; | }; | ||||
| if (!result) { | if (!result) { | ||||
| MS_LOG(EXCEPTION) << "pipeline running to end, failed in step:" << action.first; | |||||
| MS_LOG(EXCEPTION) << "Pipeline running to end, failed in step:" << action.first; | |||||
| } | } | ||||
| if (MsContext::GetInstance()->save_graphs_flag() && resource_->func_graph() != nullptr) { | if (MsContext::GetInstance()->save_graphs_flag() && resource_->func_graph() != nullptr) { | ||||
| auto graph = resource_->func_graph(); | auto graph = resource_->func_graph(); | ||||
| @@ -555,7 +555,7 @@ void Pipeline::Run() { | |||||
| if (MsContext::GetInstance()->save_graphs_flag() && (user_graph != nullptr)) { | if (MsContext::GetInstance()->save_graphs_flag() && (user_graph != nullptr)) { | ||||
| std::string user_graph_file = GetFilePathName("ModelDigraph.dot"); | std::string user_graph_file = GetFilePathName("ModelDigraph.dot"); | ||||
| MS_LOG(DEBUG) << "save user graph to: " << user_graph_file; | |||||
| MS_LOG(DEBUG) << "Save user graph to: " << user_graph_file; | |||||
| draw::DrawUserFuncGraph(user_graph_file, user_graph); | draw::DrawUserFuncGraph(user_graph_file, user_graph); | ||||
| #ifdef ENABLE_DUMP_IR | #ifdef ENABLE_DUMP_IR | ||||
| @@ -572,7 +572,7 @@ void Pipeline::Run() { | |||||
| ChangeFileMode(filename, S_IRUSR); | ChangeFileMode(filename, S_IRUSR); | ||||
| #endif | #endif | ||||
| } | } | ||||
| MS_LOG(INFO) << "end"; | |||||
| MS_LOG(INFO) << "End"; | |||||
| } | } | ||||
| void ExecutorPy::ProcessVmArg(const py::tuple& args, const std::string& phase, VectorRef* arg_list) { | void ExecutorPy::ProcessVmArg(const py::tuple& args, const std::string& phase, VectorRef* arg_list) { | ||||
| @@ -582,7 +582,7 @@ void ExecutorPy::ProcessVmArg(const py::tuple& args, const std::string& phase, V | |||||
| py::object arg = args[i]; | py::object arg = args[i]; | ||||
| auto ms_context = MsContext::GetInstance(); | auto ms_context = MsContext::GetInstance(); | ||||
| if (ms_context->backend_policy() == kMsConvert && py::isinstance<py::array>(arg)) { | if (ms_context->backend_policy() == kMsConvert && py::isinstance<py::array>(arg)) { | ||||
| MS_LOG(EXCEPTION) << "args[" << i << "] is numpy array, not tensor"; | |||||
| MS_LOG(EXCEPTION) << "Args[" << i << "] is numpy array, not tensor"; | |||||
| } | } | ||||
| (*arg_list).push_back(arg); | (*arg_list).push_back(arg); | ||||
| } | } | ||||
| @@ -642,9 +642,9 @@ py::object ExecutorPy::Run(const py::tuple& args, const py::object& phase) { | |||||
| MS_LOG(EXCEPTION) << "Can't find run graph func for " << phase_s; | MS_LOG(EXCEPTION) << "Can't find run graph func for " << phase_s; | ||||
| } | } | ||||
| MS_LOG(DEBUG) << "eval run" << backend; | |||||
| MS_LOG(DEBUG) << "Eval run" << backend; | |||||
| BaseRef value = (*run)(arg_list); | BaseRef value = (*run)(arg_list); | ||||
| MS_LOG(DEBUG) << "run end"; | |||||
| MS_LOG(DEBUG) << "Run end"; | |||||
| return BaseRefToPyData(value); | return BaseRefToPyData(value); | ||||
| } | } | ||||
| @@ -704,9 +704,9 @@ bool InitExecDatasetVm(const std::string& queue_name, int64_t size, int64_t batc | |||||
| p_init->set_attr("shapes", MakeValue(int_shapes)); | p_init->set_attr("shapes", MakeValue(int_shapes)); | ||||
| p_init->set_attr("input_indexes", MakeValue(int_input_indexes)); | p_init->set_attr("input_indexes", MakeValue(int_input_indexes)); | ||||
| const std::vector<std::string> emply_str_list; | |||||
| p_init->set_attr("input_names", MakeValue(emply_str_list)); | |||||
| p_init->set_attr("output_names", MakeValue(emply_str_list)); | |||||
| const std::vector<std::string> empty_str_list; | |||||
| p_init->set_attr("input_names", MakeValue(empty_str_list)); | |||||
| p_init->set_attr("output_names", MakeValue(empty_str_list)); | |||||
| FuncGraphPtr func_graph = std::make_shared<FuncGraph>(); | FuncGraphPtr func_graph = std::make_shared<FuncGraph>(); | ||||
| auto app_init = std::make_shared<CNode>(AnfNodePtrList{NewValueNode(p_init)}, func_graph); | auto app_init = std::make_shared<CNode>(AnfNodePtrList{NewValueNode(p_init)}, func_graph); | ||||
| @@ -730,7 +730,7 @@ bool InitExecDatasetVm(const std::string& queue_name, int64_t size, int64_t batc | |||||
| if (!(*runner.run)) { | if (!(*runner.run)) { | ||||
| // empty function | // empty function | ||||
| MS_LOG(EXCEPTION) << "Backend " << backend->name() << " unsupports tdt dataset."; | |||||
| MS_LOG(EXCEPTION) << "Backend " << backend->name() << " unsupported tdt dataset."; | |||||
| } | } | ||||
| // launch init dataset runner without inputs and outputs | // launch init dataset runner without inputs and outputs | ||||
| @@ -758,7 +758,7 @@ void InitHccl() { | |||||
| auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(device_name, device_id); | auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(device_name, device_id); | ||||
| MS_EXCEPTION_IF_NULL(runtime_instance); | MS_EXCEPTION_IF_NULL(runtime_instance); | ||||
| if (!runtime_instance->Init()) { | if (!runtime_instance->Init()) { | ||||
| MS_LOG(ERROR) << "kernel runtime init error."; | |||||
| MS_LOG(ERROR) << "Kernel runtime init error."; | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -795,7 +795,7 @@ void InitGe() { | |||||
| auto ms_context = MsContext::GetInstance(); | auto ms_context = MsContext::GetInstance(); | ||||
| MS_EXCEPTION_IF_NULL(ms_context); | MS_EXCEPTION_IF_NULL(ms_context); | ||||
| if (!ms_context->OpenTsd()) { | if (!ms_context->OpenTsd()) { | ||||
| MS_LOG(EXCEPTION) << "open tsd failed"; | |||||
| MS_LOG(EXCEPTION) << "Open tsd failed"; | |||||
| } | } | ||||
| (void)ms_context->InitGe(); | (void)ms_context->InitGe(); | ||||
| } | } | ||||
| @@ -210,7 +210,7 @@ bool AddDFGraph(const std::map<std::string, ExecutorInfoPtr>& info, const py::di | |||||
| (void)convertor.GenerateCheckpointGraph(); | (void)convertor.GenerateCheckpointGraph(); | ||||
| if (convertor.ErrCode() != 0) { | if (convertor.ErrCode() != 0) { | ||||
| DfGraphManager::GetInstance().ClearGraph(); | DfGraphManager::GetInstance().ClearGraph(); | ||||
| MS_LOG(ERROR) << "convert df graph failed, err:" << convertor.ErrCode(); | |||||
| MS_LOG(ERROR) << "Convert df graph failed, err:" << convertor.ErrCode(); | |||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -238,7 +238,7 @@ bool AddDFGraph(const std::map<std::string, ExecutorInfoPtr>& info, const py::di | |||||
| FuncGraphPtr BuildDFGraph(const std::map<std::string, ExecutorInfoPtr>& info, const py::dict& init_params, | FuncGraphPtr BuildDFGraph(const std::map<std::string, ExecutorInfoPtr>& info, const py::dict& init_params, | ||||
| const std::string& phase, const py::object& broadcast_params) { | const std::string& phase, const py::object& broadcast_params) { | ||||
| if (info.count(phase) == 0) { | if (info.count(phase) == 0) { | ||||
| MS_LOG(EXCEPTION) << "no phase in executor:" << GetPhasePrefix(phase); | |||||
| MS_LOG(EXCEPTION) << "No phase in executor:" << GetPhasePrefix(phase); | |||||
| } | } | ||||
| FuncGraphPtr anf_graph = info.at(phase)->func_graph; | FuncGraphPtr anf_graph = info.at(phase)->func_graph; | ||||
| @@ -389,7 +389,7 @@ std::shared_ptr<py::object> DoExecGraph(const FuncGraphPtr& graph, const std::ve | |||||
| const std::string& phase) { | const std::string& phase) { | ||||
| std::vector<GeTensorPtr> ge_tensors = TransformUtil::ConvertInputTensors(inputs, kOpFormat_NCHW); | std::vector<GeTensorPtr> ge_tensors = TransformUtil::ConvertInputTensors(inputs, kOpFormat_NCHW); | ||||
| if (ge_tensors.size() != inputs.size()) { | if (ge_tensors.size() != inputs.size()) { | ||||
| MS_LOG(ERROR) << "args convert to ge tensor error"; | |||||
| MS_LOG(ERROR) << "Args convert to ge tensor error"; | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -444,7 +444,7 @@ void ProcessGeArg(const std::map<std::string, ExecutorInfoPtr>& info, const py:: | |||||
| std::size_t size = args.size(); | std::size_t size = args.size(); | ||||
| if (info.count(phase) == 0) { | if (info.count(phase) == 0) { | ||||
| MS_LOG(EXCEPTION) << "no phase in executor:" << GetPhasePrefix(phase); | |||||
| MS_LOG(EXCEPTION) << "No phase in executor:" << GetPhasePrefix(phase); | |||||
| } | } | ||||
| auto arg_size = info.at(phase)->arg_list_size; | auto arg_size = info.at(phase)->arg_list_size; | ||||
| @@ -459,12 +459,12 @@ void ProcessGeArg(const std::map<std::string, ExecutorInfoPtr>& info, const py:: | |||||
| ValuePtr converted = nullptr; | ValuePtr converted = nullptr; | ||||
| bool succ = parse::ConvertData(args[i], &converted); | bool succ = parse::ConvertData(args[i], &converted); | ||||
| if (!succ) { | if (!succ) { | ||||
| MS_LOG(EXCEPTION) << "args convert error"; | |||||
| MS_LOG(EXCEPTION) << "Args convert error"; | |||||
| } | } | ||||
| if (converted->isa<tensor::Tensor>()) { | if (converted->isa<tensor::Tensor>()) { | ||||
| (*inputs).push_back(converted->cast<tensor::TensorPtr>()); | (*inputs).push_back(converted->cast<tensor::TensorPtr>()); | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "args, " << converted->ToString() << " is not tensor"; | |||||
| MS_LOG(EXCEPTION) << "Args " << converted->ToString() << " is not tensor"; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -481,7 +481,7 @@ py::object ExecDFGraph(const std::map<std::string, ExecutorInfoPtr>& info, const | |||||
| } | } | ||||
| if (info.count(phase) == 0) { | if (info.count(phase) == 0) { | ||||
| MS_LOG(EXCEPTION) << "has no phase:" << phase; | |||||
| MS_LOG(EXCEPTION) << "There is no phase:" << phase; | |||||
| } | } | ||||
| FuncGraphPtr anf_graph = info.at(phase)->func_graph; | FuncGraphPtr anf_graph = info.at(phase)->func_graph; | ||||
| @@ -511,7 +511,7 @@ py::object ExecDFGraph(const std::map<std::string, ExecutorInfoPtr>& info, const | |||||
| if (ret != nullptr) { | if (ret != nullptr) { | ||||
| return *ret; | return *ret; | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "exec graph failed"; | |||||
| MS_LOG(EXCEPTION) << "Exec graph failed"; | |||||
| } | } | ||||
| } | } | ||||
| void ExportDFGraph(const std::string& file_name, const std::string& phase) { | void ExportDFGraph(const std::string& file_name, const std::string& phase) { | ||||
| @@ -189,7 +189,7 @@ Resource::~Resource() { | |||||
| // If exit normally, these global variables will be cleaned | // If exit normally, these global variables will be cleaned | ||||
| // in Resource::Clean call by MsPipeline::Compile, but if exit with MS_LOGEXCEPTION, | // in Resource::Clean call by MsPipeline::Compile, but if exit with MS_LOGEXCEPTION, | ||||
| // these global variables may not being cleaned, it may | // these global variables may not being cleaned, it may | ||||
| // cause segmentfault when free python object inside these global varaibles | |||||
| // cause segmentfault when free python object inside these global variables | |||||
| // after python interpreter got freed, so these global variables | // after python interpreter got freed, so these global variables | ||||
| // are cleaned here. | // are cleaned here. | ||||
| // So if exit normally, these global variable will be cleaned twice, | // So if exit normally, these global variable will be cleaned twice, | ||||
| @@ -443,7 +443,7 @@ bool AbstractTensor::operator==(const AbstractTensor &other) const { | |||||
| auto v1 = GetValueTrack(); | auto v1 = GetValueTrack(); | ||||
| auto v2 = other.GetValueTrack(); | auto v2 = other.GetValueTrack(); | ||||
| if (v1 == nullptr || v2 == nullptr) { | if (v1 == nullptr || v2 == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "the value of AbstractTensor is nullptr"; | |||||
| MS_LOG(EXCEPTION) << "The value of AbstractTensor is nullptr"; | |||||
| } | } | ||||
| bool is_value_equal = (v1 == v2); | bool is_value_equal = (v1 == v2); | ||||
| @@ -77,7 +77,7 @@ class AbstractBase : public Base { | |||||
| } | } | ||||
| protected: | protected: | ||||
| // default implementation, it can be overrided by subclass; | |||||
| // default implementation, it can be overwritten by subclass; | |||||
| virtual ValuePtr RealBuildValue() const { return kAnyValue; } | virtual ValuePtr RealBuildValue() const { return kAnyValue; } | ||||
| private: | private: | ||||
| @@ -495,7 +495,7 @@ class AbstractNone : public AbstractBase { | |||||
| }; | }; | ||||
| using AbstractNonePtr = std::shared_ptr<AbstractNone>; | using AbstractNonePtr = std::shared_ptr<AbstractNone>; | ||||
| // the un assgined state value for variable, which means the variable is not assigned | |||||
| // the un assigned state value for variable, which means the variable is not assigned | |||||
| class AbstractNull : public AbstractBase { | class AbstractNull : public AbstractBase { | ||||
| public: | public: | ||||
| AbstractNull() : AbstractBase(kNullObj) { set_type(std::make_shared<TypeNull>()); } | AbstractNull() : AbstractBase(kNullObj) { set_type(std::make_shared<TypeNull>()); } | ||||
| @@ -116,7 +116,7 @@ AbstractBasePtrList FuncGraphEvaluator::NormalizeArgs(const AbstractBasePtrList | |||||
| return broaded_list; | return broaded_list; | ||||
| } | } | ||||
| if (func_graph_->has_flag(kFuncGraphFlagUndetermin)) { | |||||
| if (func_graph_->has_flag(kFuncGraphFlagUndetermined)) { | |||||
| if (parent_context_) { | if (parent_context_) { | ||||
| MS_LOG(DEBUG) << "Undeterminate FuncGraphEvaluator " << ToString() | MS_LOG(DEBUG) << "Undeterminate FuncGraphEvaluator " << ToString() | ||||
| << ", context: " << parent_context_->ToString(); | << ", context: " << parent_context_->ToString(); | ||||
| @@ -56,7 +56,7 @@ TypePtr CheckTensorDType(const AbstractTensorPtr &tensor, const TypePtrList &acc | |||||
| } | } | ||||
| TypePtr ele_type = tensor->element()->BuildType(); | TypePtr ele_type = tensor->element()->BuildType(); | ||||
| if (ele_type == nullptr) { | if (ele_type == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "abstract tensor element type nullptr"; | |||||
| MS_LOG(EXCEPTION) << "Abstract tensor element type nullptr"; | |||||
| } | } | ||||
| return CheckType(ele_type, accepts, error_message_prefix); | return CheckType(ele_type, accepts, error_message_prefix); | ||||
| } | } | ||||
| @@ -64,7 +64,7 @@ TypePtr CheckTensorDType(const AbstractTensorPtr &tensor, const TypePtrList &acc | |||||
| TypePtr CheckTensorsDTypeSame(const AbstractTensorPtrList &tensor_list, const TypePtrList &accepts, | TypePtr CheckTensorsDTypeSame(const AbstractTensorPtrList &tensor_list, const TypePtrList &accepts, | ||||
| const std::string &error_message_prefix) { | const std::string &error_message_prefix) { | ||||
| if (tensor_list.empty()) { | if (tensor_list.empty()) { | ||||
| MS_LOG(EXCEPTION) << "array list is empty"; | |||||
| MS_LOG(EXCEPTION) << "Array list is empty"; | |||||
| } | } | ||||
| auto sample_tensor = tensor_list[0]; | auto sample_tensor = tensor_list[0]; | ||||
| @@ -78,7 +78,7 @@ TypePtr CheckTensorsDTypeSame(const AbstractTensorPtrList &tensor_list, const Ty | |||||
| auto aType = tensor_list[index]->element()->BuildType(); | auto aType = tensor_list[index]->element()->BuildType(); | ||||
| loginfoBuffer << " " << aType->ToString(); | loginfoBuffer << " " << aType->ToString(); | ||||
| if (sample_type->type_id() != aType->type_id()) { | if (sample_type->type_id() != aType->type_id()) { | ||||
| MS_LOG(EXCEPTION) << "expected type " << sample_type->ToString() << ", but got " << aType->ToString() | |||||
| MS_LOG(EXCEPTION) << "Expected type " << sample_type->ToString() << ", but got " << aType->ToString() | |||||
| << ", index " << index; | << ", index " << index; | ||||
| } | } | ||||
| } | } | ||||
| @@ -89,11 +89,11 @@ TypePtr CheckTensorsDTypeSame(const AbstractTensorPtrList &tensor_list, const Ty | |||||
| TypePtr CheckScalarType(const AbstractScalarPtr &scalar, const TypePtrList &accepts, | TypePtr CheckScalarType(const AbstractScalarPtr &scalar, const TypePtrList &accepts, | ||||
| const std::string &error_message_prefix) { | const std::string &error_message_prefix) { | ||||
| if (scalar == nullptr) { | if (scalar == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "scalar nullptr"; | |||||
| MS_LOG(EXCEPTION) << "Scalar nullptr"; | |||||
| } | } | ||||
| auto type = scalar->BuildType(); | auto type = scalar->BuildType(); | ||||
| if (type == nullptr) { | if (type == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "scalar value nullptr"; | |||||
| MS_LOG(EXCEPTION) << "Scalar value nullptr"; | |||||
| } | } | ||||
| return CheckType(type, accepts, error_message_prefix); | return CheckType(type, accepts, error_message_prefix); | ||||
| @@ -182,30 +182,30 @@ AbstractBasePtr DoSignatureEvaluator::Run(AnalysisEnginePtr engine, const Config | |||||
| static AbstractBasePtrList GetUnpackGraphSpecArgsList(AbstractBasePtrList args_spec_list, bool need_unpack) { | static AbstractBasePtrList GetUnpackGraphSpecArgsList(AbstractBasePtrList args_spec_list, bool need_unpack) { | ||||
| // arg[0] is the func graph to unpack, ignore it | // arg[0] is the func graph to unpack, ignore it | ||||
| AbstractBasePtrList sepcialize_args_before_unpack(args_spec_list.begin() + 1, args_spec_list.end()); | |||||
| AbstractBasePtrList graph_sepcialize_args; | |||||
| AbstractBasePtrList specialize_args_before_unpack(args_spec_list.begin() + 1, args_spec_list.end()); | |||||
| AbstractBasePtrList graph_specialize_args; | |||||
| if (need_unpack) { | if (need_unpack) { | ||||
| for (size_t index = 0; index < sepcialize_args_before_unpack.size(); index++) { | |||||
| MS_EXCEPTION_IF_NULL(sepcialize_args_before_unpack[index]); | |||||
| if (sepcialize_args_before_unpack[index]->isa<AbstractTuple>()) { | |||||
| AbstractTuplePtr arg_tuple = sepcialize_args_before_unpack[index]->cast<AbstractTuplePtr>(); | |||||
| for (size_t index = 0; index < specialize_args_before_unpack.size(); index++) { | |||||
| MS_EXCEPTION_IF_NULL(specialize_args_before_unpack[index]); | |||||
| if (specialize_args_before_unpack[index]->isa<AbstractTuple>()) { | |||||
| AbstractTuplePtr arg_tuple = specialize_args_before_unpack[index]->cast<AbstractTuplePtr>(); | |||||
| std::transform(arg_tuple->elements().begin(), arg_tuple->elements().end(), | std::transform(arg_tuple->elements().begin(), arg_tuple->elements().end(), | ||||
| std::back_inserter(graph_sepcialize_args), [](AbstractBasePtr abs) { return abs; }); | |||||
| } else if (sepcialize_args_before_unpack[index]->isa<AbstractDictionary>()) { | |||||
| AbstractDictionaryPtr arg_dict = sepcialize_args_before_unpack[index]->cast<AbstractDictionaryPtr>(); | |||||
| std::back_inserter(graph_specialize_args), [](AbstractBasePtr abs) { return abs; }); | |||||
| } else if (specialize_args_before_unpack[index]->isa<AbstractDictionary>()) { | |||||
| AbstractDictionaryPtr arg_dict = specialize_args_before_unpack[index]->cast<AbstractDictionaryPtr>(); | |||||
| auto dict_elems = arg_dict->elements(); | auto dict_elems = arg_dict->elements(); | ||||
| (void)std::transform( | (void)std::transform( | ||||
| dict_elems.begin(), dict_elems.end(), std::back_inserter(graph_sepcialize_args), | |||||
| dict_elems.begin(), dict_elems.end(), std::back_inserter(graph_specialize_args), | |||||
| [](const AbstractAttribute &item) { return std::make_shared<AbstractKeywordArg>(item.first, item.second); }); | [](const AbstractAttribute &item) { return std::make_shared<AbstractKeywordArg>(item.first, item.second); }); | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "UnpackGraph require args should be tuple or dict, but got " | MS_LOG(EXCEPTION) << "UnpackGraph require args should be tuple or dict, but got " | ||||
| << sepcialize_args_before_unpack[index]->ToString(); | |||||
| << specialize_args_before_unpack[index]->ToString(); | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| graph_sepcialize_args = sepcialize_args_before_unpack; | |||||
| graph_specialize_args = specialize_args_before_unpack; | |||||
| } | } | ||||
| return graph_sepcialize_args; | |||||
| return graph_specialize_args; | |||||
| } | } | ||||
| AbstractBasePtr UnpackGraphEvaluator::Run(AnalysisEnginePtr engine, const ConfigPtrList &args_conf_list, | AbstractBasePtr UnpackGraphEvaluator::Run(AnalysisEnginePtr engine, const ConfigPtrList &args_conf_list, | ||||
| @@ -239,14 +239,14 @@ AbstractBasePtr UnpackGraphEvaluator::Run(AnalysisEnginePtr engine, const Config | |||||
| MS_EXCEPTION_IF_NULL(real_fn); | MS_EXCEPTION_IF_NULL(real_fn); | ||||
| FuncGraphPtr forward_graph = real_fn->func_graph(); | FuncGraphPtr forward_graph = real_fn->func_graph(); | ||||
| MS_EXCEPTION_IF_NULL(forward_graph); | MS_EXCEPTION_IF_NULL(forward_graph); | ||||
| AbstractBasePtrList graph_sepcialize_args = | |||||
| AbstractBasePtrList graph_specialize_args = | |||||
| GetUnpackGraphSpecArgsList(args_spec_list, unpack_graph->need_unpack_args()); | GetUnpackGraphSpecArgsList(args_spec_list, unpack_graph->need_unpack_args()); | ||||
| AbstractBasePtrList graph_sepcialize_args_without_sens; | |||||
| (void)std::transform(graph_sepcialize_args.begin(), | |||||
| graph_sepcialize_args.end() - (unpack_graph->with_sens_in_args() ? 1 : 0), | |||||
| std::back_inserter(graph_sepcialize_args_without_sens), [](AbstractBasePtr abs) { return abs; }); | |||||
| auto new_graph = forward_graph->GenerateGraph(graph_sepcialize_args_without_sens); | |||||
| AbstractBasePtrList graph_specialize_args_without_sens; | |||||
| (void)std::transform(graph_specialize_args.begin(), | |||||
| graph_specialize_args.end() - (unpack_graph->with_sens_in_args() ? 1 : 0), | |||||
| std::back_inserter(graph_specialize_args_without_sens), [](AbstractBasePtr abs) { return abs; }); | |||||
| auto new_graph = forward_graph->GenerateGraph(graph_specialize_args_without_sens); | |||||
| engine->func_graph_manager()->AddFuncGraph(new_graph); | engine->func_graph_manager()->AddFuncGraph(new_graph); | ||||
| ScopePtr scope = kDefaultScope; | ScopePtr scope = kDefaultScope; | ||||
| if (out_conf != nullptr) { | if (out_conf != nullptr) { | ||||
| @@ -635,8 +635,8 @@ AbstractBasePtr GetEvaluatedValueForClassAttrOrMethod(const AnalysisEnginePtr &e | |||||
| MS_LOG(EXCEPTION) << "Attribute type error"; | MS_LOG(EXCEPTION) << "Attribute type error"; | ||||
| } | } | ||||
| std::string item_name = item_v->cast<StringImmPtr>()->value(); | std::string item_name = item_v->cast<StringImmPtr>()->value(); | ||||
| MS_LOG(DEBUG) << "Resovle name: " << cls->tag().name(); | |||||
| MS_LOG(DEBUG) << "Resovle item: " << item_name; | |||||
| MS_LOG(DEBUG) << "Resolve name: " << cls->tag().name(); | |||||
| MS_LOG(DEBUG) << "Resolve item: " << item_name; | |||||
| AbstractBasePtr attr = cls->GetAttribute(item_name); | AbstractBasePtr attr = cls->GetAttribute(item_name); | ||||
| if (attr != nullptr) { | if (attr != nullptr) { | ||||
| @@ -720,7 +720,7 @@ class EmbedEvaluator : public SymbolicPrimEvaluator { | |||||
| ~EmbedEvaluator() override = default; | ~EmbedEvaluator() override = default; | ||||
| MS_DECLARE_PARENT(EmbedEvaluator, SymbolicPrimEvaluator); | MS_DECLARE_PARENT(EmbedEvaluator, SymbolicPrimEvaluator); | ||||
| AbstractBasePtr EvalPrim(const ConfigPtrList &args_conf_list) override { | AbstractBasePtr EvalPrim(const ConfigPtrList &args_conf_list) override { | ||||
| // arg: free variable to be embeded | |||||
| // arg: free variable to be embedded | |||||
| if (args_conf_list.size() != 1) { | if (args_conf_list.size() != 1) { | ||||
| MS_LOG(EXCEPTION) << "EmbedEvaluator requires 1 parameter, but got " << args_conf_list.size(); | MS_LOG(EXCEPTION) << "EmbedEvaluator requires 1 parameter, but got " << args_conf_list.size(); | ||||
| } | } | ||||
| @@ -939,7 +939,7 @@ class PartialEvaluator : public Evaluator { | |||||
| AbstractBasePtr Run(AnalysisEnginePtr engine, const ConfigPtrList &args_conf_list, | AbstractBasePtr Run(AnalysisEnginePtr engine, const ConfigPtrList &args_conf_list, | ||||
| AnfNodeConfigPtr out_conf = nullptr) override { | AnfNodeConfigPtr out_conf = nullptr) override { | ||||
| if (args_conf_list.size() == 0) { | if (args_conf_list.size() == 0) { | ||||
| MS_LOG(EXCEPTION) << "args size should be greater than 0"; | |||||
| MS_LOG(EXCEPTION) << "Args size should be greater than 0"; | |||||
| } | } | ||||
| auto arg0_value = args_conf_list[0]->GetEvaluatedValue(); | auto arg0_value = args_conf_list[0]->GetEvaluatedValue(); | ||||
| AbstractBasePtrList args_spec_list{arg0_value}; | AbstractBasePtrList args_spec_list{arg0_value}; | ||||
| @@ -190,7 +190,7 @@ void FuncGraphSpecializer::FirstPass() { | |||||
| } | } | ||||
| if (node->func_graph() != func_graph_) { | if (node->func_graph() != func_graph_) { | ||||
| if (parent_ == nullptr) { | if (parent_ == nullptr) { | ||||
| MS_LOG(EXCEPTION) << "parent must not null NodeInfo: " << trace::GetDebugInfo(node->debug_info()); | |||||
| MS_LOG(EXCEPTION) << "Parent must not null NodeInfo: " << trace::GetDebugInfo(node->debug_info()); | |||||
| } | } | ||||
| parent_->AddTodoItem(node); | parent_->AddTodoItem(node); | ||||
| parent_->FirstPass(); | parent_->FirstPass(); | ||||
| @@ -365,16 +365,16 @@ AnfNodePtr FuncGraphSpecializer::BuildSpecializedNodeInner(const AbstractBasePtr | |||||
| } | } | ||||
| if (!eval->isa<BaseFuncGraphEvaluator>()) { | if (!eval->isa<BaseFuncGraphEvaluator>()) { | ||||
| MS_LOG(EXCEPTION) << "eval is not BaseGraphEvaluator, but " << eval->ToString(); | |||||
| MS_LOG(EXCEPTION) << "Eval is not BaseGraphEvaluator, but " << eval->ToString(); | |||||
| } | } | ||||
| auto real_eval = dyn_cast<BaseFuncGraphEvaluator>(eval); | auto real_eval = dyn_cast<BaseFuncGraphEvaluator>(eval); | ||||
| if (func->context() != nullptr) { | if (func->context() != nullptr) { | ||||
| if (!IsVisible(func_graph_, func->context()->func_graph())) { | if (!IsVisible(func_graph_, func->context()->func_graph())) { | ||||
| MS_LOG(EXCEPTION) << "func is not visible NodeInfo: " << trace::GetDebugInfo(func_graph_->debug_info()); | |||||
| MS_LOG(EXCEPTION) << "Func is not visible NodeInfo: " << trace::GetDebugInfo(func_graph_->debug_info()); | |||||
| } | } | ||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "func context is nullptr NodeInfo: " << trace::GetDebugInfo(func_graph_->debug_info()); | |||||
| MS_LOG(EXCEPTION) << "Func context is nullptr NodeInfo: " << trace::GetDebugInfo(func_graph_->debug_info()); | |||||
| } | } | ||||
| AnalysisContextPtr context = real_eval->MakeContext(engine_, argvals); | AnalysisContextPtr context = real_eval->MakeContext(engine_, argvals); | ||||
| MS_LOG(DEBUG) << "Specialize function graph: " << context->func_graph()->ToString() << ", args: " << argvals.size() | MS_LOG(DEBUG) << "Specialize function graph: " << context->func_graph()->ToString() << ", args: " << argvals.size() | ||||
| @@ -556,7 +556,7 @@ SpecializeStatusCode FuncGraphSpecializer::FindUniqueArgvals(const AbstractFunct | |||||
| if (!result->first.empty()) { | if (!result->first.empty()) { | ||||
| return kSpecializeSuccess; | return kSpecializeSuccess; | ||||
| } | } | ||||
| MS_LOG(DEBUG) << "Find POLY code, it may be unused code or unresoved polymorphism."; | |||||
| MS_LOG(DEBUG) << "Find POLY code, it may be unused code or unresolved polymorphism."; | |||||
| return kSpecializeFindUniqueArgvalPoly; | return kSpecializeFindUniqueArgvalPoly; | ||||
| } | } | ||||
| } | } | ||||
| @@ -89,7 +89,7 @@ std::size_t AnfNodeConfigHasher::operator()(const AnfNodeConfigPtr conf) const { | |||||
| MS_EXCEPTION_IF_NULL(conf->node()); | MS_EXCEPTION_IF_NULL(conf->node()); | ||||
| std::size_t hash_value = hash_combine(conf->node()->hash(), conf->context()->hash()); | std::size_t hash_value = hash_combine(conf->node()->hash(), conf->context()->hash()); | ||||
| if (conf->context() != nullptr && conf->context()->func_graph() != nullptr) { | if (conf->context() != nullptr && conf->context()->func_graph() != nullptr) { | ||||
| MS_LOG(DEBUG) << "NodeConfgHasher Node: " << conf->node()->DebugString() | |||||
| MS_LOG(DEBUG) << "NodeConfigHasher Node: " << conf->node()->DebugString() | |||||
| << ", Graph: " << conf->context()->func_graph()->ToString() << " ### , hash value: " << hash_value; | << ", Graph: " << conf->context()->func_graph()->ToString() << " ### , hash value: " << hash_value; | ||||
| } else { | } else { | ||||
| MS_LOG(DEBUG) << "NodeConfigHasher Node: " << conf->node()->DebugString() << " ### , hash value: " << hash_value; | MS_LOG(DEBUG) << "NodeConfigHasher Node: " << conf->node()->DebugString() << " ### , hash value: " << hash_value; | ||||
| @@ -456,13 +456,13 @@ AbstractBasePtr AnalysisEngine::ExecuteMultipleEvaluators(const std::vector<Eval | |||||
| for (auto eval : evaluators) { | for (auto eval : evaluators) { | ||||
| auto fg_eval = eval->cast<FuncGraphEvaluatorPtr>(); | auto fg_eval = eval->cast<FuncGraphEvaluatorPtr>(); | ||||
| if (fg_eval) { | if (fg_eval) { | ||||
| auto undetermin_fgs = fg_eval->func_graph()->recursive_graphs(); | |||||
| if (undetermin_fgs) { | |||||
| for (auto undetermin_fg : *undetermin_fgs) { | |||||
| MS_LOG(DEBUG) << "Set graph undetermin: " << undetermin_fg->ToString(); | |||||
| auto undetermined_fgs = fg_eval->func_graph()->recursive_graphs(); | |||||
| if (undetermined_fgs) { | |||||
| for (auto undetermined_fg : *undetermined_fgs) { | |||||
| MS_LOG(DEBUG) << "Set graph undetermined: " << undetermined_fg->ToString(); | |||||
| // As the current evaluator has multiple possibles, all the func_graphs which | // As the current evaluator has multiple possibles, all the func_graphs which | ||||
| // are recursive with the current func_graph are undetermined in control flow. | // are recursive with the current func_graph are undetermined in control flow. | ||||
| undetermin_fg->set_flags(kFuncGraphFlagUndetermin, true); | |||||
| undetermined_fg->set_flags(kFuncGraphFlagUndetermined, true); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||