What's the difference in gradient backprop between slicing and nn.Unfold?

If you’d like to know whether the two outputs have the same value, computing the sum is one heuristic, but you can also use torch.allclose(a, b)

If you’d like to compute whether two functions compute the same gradient. You should use grad_inp = torch.autograd.grad(output, inp) to compute the gradients of inputs wrt each of the outputs respectively, and then compare them with torch.allclose.