def test_elu_inplace_view(self):
v = Variable(torch.Tensor([1.0, -1.0, 1.0, -1.0]), requires_grad=True)
def func(root):
x = root.clone()
view = x.narrow(0, 1, 2)
res = F.elu(view, inplace=True)
self.assertIs(res, view)
return x
gradcheck(func, [v])
gradgradcheck(func, [v])
评论列表
文章目录