Browse Source

!4454 fix int8/uint8 print bug

Merge pull request !4454 from zjun/fix_int8_print
tags/v0.7.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
d94a8e02ca
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