Browse Source

fix int8_t/uint8_t print

Signed-off-by: zjun <zhangjun0@huawei.com>
tags/v0.7.0-beta
zjun 5 years ago
parent
commit
f0282395d9
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      mindspore/ccsrc/utils/tensorprint_utils.cc

+ 7
- 2
mindspore/ccsrc/utils/tensorprint_utils.cc View File

@@ -105,10 +105,15 @@ template <typename T>
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<const T *>(str_data_ptr);
*buf << "Tensor shape:[1] " << tensor_type;
*buf << "\nval:";
*buf << *data_ptr << "\n";
const T *data_ptr = reinterpret_cast<const T *>(str_data_ptr);
if constexpr (std::is_same<T, int8_t>::value || std::is_same<T, uint8_t>::value) {
const int int_data = static_cast<int>(*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) {


Loading…
Cancel
Save