!12552 fix bug of pynative amp

From: @jojobugfree
Reviewed-by: @chujinjin,@zhoufeng54
Signed-off-by: @chujinjin
This commit is contained in:
mindspore-ci-bot 2021-02-24 15:16:37 +08:00 committed by Gitee
commit 8f9666c93f
1 changed files with 2 additions and 1 deletions

View File

@ -463,7 +463,8 @@ class Parameter(Tensor_):
if mstype.implicit_conversion_seq[self.dtype] < mstype.implicit_conversion_seq[data.dtype]:
raise_type_error(data.dtype)
else:
data = Tensor(data, self.dtype)
from mindspore.ops import functional as F
data = F.cast(data, self.dtype)
if isinstance(data, Tensor) and data.has_init:
# The parameter has been initializered, directly update by the data
if current_tensor_is_init: