!19490 fix python parameter del coredump if raise an error before init finished

Merge pull request !19490 from huanghui/fix-parameter
This commit is contained in:
i-robot 2021-07-09 06:36:08 +00:00 committed by Gitee
commit 3a408218ec
1 changed files with 4 additions and 2 deletions

View File

@ -136,6 +136,7 @@ class Parameter(Tensor_):
def __init__(self, default_input, name=None, requires_grad=True, layerwise_parallel=False, parallel_optimizer=True):
self.param_info = ParamInfo()
self.init_param_info = True
self.init_in_server = False
self.cache_enable = False
self.name = name
@ -581,8 +582,9 @@ class Parameter(Tensor_):
return obj
def __del__(self):
if context.get_context("mode") == context.GRAPH_MODE:
self.param_info = None
if hasattr(self, "init_param_info"):
if self.init_param_info is True and context.get_context("mode") == context.GRAPH_MODE:
self.param_info = None
class ParameterTuple(tuple):