Browse Source

!3468 Set the width for int8/int16/int32 and their relevant unsigned type.

Merge pull request !3468 from ZhangQinghua/master1
tags/v0.7.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
dba675f04f
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      mindspore/core/ir/tensor.cc

+ 13
- 2
mindspore/core/ir/tensor.cc View File

@@ -224,10 +224,21 @@ class TensorDataImpl : public TensorData {
ss << ' '; ss << ' ';
} }
} }

// Set width and indent for different int type.
//
// int8/uint8 width: 3
// int16/uint16 width: 5
// int32/uint32 width: 10
// int64/uint64 width: NOT SET
if constexpr (std::is_same<T, int8_t>::value) { if constexpr (std::is_same<T, int8_t>::value) {
ss << static_cast<int16_t>(value);
ss << std::setw(3) << std::setiosflags(std::ios::right) << static_cast<int16_t>(value);
} else if constexpr (std::is_same<T, uint8_t>::value) { } else if constexpr (std::is_same<T, uint8_t>::value) {
ss << static_cast<uint16_t>(value);
ss << std::setw(3) << std::setiosflags(std::ios::right) << static_cast<uint16_t>(value);
} else if constexpr (std::is_same<T, int16_t>::value || std::is_same<T, uint16_t>::value) {
ss << std::setw(5) << std::setiosflags(std::ios::right) << value;
} else if constexpr (std::is_same<T, int32_t>::value || std::is_same<T, uint32_t>::value) {
ss << std::setw(10) << std::setiosflags(std::ios::right) << value;
} else { } else {
ss << value; ss << value;
} }


Loading…
Cancel
Save