I have tried to find a way to get the string reprensentation of a tensor for logging with spdlog.

torch::Tensor tensor;
// works
std::cout << tensor << "\n";
// spdlog prints error: "basic_ios::clear: iostream error"
spdlog::info("tensor: {}", tensor);

I’m thinking to work around the error by getting the string of tensor first and pass it to spdlog but failed to find any API which does that. I really appreciate any help. Thanks in advance!