Skip to content

Commit

Permalink
bugfix: param init with fill constant str_value (PaddlePaddle#33381)
Browse files Browse the repository at this point in the history
  • Loading branch information
JZ-LIANG committed Jun 9, 2021
1 parent d496722 commit f8c7b37
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/paddle/fluid/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ def __call__(self, var, block=None):
out_dtype = var.dtype
out_var = var

# fill constant should set the "str_value" to preserve precision
op = block.append_op(
type="fill_constant",
outputs={"Out": out_var},
attrs={
"shape": var.shape,
"dtype": int(out_dtype),
"value": float(self._value),
'str_value': str(float(self._value)),
'force_cpu': self._force_cpu
},
stop_gradient=True)
Expand Down

0 comments on commit f8c7b37

Please sign in to comment.