I would like to get the grad_fn name from the c++ side. Something like <AddBackward0> in python:
tensor([[3., 3.],
        [3., 3.]], grad_fn=<AddBackward0>)

I tried the following:
#include <torch/torch.h>
#include <iostream>

int main() {
  torch::Tensor x = torch::randn({2, 3});
  x.set_requires_grad(true);
  torch::autograd::Variable y(x);
  std::cout << y.grad_fn().get()->name << std::endl;
}

But it does not compile. The error is:
error: member access into incomplete type
      'std::__1::shared_ptr<torch::autograd::Function>::element_type' (aka 'torch::autograd::Function')
  std::cout << y.grad_fn().get()->name << std::endl;

Does anyone can help me?
Thanks in advance!