!12505 add exception description for assign subnet parameter

From: @zhangbuxue
Reviewed-by: @ginfung,@zh_qh
Signed-off-by: @zh_qh
pull/12505/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 1a745006ae

@ -66,6 +66,7 @@ AST_SUB_TYPE_NAME = 5 # ast.Name
AST_SUB_TYPE_TUPLE = 6 # ast.Tuple
AST_SUB_TYPE_SUBSCRIPT = 7 # ast.Subscript
AST_SUB_TYPE_STARRED = 8 # ast.Starred
AST_SUB_TYPE_ATTRIBUTE = 9 # ast.Attribute
AST_SUB_TYPE_UNKNOWN = 0xFF # unknown
# Process expr statement white list
@ -456,6 +457,8 @@ class Parser:
ast_type = AST_SUB_TYPE_SUBSCRIPT
elif isinstance(node, ast.Starred):
ast_type = AST_SUB_TYPE_STARRED
elif isinstance(node, ast.Attribute):
ast_type = AST_SUB_TYPE_ATTRIBUTE
else:
ast_type = AST_SUB_TYPE_UNKNOWN
return ast_type

@ -1588,6 +1588,9 @@ void Parser::WriteAssignVars(const FunctionBlockPtr &block, const py::object &ta
HandleAssignSubscript(block, targ, value_node);
} else if (ast_->IsClassMember(targ)) {
HandleAssignClassMember(block, targ, value_node);
} else if (ast_type == AST_SUB_TYPE_ATTRIBUTE) {
MS_LOG(EXCEPTION) << "The subnet attributes cannot be changed in the network"
<< " NodeInfo: " << trace::GetDebugInfo(value_node->debug_info());
} else {
MS_LOG(EXCEPTION) << "Not supported assign type: " << ast_type
<< " NodeInfo: " << trace::GetDebugInfo(value_node->debug_info());

@ -42,6 +42,7 @@ enum AstSubType : int64_t {
AST_SUB_TYPE_TUPLE = 6, // ast.Tuple
AST_SUB_TYPE_SUBSCRIPT = 7, // ast.Subscript
AST_SUB_TYPE_STARRED = 8, // ast.Starred
AST_SUB_TYPE_ATTRIBUTE = 9, // ast.Attribute
AST_SUB_TYPE_UNKNOWN = 0xFF // Error
};
@ -147,7 +148,7 @@ const char RESOLVE_NAMESPACE_NAME_MODULE[] = "Module"; // fro Module
// define Resolve type
enum ResolveTypeDef : int64_t {
RESOLVE_TYPE_NONE = 0, // resolve None
RESOLVE_TYPE_FUNCTION = 1, // reslove function
RESOLVE_TYPE_FUNCTION = 1, // resolve function
RESOLVE_TYPE_METHOD = 2, // resolve class method
RESOLVE_TYPE_CLASS_TYPE = 3, // resolve class type
RESOLVE_TYPE_CLASS_INSTANCE = 4, // resolve the class instance of common class

Loading…
Cancel
Save