diff --git a/mindspore/ccsrc/utils/tensorprint_utils.cc b/mindspore/ccsrc/utils/tensorprint_utils.cc index d6dbe970c4..b716931b31 100644 --- a/mindspore/ccsrc/utils/tensorprint_utils.cc +++ b/mindspore/ccsrc/utils/tensorprint_utils.cc @@ -105,10 +105,15 @@ template void PrintScalarToString(const char *str_data_ptr, const string &tensor_type, std::ostringstream *const buf) { MS_EXCEPTION_IF_NULL(str_data_ptr); MS_EXCEPTION_IF_NULL(buf); - const T *data_ptr = reinterpret_cast(str_data_ptr); *buf << "Tensor shape:[1] " << tensor_type; *buf << "\nval:"; - *buf << *data_ptr << "\n"; + const T *data_ptr = reinterpret_cast(str_data_ptr); + if constexpr (std::is_same::value || std::is_same::value) { + const int int_data = static_cast(*data_ptr); + *buf << int_data << "\n"; + } else { + *buf << *data_ptr << "\n"; + } } void PrintScalarToBoolString(const char *str_data_ptr, const string &tensor_type, std::ostringstream *const buf) {