How to estimate size of serialized tensor (in C++)?

Hi.

If I write a tensor into an ostringstream named testStream, I can get the size(in bytes) of the serialized tensor by testStream.str().length(). How can I get this value without actually executing any action such as “serializing into ostringstream”?

Thank you.