Fix bug in torch::load and unpack torch::optim::detail namespace (#15926)
authorPeter Goldsborough <psag@fb.com>
Thu, 10 Jan 2019 21:50:41 +0000 (13:50 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 10 Jan 2019 21:55:50 +0000 (13:55 -0800)
commitb1fa19961e266f900fa5283a913b57c054509b5d
tree8986a96f07f69e5e1a73d384edcdb22f8cc2a9f5
parent9173cd5a4d31abd8cf42fcae0341db8287a69074
Fix bug in torch::load and unpack torch::optim::detail namespace (#15926)

Summary:
Wasn't clearing optimizer buffers before adding new entries to it during deserialization. Successive calls to `torch::load` with the same optimizer would just append to the buffer container. Also moved `serialize()` function from `torch::optim::detail` into `torch::optim` so users can use it for custom optimizers.

Fixes #15792

ezyang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15926

Differential Revision: D13623615

Pulled By: goldsborough

fbshipit-source-id: e193091f25f56a95f2a9648af312cb7caa45f300
torch/csrc/api/include/torch/optim/adagrad.h
torch/csrc/api/include/torch/optim/adam.h
torch/csrc/api/include/torch/optim/lbfgs.h
torch/csrc/api/include/torch/optim/optimizer.h
torch/csrc/api/include/torch/optim/rmsprop.h
torch/csrc/api/include/torch/optim/serialize.h
torch/csrc/api/src/optim/serialize.cpp
torch/csrc/api/src/optim/sgd.cpp