Skip to content

Commit 1640334

Browse files
authored
Merge pull request #12215 from luotao1/clone_var
fix _clone_variable in optimizer.py
2 parents e104cf9 + e33017f commit 1640334

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

python/paddle/fluid/optimizer.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,16 +1180,16 @@ def __init__(self,
11801180
self._add_average_restore_op(block, param_grad)
11811181

11821182
def _add_average_apply_op(self, block, param_grad):
1183-
param = block.clone_variable(param_grad[0])
1184-
grad = block.clone_variable(param_grad[1])
1185-
sum_1 = block.clone_variable(self._get_accumulator('sum_1', param))
1186-
sum_2 = block.clone_variable(self._get_accumulator('sum_2', param))
1187-
sum_3 = block.clone_variable(self._get_accumulator('sum_3', param))
1188-
num_accumulates = block.clone_variable(
1183+
param = block._clone_variable(param_grad[0])
1184+
grad = block._clone_variable(param_grad[1])
1185+
sum_1 = block._clone_variable(self._get_accumulator('sum_1', param))
1186+
sum_2 = block._clone_variable(self._get_accumulator('sum_2', param))
1187+
sum_3 = block._clone_variable(self._get_accumulator('sum_3', param))
1188+
num_accumulates = block._clone_variable(
11891189
self._get_accumulator('num_accumulates', param))
1190-
old_num_accumulates = block.clone_variable(
1190+
old_num_accumulates = block._clone_variable(
11911191
self._get_accumulator('old_num_accumulates', param))
1192-
num_updates = block.clone_variable(
1192+
num_updates = block._clone_variable(
11931193
self._get_accumulator('num_updates', param))
11941194
# backup param value to grad
11951195
layers.assign(input=param, output=grad)
@@ -1203,8 +1203,8 @@ def _add_average_apply_op(self, block, param_grad):
12031203
layers.elementwise_div(x=sum, y=tmp, out=param)
12041204

12051205
def _add_average_restore_op(self, block, param_grad):
1206-
param = block.clone_variable(param_grad[0])
1207-
grad = block.clone_variable(param_grad[1])
1206+
param = block._clone_variable(param_grad[0])
1207+
grad = block._clone_variable(param_grad[1])
12081208
layers.assign(input=grad, output=param)
12091209

12101210
def _append_average_accumulate_op(self, param):

0 commit comments

Comments
 (0)