From dfdcfb9450466ccbf8b9467732ff77fb6df6f17e Mon Sep 17 00:00:00 2001 From: zhangbo9674 <82555433+zhangbo9674@users.noreply.github.com> Date: Mon, 27 Jun 2022 10:38:39 +0800 Subject: [PATCH] amp.decorate save_dtype hook skil int (#43824) --- python/paddle/fluid/dygraph/amp/auto_cast.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/dygraph/amp/auto_cast.py b/python/paddle/fluid/dygraph/amp/auto_cast.py index 12ddf1a0f8..8547501e1b 100644 --- a/python/paddle/fluid/dygraph/amp/auto_cast.py +++ b/python/paddle/fluid/dygraph/amp/auto_cast.py @@ -395,9 +395,10 @@ class StateDictHook(object): for key in state_dict: param = state_dict[key] with paddle.fluid.dygraph.guard(): - param_applied = paddle.cast(param, self._save_dtype) - param_applied.name = param.name - state_dict[key] = param_applied + if paddle.is_floating_point(param): + param_applied = paddle.cast(param, self._save_dtype) + param_applied.name = param.name + state_dict[key] = param_applied @dygraph_only -- GitLab