Skip to content

Commit

Permalink
Merge pull request #8382 from y1r/fp32_update_on_chainerx
Browse files Browse the repository at this point in the history
Fix `optimizer.use_fp32_update` on ChainerX model
  • Loading branch information
takagi committed Apr 4, 2020
2 parents 8629ac2 + 2c6d8be commit 97e8327
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion chainer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ def __update(self, param):
# Convert back to the original dtype
if fp32_converted:
if is_initialized:
param.array = fp32_param.array.astype(param.dtype)
if isinstance(param.array, chainerx.ndarray):
param.array[:] = fp32_param.array.astype(param.dtype)
else:
param.array = fp32_param.array.astype(param.dtype)
fp32_param.grad = None

def _create_uninitialized_parameter(self, dtype, name):
Expand Down

0 comments on commit 97e8327

Please sign in to comment.