Skip to content

Commit

Permalink
remove additional warnning in layer.to
Browse files Browse the repository at this point in the history
  • Loading branch information
JiabinYang committed Oct 25, 2021
1 parent 4f12d7e commit 3fd7e25
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions python/paddle/fluid/dygraph/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,17 +1479,17 @@ def _apply(self, func, device, dtype, blocking):
param_applied.is_distributed = param.is_distributed
self._parameters[key] = param_applied

if param.grad is not None:
with no_grad():
grad_applied = func(param._grad_ivar(), device,
dtype, blocking)

grad_applied.stop_gradient = param._grad_ivar(
).stop_gradient
if hasattr(param._grad_ivar(), 'is_distributed'):
grad_applied.is_distributed = param._grad_ivar(
).is_distributed
self._parameters[key]._set_grad_ivar(grad_applied)
if param.grad is not None:
with no_grad():
grad_applied = func(param._grad_ivar(), device, dtype,
blocking)

grad_applied.stop_gradient = param._grad_ivar(
).stop_gradient
if hasattr(param._grad_ivar(), 'is_distributed'):
grad_applied.is_distributed = param._grad_ivar(
).is_distributed
self._parameters[key]._set_grad_ivar(grad_applied)

self._parameters_transform_map[id(param)] = [param_applied, key]

Expand Down

0 comments on commit 3fd7e25

Please sign in to comment.