Summary:
Resolves #15923 where LBFGS threw "Error: a leaf Variable that requires grad has been used in an in-place operation."
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16167
Differential Revision:
D13745822
Pulled By: soumith
fbshipit-source-id:
7d1d0511d06838c0c6f4c8a6b53cf15193283059
#include <torch/csrc/autograd/generated/variable_factories.h>
#include <torch/csrc/autograd/variable.h>
#include <torch/serialize/archive.h>
+#include <torch/utils.h>
#include <ATen/ATen.h>
}
void LBFGS::add_grad(const torch::Tensor& step_size, const Tensor& update) {
+ NoGradGuard guard;
int64_t offset = 0;
for (auto& parameter : parameters_) {
int64_t numel = parameter.numel();