提交 f9ab2781 编写于 作者: H He Wei

Sync data while Tensor::ToString()

上级 4276050f
......@@ -465,6 +465,7 @@ std::string Tensor::GetShapeAndDataTypeInfo() const {
std::string Tensor::ToString() const {
const int small_tensor_size = 30;
std::ostringstream buf;
data_sync();
buf << "Tensor shape:[" << shape() << "]" << this->Dtype()->ToString();
// only print small tensor
if (DataSize() < small_tensor_size) {
......@@ -477,6 +478,7 @@ std::string Tensor::ToStringRepr() const {
std::ostringstream buf;
auto type_ptr = this->Dtype();
MS_EXCEPTION_IF_NULL(type_ptr);
data_sync();
buf << "Tensor shape:[" << shape() << "]" << type_ptr->ToString();
buf << "\nvalue:" << data().ToString(data_type_, shape());
return buf.str();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册