Browse Source

!4728 Fix tensor print format

Merge pull request !4728 from hewei/fix_tensor_to_string
tags/v0.7.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
213eacbd58
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      mindspore/core/ir/tensor.cc

+ 5
- 5
mindspore/core/ir/tensor.cc View File

@@ -485,12 +485,12 @@ std::string Tensor::ToString() const {
auto dtype = Dtype();
MS_EXCEPTION_IF_NULL(dtype);
data_sync();
buf << "Tensor(shape=" << ShapeToString(shape_) << ", dtype=" << dtype->ToString() << ",\n";
buf << "Tensor(shape=" << ShapeToString(shape_) << ", dtype=" << dtype->ToString() << ',';
if (DataSize() < small_tensor_size) {
// Only print data for small tensor.
buf << data().ToString(data_type_, shape_) << ')';
buf << ((data().ndim() > 1) ? '\n' : ' ') << data().ToString(data_type_, shape_) << ')';
} else {
buf << "[...])";
buf << " [...])";
}
return buf.str();
}
@@ -500,8 +500,8 @@ std::string Tensor::ToStringRepr() const {
auto dtype = Dtype();
MS_EXCEPTION_IF_NULL(dtype);
data_sync();
buf << "Tensor(shape=" << ShapeToString(shape_) << ", dtype=" << dtype->ToString() << ",\n"
<< data().ToString(data_type_, shape_) << ')';
buf << "Tensor(shape=" << ShapeToString(shape_) << ", dtype=" << dtype->ToString() << ','
<< ((data().ndim() > 1) ? '\n' : ' ') << data().ToString(data_type_, shape_) << ')';
return buf.str();
}



Loading…
Cancel
Save