How can I view the contents of a C++/Libtorch tensor while debugging in an IDE like CLION?

I am trying to view the contents of tensors while debugging in CLION like I do for PyTorch tensors. However I am unable to view the contents of the tensor.

I have gone through these discussion boards but have not found any sort of solution.

I’d like to be able to view the contents like I view a vector’s contents (or something similiar and easy). My only solution at the moment is to cout at runtime, but that is unruly for long tensors and seems much more backwards than when doing it in python.

2 Likes

This is my simple tensor in my example:

torch::Tensor tensor = torch::rand({2, 3});