Print tensor to string with size constraints

If I print a huge tensor in libtorch to a string it will simply print it all. Is there a way to get the output in a nice way like if I print a tensor in python, where it limits what it puts out for large tensors?

Currently I do this to print to a string:

        std::stringstream buffer;
        buffer << *t << std::endl;

Currently, there is no way to act like python print. We do plan to improve this later.
The only thing that you can control is how many chars in one line. see here:

1 Like