From f0282395d95c788692d205d1bc0837dd65529cf2 Mon Sep 17 00:00:00 2001 From: zjun Date: Fri, 14 Aug 2020 15:51:49 +0800 Subject: [PATCH] fix int8_t/uint8_t print Signed-off-by: zjun --- mindspore/ccsrc/utils/tensorprint_utils.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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) {