From 7bf8d2696c8b74f7e81f6ecaab008a2f71ee93a5 Mon Sep 17 00:00:00 2001 From: zjun Date: Tue, 26 May 2020 09:42:37 +0800 Subject: [PATCH] fix scalar print --- mindspore/ccsrc/utils/tensorprint_utils.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/utils/tensorprint_utils.cc b/mindspore/ccsrc/utils/tensorprint_utils.cc index b34944cf2..56f0f13f4 100644 --- a/mindspore/ccsrc/utils/tensorprint_utils.cc +++ b/mindspore/ccsrc/utils/tensorprint_utils.cc @@ -32,6 +32,7 @@ namespace mindspore { const char kShapeSeperator[] = ","; const char kShapeScalar[] = "[0]"; +const char kShapeNone[] = "[]"; static std::map print_type_map = { {"int8_t", TypeId::kNumberTypeInt8}, {"uint8_t", TypeId::kNumberTypeUInt8}, {"int16_t", TypeId::kNumberTypeInt16}, {"uint16_t", TypeId::kNumberTypeUInt16}, @@ -163,9 +164,9 @@ bool ConvertDataItem2Tensor(const std::vector &items) { } std::shared_ptr str_data_ptr = std::static_pointer_cast(item.dataPtr_); MS_EXCEPTION_IF_NULL(str_data_ptr); - if (item.tensorShape_ == kShapeScalar) { + if (item.tensorShape_ == kShapeScalar || item.tensorShape_ == kShapeNone) { if (!judgeLengthValid(str_data_ptr->size(), item.tensorType_)) { - MS_LOG(EXCEPTION) << "Print op receive data length is invalid."; + MS_LOG(EXCEPTION) << "Print op receive data length is invalid."; } convertDataItem2Scalar(str_data_ptr->data(), item.tensorType_, &buf); continue; -- GitLab