提交 2aa35759 编写于 作者: Z Zhang Qinghua

Set the width of different int type for printing Tensor data.

上级 0a74c8a5
......@@ -224,10 +224,21 @@ class TensorDataImpl : public TensorData {
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) {
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) {
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 {
ss << value;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册