The following error occurs after I upgrade to Pytorch 1.2.0. No errors when running in 1.1.0

one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [3]], which is output 0 of AddBackward0, is at version 1; expected version 0 instead.

Codes:

import torch
b0 = torch.tensor(5.0, requires_grad = True)
a = torch.Tensor([1,0,0])
b = torch.zeros(3, requires_grad = True)
c = torch.ones(3, requires_grad = True)
bb = b+1
bb[a!=0] = torch.min(bb[a!=0], c[a!=0])
d = torch.sum(bb)
d.backward()

Is there a way to make it work in 1.2.0? I tried adding clone() at a couple of locations, but still didn’t work.