I am trying to run the LibTorch autograd example 1 but runs into the following error.
class c10::Error: grad can be implicitly created only for scalar outputs (_make_grads at ..\..\torch\csrc\autograd\autograd.cpp:47)

The code to reproduce this is.
#include <torch/csrc/autograd/variable.h>
#include <torch/csrc/autograd/function.h>

int main(int argc, char** argv)
{
  torch::Tensor a = torch::ones({2, 2}, torch::requires_grad());
  torch::Tensor b = torch::randn({2, 2});
  auto c = a + b;
  c.backward(); // a.grad() will now hold the gradient of c w.r.t. a.

  return EXIT_SUCCESS;
}

This works if c is a scalar. Any help on this?