How to print at::tensor in C++

How to print at::tensor in C++ during debugging a custom op?
1.code line?
2.gdb?

You can use std::cout << your_tensor << std::endl; to print the content of a Tensor.

Is there a way of printing the size of a tensor without iterating through all elements of size()?

So doing something like cout << t.size() << end.

I believe std::cout << self.sizes() << std::endl; will work no?

1 Like

Thanks for your reply. Indeed, tensor impl has some attributes of tensor.