Skip to content

Commit

Permalink
Updates div sometimes performing floor division to explicitly perform…
Browse files Browse the repository at this point in the history
… either true division or floor division

Summary:
torch.div will soon throw a runtime error when it would have performed floor division. This diff updates this instance of div to use either the true division or floor division operators as appropriate so the behavior doesn't change and the test won't throw a runtime error.

Created from Diffusion's 'Open in Editor' feature.

Reviewed By: myleott

Differential Revision: D21900423

fbshipit-source-id: 363c3e64d25608a033cd2942dcbb039a73018596
  • Loading branch information
Mike Ruberry authored and facebook-github-bot committed Jun 5, 2020
1 parent 023f7af commit b1f9a8f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/average_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def average_checkpoints(inputs):
averaged_params = collections.OrderedDict()
for k, v in params_dict.items():
averaged_params[k] = v
averaged_params[k].div_(num_models)
if averaged_params[k].is_floating_point():
averaged_params[k].div_(num_models)
else:
averaged_params[k] //= num_models
new_state['model'] = averaged_params
return new_state

Expand Down

0 comments on commit b1f9a8f

Please sign in to comment.