How do you debug libtorch using gdb

I wonder how do you guys debug libtorch using gdb ?

1 Like

What do you mean?
You can debug your cpp program that uses libtorch as any other cpp program. Is there something specific you want to do?

Yes there is specific thing I want to do, I want to print read torch::Tensor elements using gdb. I use CLion IDE, The tensor elements and shape does not show up on CLion debugger.

The .sizes() function should return the sizes to you.
You can access the values by passing the Tensor to <<, not sure how to do that in the CLion ide though :confused:

thank you for your response, Hmmm… it is what I usually use, or sometime I use at::print() to print the entire tensor … using std out will mess my code,… is there any standard or best practice to debug libtorch program

Did you ever find a solution to this issue? std out is not a great solution and I am looking for something else.