未验证 提交 8071d230 编写于 作者: Z Zhou Wei 提交者: GitHub

fix bug that can't print int8_t (#26712)

fix bug that can't print int8_t 
上级 f4083010
...@@ -913,10 +913,20 @@ std::ostream& print_tensor(std::ostream& os, const framework::Tensor& tensor) { ...@@ -913,10 +913,20 @@ std::ostream& print_tensor(std::ostream& os, const framework::Tensor& tensor) {
auto element_num = tensor.numel(); auto element_num = tensor.numel();
os << " - data: ["; os << " - data: [";
if (element_num > 0) { // Note: int8_t && uint8_t is typedf of char, ostream unable to print properly
os << inspect[0]; if (typeid(int8_t) == typeid(T) || typeid(uint8_t) == typeid(T)) {
for (int j = 1; j < element_num; ++j) { if (element_num > 0) {
os << " " << inspect[j]; os << signed(inspect[0]);
for (int j = 1; j < element_num; ++j) {
os << " " << signed(inspect[j]);
}
}
} else {
if (element_num > 0) {
os << inspect[0];
for (int j = 1; j < element_num; ++j) {
os << " " << inspect[j];
}
} }
} }
os << "]"; os << "]";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册