Avoid temp string if standard string_view is available
ostream output and `std::hash` currently fall-back to `std::string` to
ensure correctness, which means an extra allocation. If available, we
should prefer `std::string_view` or `std::experimental::string_view`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76975
Approved by: https://github.com/swolchok