From 8023c9c213a776e065e60f9bb91d592b1acb31d2 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 10:30:51 +0800 Subject: [PATCH 01/12] error message add format --- .../format_transfers/datatype_transfer.cc | 23 ++++++---- .../format_transfer_c1hwncoc0_hwcn.cc | 20 ++++++--- .../format_transfer_dhwcn_fracz3D.cc | 6 +-- ...format_transfer_dhwnc_fracz3D_transpose.cc | 6 +-- .../format_transfer_fractal_nz.cc | 15 +++---- .../format_transfer_fractal_z.cc | 11 ++--- .../format_transfer_fractal_zz.cc | 18 +++----- .../format_transfer_fracz_hwcn.cc | 6 +-- .../format_transfer_nchw_fz_c04.cc | 6 +-- .../format_transfer_transpose.cc | 6 +-- ge/common/formats/formats.cc | 45 +++++++++++++++---- ge/common/formats/formats.h | 4 ++ .../formats/utils/formats_trans_utils.cc | 19 +++++--- inc/framework/common/debug/log.h | 9 ++++ 14 files changed, 111 insertions(+), 83 deletions(-) diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index 725eed98..9c7f4ac0 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -123,21 +123,25 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result std::pair trans_info(args.src_data_type, args.dst_data_type); auto iter = trans_mode_map.find(trans_info); if (iter == trans_mode_map.end()) { - GELOGE(PARAM_INVALID, "Trans data type from %s to %s is not supported.", - TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), - TypeUtils::DataTypeToSerialString(args.dst_data_type).c_str()); + std::string error = "Failed to trans data from datatype [" + + TypeUtils::FormatToSerialString(args.src_data_type) + "] to " + "[" + + TypeUtils::FormatToSerialString(args.dst_data_type) + "], it is not supported."; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } auto trans_mode = iter->second; int size = GetSizeByDataType(args.dst_data_type); if (size <= 0) { - GELOGE(PARAM_INVALID, "Failed to calc size from data type %s", - TypeUtils::DataTypeToSerialString(args.dst_data_type).c_str()); + std::string error = "Failed to calc size from data type[" + + TypeUtils::DataTypeToSerialString(args.dst_data_type) + "], it is not supported."; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return PARAM_INVALID; } if (args.src_data_size > static_cast(SIZE_MAX / size)) { - GELOGE(PARAM_INVALID, "args.src_data_size %zu or data type size %d too big.", args.src_data_size, size); + std::string error = "args.src_data_size[" + std::to_string(args.src_data_size) + + "] or data type size[" + std::to_string(size) + "is too big"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return PARAM_INVALID; } size_t total_size = static_cast(args.src_data_size * size); @@ -154,9 +158,10 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result } if (CastKernel(args, dst.get(), args.src_data_size, trans_mode) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to cast data from %s to %s, data size %zu", - TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), - TypeUtils::DataTypeToSerialString(args.dst_data_type).c_str(), args.src_data_size); + std::string error = "Failed to cast data from datatype [" + + TypeUtils::FormatToSerialString(args.src_data_type) + "] to " + "[" + + TypeUtils::FormatToSerialString(args.dst_data_type) + "], data size is " + std::to_string(args.src_data_size); + GE_ERRORLOG_AND_ERRORMSG(INTERNAL_ERROR, error.c_str()); return INTERNAL_ERROR; } result.data = dst; diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index 12d13e44..aa5ec7ec 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -35,14 +35,18 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { auto src_shape = args.src_shape; auto dst_shape = args.dst_shape; if (args.src_format != FORMAT_C1HWNCoC0 || args.dst_format != FORMAT_HWCN) { + std::string error = "Dose not support trans format from " + + FmtEgStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtEgStr(TypeUtils::FormatToSerialString(args.dst_format)); GELOGE(UNSUPPORTED, "Does not support trans format from %s to %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str()); return UNSUPPORTED; } if (!CheckDataTypeSupported(args.src_data_type)) { - GELOGE(UNSUPPORTED, "Failed to trans shape from NC1HWNCoC0 to HWCN, invalid data type %s", - TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); + std::string error = "Failed to trans shape from NC1HWNCoC0 to HWCN, invalid data type[" + + TypeUtils::DataTypeToSerialString(args.src_data_type).c_str() + "]"; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } if (!CheckShapeValid(src_shape, kC1hwncoc0DimsNum)) { @@ -58,8 +62,9 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { src_shape.at(kC1hwncoc0H) != dst_shape.at(kHwcnH) || src_shape.at(kC1hwncoc0W) != dst_shape.at(kHwcnW) || src_shape.at(kC1hwncoc0N) != dst_shape.at(kHwcnN) || src_shape.at(kC1hwncoc0Co) != cube_size || src_shape.at(kC1hwncoc0C0) != cube_size) { - GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", - ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); + std::string error = "Failed to check relationship between src and dst shape, src shape[" + + ShapeToString(src_shape) + "], dst shape[" + ShapeToString(dst_shape) + "]"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return PARAM_INVALID; } @@ -69,9 +74,10 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); + std::string error = "Failed to trans format from[" + TypeUtils::FormatToSerialString(args.src_format).c_str() + + "] to [" + TypeUtils::FormatToSerialString(args.dst_format) + "], can not alloc the memory for dst buf[" + + std::to_string(total_size) + "], shape[" + ShapeToString(args.dst_shape) + "]"; + GE_ERRORLOG_AND_ERRORMSG(OUT_OF_MEMORY, error.c_str()); return OUT_OF_MEMORY; } diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc index 4060a3b2..e44bd9a1 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc @@ -148,11 +148,7 @@ Status FormatTransferDhwcnFractalZ3D::TransFormat(const TransArgs &args, TransRe if (ret != SUCCESS) { return ret; } - if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, the dst shape %s is invalid, expect %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.dst_shape).c_str(), - ShapeToString(expect_shape).c_str()); + if (!IsTransShapeCorrect(args, expect_shape)) { return PARAM_INVALID; } diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc index 457469c7..cd1e0607 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc @@ -149,11 +149,7 @@ Status FormatTransferDhwncFractalZ3DTranspose::TransFormat(const TransArgs &args if (ret != SUCCESS) { return ret; } - if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, the dst shape %s is invalid, expect %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.dst_shape).c_str(), - ShapeToString(expect_shape).c_str()); + if (!IsTransShapeDstCorrect(args, expect_shape)) { return PARAM_INVALID; } diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc index cb4de6b5..a0e3fa83 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -39,6 +39,9 @@ bool CheckShape(Format format, const ShapeVector &shape) { case FORMAT_NHWC: return CheckShapeValid(shape, kDimSize4D); default: + std::string error = "Trans format between[" + TypeUtils::FormatToSerialString(format) + + "] and FORMAT_FRACTAL_NZ is not supported."; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); GELOGE(PARAM_INVALID, "Trans format between %s and FORMAT_FRACTAL_NZ is not supported.", TypeUtils::FormatToSerialString(format).c_str()); return false; @@ -103,11 +106,7 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) { ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); return INTERNAL_ERROR; } - if (args.src_shape != expect_src_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, invalid relationship between src shape %s and dst %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), - ShapeToString(args.dst_shape).c_str()); + if (!IsTransShapeSrcCorrect(args, expect_shape)) { return PARAM_INVALID; } return SUCCESS; @@ -275,11 +274,7 @@ Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult & if (ret != SUCCESS) { return ret; } - if (args.dst_shape != expect_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, the dst shape %s is invalid, expect %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.dst_shape).c_str(), - ShapeToString(expect_shape).c_str()); + if (!IsTransShapeDstCorrect(args, expect_shape)) { return PARAM_INVALID; } return TransFormatFromNdToFracNz(args, result, hw_shape); diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index 0e941486..d19702ff 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -159,8 +159,9 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { ret = memset_s(dst.get() + offset, static_cast(protected_size), 0, static_cast(size)); } else { if (protected_size < size) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory, protected_size is %ld and size is %ld", - protected_size, size); + std::string error = "Failed to operate the dst memory, protected_size is[" + + std::to_string(protected_size) + "] and size is [" + std::to_string(size) + "]"; + GE_ERRORLOG_AND_ERRORMSG(INTERNAL_ERROR, error.c_str()); return INTERNAL_ERROR; } char *dst_data = reinterpret_cast(dst.get() + offset); @@ -345,11 +346,7 @@ Status FormatTransferFractalZ::TransFormat(const TransArgs &args, TransResult &r if (ret != SUCCESS) { return ret; } - if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, the dst shape %s is invalid, expect %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.dst_shape).c_str(), - ShapeToString(expect_shape).c_str()); + if (!IsTransShapeDstCorrect(args, expect_shape)) { return PARAM_INVALID; } diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc index 009bce2b..c05eef1d 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -39,8 +39,9 @@ bool CheckShape(Format format, const ShapeVector &shape) { case FORMAT_NHWC: return CheckShapeValid(shape, kDimSize4D); default: - GELOGE(PARAM_INVALID, "Not support trans format between %s and FORMAT_FRACTAL_ZZ.", - TypeUtils::FormatToSerialString(format).c_str()); + std::string error = "Trans format between[" + TypeUtils::FormatToSerialString(format) + + "] and FORMAT_FRACTAL_ZZ is not supported."; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } } @@ -103,12 +104,7 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) { ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); return INTERNAL_ERROR; } - if (args.src_shape != expect_src_shape) { - GELOGE(PARAM_INVALID, - "Failed to trans format from %s to %s, invalid relationship between src shape %s and dst shape %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), - ShapeToString(args.dst_shape).c_str()); + if (!IsTransShapeSrcCorrect(args, expect_shape)) { return PARAM_INVALID; } return SUCCESS; @@ -289,11 +285,7 @@ Status FormatTransferFractalZz::TransFormat(const TransArgs &args, TransResult & if (ret != SUCCESS) { return ret; } - if (args.dst_shape != expect_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, the dst shape %s is invalid, expect %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.dst_shape).c_str(), - ShapeToString(expect_shape).c_str()); + if (!IsTransShapeDstCorrect(args, expect_shape)) { return PARAM_INVALID; } return TransFormatFromNdToFracZz(args, result, hw_shape); diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 2076f6f9..299cfe2e 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -33,9 +33,9 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { auto src_shape = args.src_shape; auto dst_shape = args.dst_shape; if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_HWCN) { - GELOGE(UNSUPPORTED, "Does not support trans format from %s to %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + std::string error = "Dose not support trans format from [" + + TypeUtils::FormatToSerialString(args.src_format) + "] to " + "[" + + TypeUtils::FormatToSerialString(args.dst_format) + "]"; return UNSUPPORTED; } if (!CheckDataTypeSupported(args.src_data_type)) { diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index 6f065fc5..d521b1e3 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -280,11 +280,7 @@ Status FormatTransferNchwToFZC04::TransFormat(const TransArgs &args, TransResult return ret; } - if (!args_tmp.dst_shape.empty() && args_tmp.dst_shape != expect_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, the dst shape %s is invalid, expect %s", - TypeUtils::FormatToSerialString(args_tmp.src_format).c_str(), - TypeUtils::FormatToSerialString(args_tmp.dst_format).c_str(), ShapeToString(args_tmp.dst_shape).c_str(), - ShapeToString(expect_shape).c_str()); + if (!IsTransShapeCorrect(args_tmp, expect_shape)) { return PARAM_INVALID; } diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc index 19f54040..86781e13 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -223,11 +223,7 @@ Status FormatTransferTranspose::TransFormat(const TransArgs &args, TransResult & if (ret != SUCCESS) { return ret; } - if (args.dst_shape != expected_shape) { - GELOGE(PARAM_INVALID, "Failed to trans format from %s to %s, invalid dst shape %s, expect %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.dst_shape).c_str(), - ShapeToString(expected_shape).c_str()); + if (!IsTransShapeDstCorrect(args, expect_shape)) { return PARAM_INVALID; } diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc index 697e16ad..81f7a84b 100755 --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -34,9 +34,10 @@ namespace formats { GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArgs &args, TransResult &result) { auto transfer = BuildFormatTransfer(args); if (transfer == nullptr) { - GELOGE(UNSUPPORTED, "Failed to trans data from format %s to %s, unsupport now", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + std::string error = "Failed to trans data from format [" + + TypeUtils::FormatToSerialString(args.src_format) + "] to " + "[" + + TypeUtils::FormatToSerialString(args.dst_format) + "]"; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -59,9 +60,10 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_form args.dst_format = dst_format; auto transfer = BuildFormatTransfer(args); if (transfer == nullptr) { - GELOGE(UNSUPPORTED, "Failed to trans data from format %s to %s, unsupport now", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + std::string error = "Failed to trans data from format [" + + TypeUtils::FormatToSerialString(args.src_format) + "] to " + "[" + + TypeUtils::FormatToSerialString(args.dst_format) + "]"; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -71,9 +73,10 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_form GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransDataType(const CastArgs &args, TransResult &result) { auto transfer = BuildDataTypeTransfer(args); if (transfer == nullptr) { - GELOGE(UNSUPPORTED, "Failed to trans data from datatype %s to %s, unsupport now", - TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), - TypeUtils::DataTypeToSerialString(args.dst_data_type).c_str()); + std::string error = "Failed to trans data from datatype [" + + TypeUtils::FormatToSerialString(args.src_data_type) + "] to " + "[" + + TypeUtils::FormatToSerialString(args.dst_data_type) + "]"; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -92,5 +95,29 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransFormatSupport(const T GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransDataTypeSupport(const CastArgs &args) { return DataTypeTransferExists(args); } + +GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape) { + if (!args.src_shape.empty() && args.src_shape != expect_shape) { + std::string error = "Failed to trans format from[" + TypeUtils::FormatToSerialString(args.src_format) + + "] to [" + TypeUtils::FormatToSerialString(args.dst_format) + "], the src shape[" + + TypeUtils::FormatToSerialString(args.dst_format).c_str() + "] is invalid, expect[" + + ShapeToString(expect_shape) + "]"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); + return false; + } + return true; +} + +GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape) { + if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { + std::stringstream error; + error << "Failed to trans format from[" + TypeUtils::FormatToSerialString(args.src_format) << + "] to [" << TypeUtils::FormatToSerialString(args.dst_format) << "], invalid relationship between src shape[" << + ShapeToString(args.src_shape) << "] and dst [" << ShapeToString(args.dst_shape) + "]"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.str()); + return false; + } + return true; +} } // namespace formats } // namespace ge diff --git a/ge/common/formats/formats.h b/ge/common/formats/formats.h index 52ae84ad..594bb2f8 100644 --- a/ge/common/formats/formats.h +++ b/ge/common/formats/formats.h @@ -44,6 +44,10 @@ Status TransDataType(const CastArgs &args, TransResult &result); bool IsTransFormatSupport(const TransArgs &args); bool IsTransDataTypeSupport(const CastArgs &args); + +bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape); + +bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape); } // namespace formats } // namespace ge #endif // GE_COMMON_FORMATS_FORMATS_H_ diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index e184a866..cdf1f363 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -29,8 +29,9 @@ int64_t GetCubeSizeByDataType(DataType data_type) { // Current cube does not support 4 bytes and longer data auto size = GetSizeByDataType(data_type); if (size <= 0) { - GELOGE(PARAM_INVALID, "Failed to get cube size, the data type %s is invalid", - TypeUtils::DataTypeToSerialString(data_type).c_str()); + std::string error = "Failed to get cube size, the data type [" + + TypeUtils::DataTypeToSerialString(data_type) + "] is invalid"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return -1; } else if (size == 1) { return kCubeSize * 2; // 32 bytes cube size @@ -57,7 +58,10 @@ int64_t GetItemNumByShape(const std::vector &shape) { bool CheckShapeValid(const std::vector &shape, const int64_t expect_dims) { if (expect_dims <= 0 || shape.size() != static_cast(expect_dims)) { - GELOGE(PARAM_INVALID, "Invalid shape, dims num %zu, expect %ld", shape.size(), expect_dims); + std::string error = " Invalid shape, dims num [" + std::to_string(shape.size()) + + "], expect [" + std::to_string(expect_dims) + "]"; + TypeUtils::DataTypeToSerialString(data_type) + "] is invalid"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } return IsShapeValid(shape); @@ -70,11 +74,14 @@ bool IsShapeValid(const std::vector &shape) { int64_t num = 1; for (auto dim : shape) { if (dim < 0) { - GELOGE(PARAM_INVALID, "Invalid negative dim in the shape %s", ShapeToString(shape).c_str()); + std::string error = "Invalid negative dims in the shape [" + ShapeToString(shape).c_str() + "]"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } if (dim != 0 && kShapeItemNumMAX / dim < num) { - GELOGE(PARAM_INVALID, "Shape overflow, the total count should be less than %ld!", kShapeItemNumMAX); + std::string error = "Shape overflow, the total count should be less than [" + + std::to_string(kShapeItemNumMAX) + "]"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } num *= dim; @@ -94,5 +101,7 @@ bool IsShapeEqual(const GeShape &src, const GeShape &dst) { } return true; } + +bool } // namespace formats } // namespace ge diff --git a/inc/framework/common/debug/log.h b/inc/framework/common/debug/log.h index e259f43b..aaf76621 100644 --- a/inc/framework/common/debug/log.h +++ b/inc/framework/common/debug/log.h @@ -18,6 +18,7 @@ #define INC_FRAMEWORK_COMMON_DEBUG_LOG_H_ #include +#include #include "runtime/rt.h" #include "common/string_util.h" @@ -269,4 +270,12 @@ } \ } while (0) +template +std::string FmtEgStr(const T &t) { + std::string fmt; + std::stringstream st; + st << "[" << t << "]"; + return fmt; +} + #endif // INC_FRAMEWORK_COMMON_DEBUG_LOG_H_ From 42c6940bb1e0422f06bc0c3a1986c86da8b641f0 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 11:25:40 +0800 Subject: [PATCH 02/12] error message add format --- .../format_transfers/datatype_transfer.cc | 22 ++++++++++-------- .../format_transfer_c1hwncoc0_hwcn.cc | 23 ++++++++----------- .../format_transfer_fractal_z.cc | 4 ++-- .../format_transfer_fractal_zz.cc | 4 ++-- .../format_transfer_fracz_hwcn.cc | 13 +++++++---- .../format_transfer_fracz_nchw.cc | 7 +++--- .../format_transfer_fracz_nhwc.cc | 7 +++--- .../format_transfer_hwcn_c1hwncoc0.cc | 7 +++--- .../format_transfer_nc1hwc0_nchw.cc | 7 +++--- .../format_transfer_nc1hwc0_nhwc.cc | 7 +++--- .../format_transfer_nchw_nc1hwc0.cc | 7 +++--- .../format_transfer_nhwc_nc1hwc0.cc | 7 +++--- .../format_transfer_transpose.cc | 2 +- .../formats/utils/formats_trans_utils.cc | 11 ++++----- inc/framework/common/debug/log.h | 2 +- 15 files changed, 69 insertions(+), 61 deletions(-) diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index 9c7f4ac0..54600000 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -24,6 +24,7 @@ #include "common/fp16_t.h" #include "common/ge/ge_util.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" #include "securec.h" @@ -123,9 +124,9 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result std::pair trans_info(args.src_data_type, args.dst_data_type); auto iter = trans_mode_map.find(trans_info); if (iter == trans_mode_map.end()) { - std::string error = "Failed to trans data from datatype [" + - TypeUtils::FormatToSerialString(args.src_data_type) + "] to " + "[" + - TypeUtils::FormatToSerialString(args.dst_data_type) + "], it is not supported."; + std::string error = "Failed to trans data from datatype " + + FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)) + " to " + + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)) + " , it is not supported."; GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -133,14 +134,14 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result int size = GetSizeByDataType(args.dst_data_type); if (size <= 0) { - std::string error = "Failed to calc size from data type[" + - TypeUtils::DataTypeToSerialString(args.dst_data_type) + "], it is not supported."; + std::string error = "Failed to calc size from data type" + + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)) + ", it is not supported."; GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return PARAM_INVALID; } if (args.src_data_size > static_cast(SIZE_MAX / size)) { - std::string error = "args.src_data_size[" + std::to_string(args.src_data_size) + - "] or data type size[" + std::to_string(size) + "is too big"; + std::string error = "args.src_data_size" + FmtToStr(args.src_data_size) + + " or data type size" + FmtToStr(std::to_string(size)) + " is too big"; GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return PARAM_INVALID; } @@ -158,9 +159,10 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result } if (CastKernel(args, dst.get(), args.src_data_size, trans_mode) != SUCCESS) { - std::string error = "Failed to cast data from datatype [" + - TypeUtils::FormatToSerialString(args.src_data_type) + "] to " + "[" + - TypeUtils::FormatToSerialString(args.dst_data_type) + "], data size is " + std::to_string(args.src_data_size); + std::string error = "Failed to cast data from datatype " + + FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)) + " to " + + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)) + ", data size is " + + FmtToStr(std::to_string(args.src_data_size)); GE_ERRORLOG_AND_ERRORMSG(INTERNAL_ERROR, error.c_str()); return INTERNAL_ERROR; } diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index aa5ec7ec..16b559c4 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -36,16 +36,14 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { auto dst_shape = args.dst_shape; if (args.src_format != FORMAT_C1HWNCoC0 || args.dst_format != FORMAT_HWCN) { std::string error = "Dose not support trans format from " + - FmtEgStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtEgStr(TypeUtils::FormatToSerialString(args.dst_format)); - GELOGE(UNSUPPORTED, "Does not support trans format from %s to %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } if (!CheckDataTypeSupported(args.src_data_type)) { - std::string error = "Failed to trans shape from NC1HWNCoC0 to HWCN, invalid data type[" + - TypeUtils::DataTypeToSerialString(args.src_data_type).c_str() + "]"; + std::string error = "Failed to trans shape from NC1HWNCoC0 to HWCN, invalid data type" + + FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -62,8 +60,8 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { src_shape.at(kC1hwncoc0H) != dst_shape.at(kHwcnH) || src_shape.at(kC1hwncoc0W) != dst_shape.at(kHwcnW) || src_shape.at(kC1hwncoc0N) != dst_shape.at(kHwcnN) || src_shape.at(kC1hwncoc0Co) != cube_size || src_shape.at(kC1hwncoc0C0) != cube_size) { - std::string error = "Failed to check relationship between src and dst shape, src shape[" + - ShapeToString(src_shape) + "], dst shape[" + ShapeToString(dst_shape) + "]"; + std::string error = "Failed to check relationship between src and dst shape, src shape" + + FmtToStr(ShapeToString(src_shape)) + ", dst shape" + FmtToStr(ShapeToString(dst_shape)); GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return PARAM_INVALID; } @@ -74,10 +72,9 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - std::string error = "Failed to trans format from[" + TypeUtils::FormatToSerialString(args.src_format).c_str() + - "] to [" + TypeUtils::FormatToSerialString(args.dst_format) + "], can not alloc the memory for dst buf[" + - std::to_string(total_size) + "], shape[" + ShapeToString(args.dst_shape) + "]"; - GE_ERRORLOG_AND_ERRORMSG(OUT_OF_MEMORY, error.c_str()); + GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + TypeUtils::FormatToSerialString(args.src_format).c_str(), + TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); return OUT_OF_MEMORY; } diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index d19702ff..378d0dd1 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -159,8 +159,8 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { ret = memset_s(dst.get() + offset, static_cast(protected_size), 0, static_cast(size)); } else { if (protected_size < size) { - std::string error = "Failed to operate the dst memory, protected_size is[" + - std::to_string(protected_size) + "] and size is [" + std::to_string(size) + "]"; + std::string error = "Failed to operate the dst memory, protected_size is " + + FmtToStr(protected_size) + " and size is " + FmtToStr(size); GE_ERRORLOG_AND_ERRORMSG(INTERNAL_ERROR, error.c_str()); return INTERNAL_ERROR; } diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc index c05eef1d..76e9bd0f 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -39,8 +39,8 @@ bool CheckShape(Format format, const ShapeVector &shape) { case FORMAT_NHWC: return CheckShapeValid(shape, kDimSize4D); default: - std::string error = "Trans format between[" + TypeUtils::FormatToSerialString(format) + - "] and FORMAT_FRACTAL_ZZ is not supported."; + std::string error = "Trans format between " + FmtToStr(TypeUtils::FormatToSerialString(format)) + + " and FORMAT_FRACTAL_ZZ is not supported."; GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 299cfe2e..347ee2b2 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -33,9 +33,10 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { auto src_shape = args.src_shape; auto dst_shape = args.dst_shape; if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_HWCN) { - std::string error = "Dose not support trans format from [" + - TypeUtils::FormatToSerialString(args.src_format) + "] to " + "[" + - TypeUtils::FormatToSerialString(args.dst_format) + "]"; + std::string error = "Dose not support trans format from " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } if (!CheckDataTypeSupported(args.src_data_type)) { @@ -59,8 +60,10 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { int64_t n0 = Ceil(dst_shape.at(kHwcnN), static_cast(kNiSize)); if (src_shape.at(kFracZHWC1) != dst_shape.at(kHwcnH) * dst_shape.at(kHwcnW) * c1 || src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { - GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", - ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); + std::string error = "Failed to check relationship between src shape" + + FmtToStr(ShapeToString(src_shape)) + " and dst shape" + + FmtToStr(ShapeToString(dst_shape)) + ; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return PARAM_INVALID; } diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc index 042559ca..6639fe11 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -33,9 +33,10 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) { auto src_shape = args.src_shape; auto dst_shape = args.dst_shape; if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_NCHW) { - GELOGE(UNSUPPORTED, "Does not support trans format from %s to %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + std::string error = "Dose not support trans format from " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } if (!CheckDataTypeSupported(args.src_data_type)) { diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc index 98bd1807..b55b7c5e 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -33,9 +33,10 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { auto src_shape = args.src_shape; auto dst_shape = args.dst_shape; if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_NHWC) { - GELOGE(UNSUPPORTED, "Does not support trans format from %s to %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + std::string error = "Dose not support trans format from " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } if (!CheckDataTypeSupported(args.src_data_type)) { diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc index d2f8cf30..511a4731 100755 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -50,9 +50,10 @@ Status TransShapeHwcnToC1hwncoc0(const DataType &data_type, const std::vector &src_shape, DataType d Status CheckArgsForNchwToNc1hwc0(const TransArgs &args) { if (args.src_format != FORMAT_NCHW || args.dst_format != FORMAT_NC1HWC0) { - GELOGE(UNSUPPORTED, "Does not support trans format from %s to %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + std::string error = "Dose not support trans format from " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } std::vector expect_5d_shape; diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc index 3ae7a924..27a7154b 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -51,9 +51,10 @@ Status TransShapeNhwcToNc1hwc0(const std::vector &src_shape, DataType d Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { if (args.src_format != FORMAT_NHWC || args.dst_format != FORMAT_NC1HWC0) { - GELOGE(UNSUPPORTED, "Does not support trans format from %s to %s", - TypeUtils::FormatToSerialString(args.src_format).c_str(), - TypeUtils::FormatToSerialString(args.dst_format).c_str()); + std::string error = "Dose not support trans format from " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } if (!CheckDataTypeSupported(args.src_data_type)) { diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc index 86781e13..b8d800cf 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -223,7 +223,7 @@ Status FormatTransferTranspose::TransFormat(const TransArgs &args, TransResult & if (ret != SUCCESS) { return ret; } - if (!IsTransShapeDstCorrect(args, expect_shape)) { + if (!IsTransShapeDstCorrect(args, expected_shape)) { return PARAM_INVALID; } diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index cdf1f363..d18e4e1d 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -20,6 +20,7 @@ #include "common/formats/utils/formats_definitions.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "framework/common/ge_inner_error_codes.h" #include "graph/utils/type_utils.h" @@ -58,9 +59,8 @@ int64_t GetItemNumByShape(const std::vector &shape) { bool CheckShapeValid(const std::vector &shape, const int64_t expect_dims) { if (expect_dims <= 0 || shape.size() != static_cast(expect_dims)) { - std::string error = " Invalid shape, dims num [" + std::to_string(shape.size()) + - "], expect [" + std::to_string(expect_dims) + "]"; - TypeUtils::DataTypeToSerialString(data_type) + "] is invalid"; + std::string error = " Invalid shape, dims num " + FmtToStr(shape.size()) + + ", expect " + FmtToStr(expect_dims); GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } @@ -74,13 +74,12 @@ bool IsShapeValid(const std::vector &shape) { int64_t num = 1; for (auto dim : shape) { if (dim < 0) { - std::string error = "Invalid negative dims in the shape [" + ShapeToString(shape).c_str() + "]"; + std::string error = "Invalid negative dims in the shape " + FmtToStr(ShapeToString(shape)); GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } if (dim != 0 && kShapeItemNumMAX / dim < num) { - std::string error = "Shape overflow, the total count should be less than [" + - std::to_string(kShapeItemNumMAX) + "]"; + std::string error = "Shape overflow, the total count should be less than " + FmtToStr(kShapeItemNumMAX); GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } diff --git a/inc/framework/common/debug/log.h b/inc/framework/common/debug/log.h index aaf76621..575779bf 100644 --- a/inc/framework/common/debug/log.h +++ b/inc/framework/common/debug/log.h @@ -271,7 +271,7 @@ } while (0) template -std::string FmtEgStr(const T &t) { +std::string FmtToStr(const T &t) { std::string fmt; std::stringstream st; st << "[" << t << "]"; From d05ff88ae5e1b7a8f2dfb2616d8368fdd5a76eb8 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 11:51:13 +0800 Subject: [PATCH 03/12] error message add format --- ge/common/formats/formats.cc | 39 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc index 81f7a84b..32f20536 100755 --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -26,6 +26,7 @@ #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "framework/common/ge_inner_error_codes.h" #include "graph/utils/type_utils.h" @@ -34,9 +35,9 @@ namespace formats { GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArgs &args, TransResult &result) { auto transfer = BuildFormatTransfer(args); if (transfer == nullptr) { - std::string error = "Failed to trans data from format [" + - TypeUtils::FormatToSerialString(args.src_format) + "] to " + "[" + - TypeUtils::FormatToSerialString(args.dst_format) + "]"; + std::string error = "Failed to trans data from format " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -60,9 +61,9 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_form args.dst_format = dst_format; auto transfer = BuildFormatTransfer(args); if (transfer == nullptr) { - std::string error = "Failed to trans data from format [" + - TypeUtils::FormatToSerialString(args.src_format) + "] to " + "[" + - TypeUtils::FormatToSerialString(args.dst_format) + "]"; + std::string error = "Failed to trans data from format " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -73,9 +74,9 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_form GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransDataType(const CastArgs &args, TransResult &result) { auto transfer = BuildDataTypeTransfer(args); if (transfer == nullptr) { - std::string error = "Failed to trans data from datatype [" + - TypeUtils::FormatToSerialString(args.src_data_type) + "] to " + "[" + - TypeUtils::FormatToSerialString(args.dst_data_type) + "]"; + std::string error = "Failed to trans data from datatype " + + FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)) + " to " + + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -98,10 +99,11 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransDataTypeSupport(const GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape) { if (!args.src_shape.empty() && args.src_shape != expect_shape) { - std::string error = "Failed to trans format from[" + TypeUtils::FormatToSerialString(args.src_format) + - "] to [" + TypeUtils::FormatToSerialString(args.dst_format) + "], the src shape[" + - TypeUtils::FormatToSerialString(args.dst_format).c_str() + "] is invalid, expect[" + - ShapeToString(expect_shape) + "]"; + std::string error = "Failed to trans format from" + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ", invalid relationship between src shape " + + FmtToStr(ShapeToString(args.src_shape)) + " and dst " + + FmtToStr(ShapeToString(args.dst_shape)); GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } @@ -110,11 +112,12 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeSrcCorrect(const GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape) { if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { - std::stringstream error; - error << "Failed to trans format from[" + TypeUtils::FormatToSerialString(args.src_format) << - "] to [" << TypeUtils::FormatToSerialString(args.dst_format) << "], invalid relationship between src shape[" << - ShapeToString(args.src_shape) << "] and dst [" << ShapeToString(args.dst_shape) + "]"; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.str()); + std::string error = "Failed to trans format from " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ", the dst shape" + + FmtToStr(ShapeToString(args.dst_shape)) + " is invalid, expect" + + FmtToStr(ShapeToString(expect_shape)); + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } return true; From 1debfced284b7634449c5e0344d5d9e7214c39d6 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 15:29:22 +0800 Subject: [PATCH 04/12] error message add format --- ge/common/formats/formats.cc | 26 ---------------- ge/common/formats/formats.h | 4 --- .../formats/utils/formats_trans_utils.cc | 31 +++++++++++++++++-- ge/common/formats/utils/formats_trans_utils.h | 4 +++ 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc index 32f20536..0b21a884 100755 --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -96,31 +96,5 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransFormatSupport(const T GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransDataTypeSupport(const CastArgs &args) { return DataTypeTransferExists(args); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape) { - if (!args.src_shape.empty() && args.src_shape != expect_shape) { - std::string error = "Failed to trans format from" + - FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ", invalid relationship between src shape " + - FmtToStr(ShapeToString(args.src_shape)) + " and dst " + - FmtToStr(ShapeToString(args.dst_shape)); - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); - return false; - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape) { - if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { - std::string error = "Failed to trans format from " + - FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ", the dst shape" + - FmtToStr(ShapeToString(args.dst_shape)) + " is invalid, expect" + - FmtToStr(ShapeToString(expect_shape)); - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); - return false; - } - return true; -} } // namespace formats } // namespace ge diff --git a/ge/common/formats/formats.h b/ge/common/formats/formats.h index 594bb2f8..52ae84ad 100644 --- a/ge/common/formats/formats.h +++ b/ge/common/formats/formats.h @@ -44,10 +44,6 @@ Status TransDataType(const CastArgs &args, TransResult &result); bool IsTransFormatSupport(const TransArgs &args); bool IsTransDataTypeSupport(const CastArgs &args); - -bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape); - -bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape); } // namespace formats } // namespace ge #endif // GE_COMMON_FORMATS_FORMATS_H_ diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index d18e4e1d..b48874f0 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -19,6 +19,7 @@ #include #include "common/formats/utils/formats_definitions.h" +#include "common/util/error_manager/error_manager.h" #include "framework/common/debug/ge_log.h" #include "framework/common/debug/log.h" #include "framework/common/ge_inner_error_codes.h" @@ -30,8 +31,8 @@ int64_t GetCubeSizeByDataType(DataType data_type) { // Current cube does not support 4 bytes and longer data auto size = GetSizeByDataType(data_type); if (size <= 0) { - std::string error = "Failed to get cube size, the data type [" + - TypeUtils::DataTypeToSerialString(data_type) + "] is invalid"; + std::string error = "Failed to get cube size, the data type " + + FmtToStr(TypeUtils::DataTypeToSerialString(data_type)) + " is invalid"; GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return -1; } else if (size == 1) { @@ -101,6 +102,30 @@ bool IsShapeEqual(const GeShape &src, const GeShape &dst) { return true; } -bool +GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape) { + if (!args.src_shape.empty() && args.src_shape != expect_shape) { + std::string error = "Failed to trans format from" + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ", invalid relationship between src shape " + + FmtToStr(ShapeToString(args.src_shape)) + " and dst " + + FmtToStr(ShapeToString(args.dst_shape)); + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); + return false; + } + return true; +} + +GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape) { + if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { + std::string error = "Failed to trans format from " + + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ", the dst shape" + + FmtToStr(ShapeToString(args.dst_shape)) + " is invalid, expect" + + FmtToStr(ShapeToString(expect_shape)); + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); + return false; + } + return true; +} } // namespace formats } // namespace ge diff --git a/ge/common/formats/utils/formats_trans_utils.h b/ge/common/formats/utils/formats_trans_utils.h index a480b814..a6c27d36 100755 --- a/ge/common/formats/utils/formats_trans_utils.h +++ b/ge/common/formats/utils/formats_trans_utils.h @@ -61,6 +61,10 @@ bool IsShapeValid(const std::vector &shape); bool IsShapeEqual(const GeShape &src, const GeShape &dst); +bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape); + +bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape); + template T Ceil(T n1, T n2) { if (n1 == 0) { From 2be4579f0abe961f8a06ee3c8a2d14826ffa9c72 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 15:57:31 +0800 Subject: [PATCH 05/12] error message add format --- .../format_transfers/format_transfer_c1hwncoc0_hwcn.cc | 1 + ge/common/formats/utils/formats_trans_utils.cc | 7 +++---- ge/common/formats/utils/formats_trans_utils.h | 1 + inc/framework/common/debug/log.h | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index 16b559c4..85f4038e 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index b48874f0..8a4b0729 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -19,7 +19,6 @@ #include #include "common/formats/utils/formats_definitions.h" -#include "common/util/error_manager/error_manager.h" #include "framework/common/debug/ge_log.h" #include "framework/common/debug/log.h" #include "framework/common/ge_inner_error_codes.h" @@ -102,8 +101,8 @@ bool IsShapeEqual(const GeShape &src, const GeShape &dst) { return true; } -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape) { - if (!args.src_shape.empty() && args.src_shape != expect_shape) { +bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector &expect_shape) { + if (args.src_shape != expect_shape) { std::string error = "Failed to trans format from" + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ", invalid relationship between src shape " + @@ -115,7 +114,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeSrcCorrect(const return true; } -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape) { +bool IsTransShapeDstCorrect(const TransArgs &args, std::vector &expect_shape) { if (!args.dst_shape.empty() && args.dst_shape != expect_shape) { std::string error = "Failed to trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + diff --git a/ge/common/formats/utils/formats_trans_utils.h b/ge/common/formats/utils/formats_trans_utils.h index a6c27d36..848e8b3a 100755 --- a/ge/common/formats/utils/formats_trans_utils.h +++ b/ge/common/formats/utils/formats_trans_utils.h @@ -23,6 +23,7 @@ #include #include "external/graph/types.h" #include "graph/ge_tensor.h" +#include "register/register_format_transfer.h" namespace ge { namespace formats { diff --git a/inc/framework/common/debug/log.h b/inc/framework/common/debug/log.h index 575779bf..2e5a8566 100644 --- a/inc/framework/common/debug/log.h +++ b/inc/framework/common/debug/log.h @@ -23,6 +23,7 @@ #include "runtime/rt.h" #include "common/string_util.h" #include "common/util.h" +#include "common/util/error_manager/error_manager.h" #include "framework/common/debug/ge_log.h" #include "ge/ge_api_error_codes.h" From a70769c882fd2f0d7d33d1b8710fd13d08777136 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 16:04:20 +0800 Subject: [PATCH 06/12] error message add format --- .../formats/format_transfers/format_transfer_fractal_nz.cc | 7 +++---- .../formats/format_transfers/format_transfer_fractal_z.cc | 1 + .../formats/format_transfers/format_transfer_fractal_zz.cc | 1 + .../formats/format_transfers/format_transfer_fracz_hwcn.cc | 3 ++- .../formats/format_transfers/format_transfer_fracz_nchw.cc | 1 + .../formats/format_transfers/format_transfer_fracz_nhwc.cc | 1 + .../format_transfers/format_transfer_hwcn_c1hwncoc0.cc | 1 + .../format_transfers/format_transfer_nc1hwc0_nchw.cc | 1 + .../format_transfers/format_transfer_nc1hwc0_nhwc.cc | 1 + .../format_transfers/format_transfer_nchw_nc1hwc0.cc | 1 + 10 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc index a0e3fa83..c098e4c9 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { @@ -39,11 +40,9 @@ bool CheckShape(Format format, const ShapeVector &shape) { case FORMAT_NHWC: return CheckShapeValid(shape, kDimSize4D); default: - std::string error = "Trans format between[" + TypeUtils::FormatToSerialString(format) + - "] and FORMAT_FRACTAL_NZ is not supported."; + std::string error = "Trans format between " + FmtToStr(TypeUtils::FormatToSerialString(format)) + + " and FORMAT_FRACTAL_NZ is not supported."; GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); - GELOGE(PARAM_INVALID, "Trans format between %s and FORMAT_FRACTAL_NZ is not supported.", - TypeUtils::FormatToSerialString(format).c_str()); return false; } } diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index 378d0dd1..dbceb911 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -23,6 +23,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc index 76e9bd0f..f448eb62 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 347ee2b2..93dd0291 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { @@ -65,7 +66,7 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { FmtToStr(ShapeToString(dst_shape)) + ; GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return PARAM_INVALID; - } + } return SUCCESS; } diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc index 6639fe11..7a831b03 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc index b55b7c5e..c639e048 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc index 511a4731..a7536d53 100755 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc index 4ffc5f1f..e45801be 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc index 9017bd86..0d9c5c0e 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc index 902775fd..dc2ca7a2 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { From a11768fe37437cb36f463399a6e0b165218cf6c7 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 17:41:47 +0800 Subject: [PATCH 07/12] error message add format --- .../formats/format_transfers/format_transfer_fractal_nz.cc | 2 +- .../formats/format_transfers/format_transfer_fractal_zz.cc | 2 +- .../formats/format_transfers/format_transfer_fracz_hwcn.cc | 4 ++-- .../formats/format_transfers/format_transfer_fracz_nchw.cc | 2 +- .../formats/format_transfers/format_transfer_fracz_nhwc.cc | 2 +- .../format_transfers/format_transfer_hwcn_c1hwncoc0.cc | 2 +- .../formats/format_transfers/format_transfer_nc1hwc0_nchw.cc | 2 +- .../formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc | 2 +- .../formats/format_transfers/format_transfer_nchw_nc1hwc0.cc | 2 +- .../formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc | 1 + 10 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc index c098e4c9..ed1c6941 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -105,7 +105,7 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) { ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); return INTERNAL_ERROR; } - if (!IsTransShapeSrcCorrect(args, expect_shape)) { + if (!IsTransShapeSrcCorrect(args, expect_src_shape)) { return PARAM_INVALID; } return SUCCESS; diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc index f448eb62..d890e681 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -105,7 +105,7 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) { ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); return INTERNAL_ERROR; } - if (!IsTransShapeSrcCorrect(args, expect_shape)) { + if (!IsTransShapeSrcCorrect(args, expect_src_shape)) { return PARAM_INVALID; } return SUCCESS; diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 93dd0291..43c16ee9 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -36,7 +36,7 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_HWCN) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } @@ -63,7 +63,7 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { std::string error = "Failed to check relationship between src shape" + FmtToStr(ShapeToString(src_shape)) + " and dst shape" + - FmtToStr(ShapeToString(dst_shape)) + ; + FmtToStr(ShapeToString(dst_shape)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return PARAM_INVALID; } diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc index 7a831b03..915d0d76 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -36,7 +36,7 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) { if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_NCHW) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc index c639e048..a2c86300 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -36,7 +36,7 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_NHWC) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc index a7536d53..7840b556 100755 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -53,7 +53,7 @@ Status CheckArgsForHwcnToC1hwncoc0(const TransArgs &args) { if (args.src_format != FORMAT_HWCN || args.dst_format != FORMAT_C1HWNCoC0) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc index e45801be..df8e5a29 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc @@ -36,7 +36,7 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) { if (args.src_format != FORMAT_NC1HWC0 || args.dst_format != FORMAT_NCHW) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc index 0d9c5c0e..a37ba2b5 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc @@ -36,7 +36,7 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) { if (args.src_format != FORMAT_NC1HWC0 || args.dst_format != FORMAT_NHWC) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc index dc2ca7a2..98af1efa 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc @@ -56,7 +56,7 @@ Status CheckArgsForNchwToNc1hwc0(const TransArgs &args) { if (args.src_format != FORMAT_NCHW || args.dst_format != FORMAT_NC1HWC0) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc index 27a7154b..4bcda91f 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -22,6 +22,7 @@ #include "common/formats/utils/formats_definitions.h" #include "common/formats/utils/formats_trans_utils.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/debug/log.h" #include "graph/utils/type_utils.h" namespace ge { From 01934a69f21d28ada3a3a68803f9faa6f4620935 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 17:46:02 +0800 Subject: [PATCH 08/12] error message add format --- .../formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc index 4bcda91f..8faaf4e7 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -54,7 +54,7 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { if (args.src_format != FORMAT_NHWC || args.dst_format != FORMAT_NC1HWC0) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + - FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)) + ; + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } From 0d484181afd434843c19c94a3cd07633c1089302 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 17:53:57 +0800 Subject: [PATCH 09/12] error message add format --- .../formats/format_transfers/format_transfer_dhwcn_fracz3D.cc | 2 +- .../formats/format_transfers/format_transfer_nchw_fz_c04.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc index e44bd9a1..79af84f7 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc @@ -148,7 +148,7 @@ Status FormatTransferDhwcnFractalZ3D::TransFormat(const TransArgs &args, TransRe if (ret != SUCCESS) { return ret; } - if (!IsTransShapeCorrect(args, expect_shape)) { + if (!IsTransShapeDstCorrect(args, expect_shape)) { return PARAM_INVALID; } diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index d521b1e3..275d9f10 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -280,7 +280,7 @@ Status FormatTransferNchwToFZC04::TransFormat(const TransArgs &args, TransResult return ret; } - if (!IsTransShapeCorrect(args_tmp, expect_shape)) { + if (!IsTransShapeDstCorrect(args_tmp, expect_shape)) { return PARAM_INVALID; } From 297f87423c116d4f2904ae4b3a8b4e439277a2cc Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 18:24:34 +0800 Subject: [PATCH 10/12] error message add format --- .../format_transfer_transpose.cc | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc index b8d800cf..e623d9e7 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -48,28 +48,31 @@ std::map>> perm_args{ bool IsShapeArgValid(const std::vector &src_shape, const std::vector &perm_arg) { if (src_shape.empty()) { + std::string error = "Failed to transpose, empty src shape"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); GELOGE(PARAM_INVALID, "Failed to transpose, empty src shape"); return false; } for (auto dim : src_shape) { if (dim < 0) { - GELOGE(PARAM_INVALID, "Failed to transpose, negative dim in src shape %s", ShapeToString(src_shape).c_str()); + std::string error = "Failed to transpose, negative dim in src shape " + FmtToStr(ShapeToString(src_shape)); + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } } if (perm_arg.size() != src_shape.size()) { - GELOGE(PARAM_INVALID, - "Failed to transpose, the size of src shape(%zu) and" - " perm arg(%zu) are different", - src_shape.size(), perm_arg.size()); + std::string error = "Failed to transpose, the size of src shape" + FmtToStr(src_shape.size()) + + " and perm arg" + FmtToStr(perm_arg.size()) + " are different"; + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } std::vector exists(perm_arg.size()); for (auto perm : perm_arg) { if (perm < 0 || static_cast(perm) >= perm_arg.size() || ++exists[perm] > 1) { - GELOGE(PARAM_INVALID, "Failed to transpose, duplicated perm arg %ld, perm arg %s", perm, - JoinToString(perm_arg).c_str()); + std::string error = "Failed to transpose, duplicated perm arg " + FmtToStr(perm) + + ", perm arg " + FmtToStr(JoinToString(perm_arg)); + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } } @@ -192,9 +195,10 @@ Status TransposeWithShapeCheck(const uint8_t *data, const std::vector & } auto expected_shape = TransShapeByPerm(src_shape, perm_arg); if (dst_shape != expected_shape) { - GELOGE(PARAM_INVALID, "Failed to trans axis for perm_arg %s, invalid dst shape %s, expect %s", - ShapeToString(perm_arg).c_str(), ShapeToString(dst_shape).c_str(), ShapeToString(expected_shape).c_str()); - return PARAM_INVALID; + std::string error = "Failed to trans axis for perm_arg" + + FmtToStr(ShapeToString(perm_arg)) + ", invalid dst shape" + + FmtToStr(ShapeToString(dst_shape)) + ", expect" + FmtToStr(ShapeToString(expected_shape)); + GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); } return Transpose(data, src_shape, src_data_type, perm_arg, result); @@ -203,14 +207,18 @@ Status TransposeWithShapeCheck(const uint8_t *data, const std::vector & Status GetPermByForamt(Format src_format, Format dst_format, std::vector &perm) { auto dst_iter = perm_args.find(src_format); if (dst_iter == perm_args.end()) { - GELOGE(UNSUPPORTED, "Failed to trans shape, do not support transpose from format %s to %s", - TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str()); + std::string error = "Failed to trans shape, do not support transpose from format " + + FmtToStr(TypeUtils::FormatToSerialString(src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(dst_format)); + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } auto iter = dst_iter->second.find(dst_format); if (iter == dst_iter->second.end()) { - GELOGE(UNSUPPORTED, "Failed to trans shape, do not support transpose from format %s to %s", - TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str()); + std::string error = "Failed to trans shape, do not support transpose from format " + + FmtToStr(TypeUtils::FormatToSerialString(src_format)) + " to " + + FmtToStr(TypeUtils::FormatToSerialString(dst_format)); + GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); return UNSUPPORTED; } perm = iter->second; From fdefa146ac042ab62ee5503e154bce5962e0001f Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 17 Nov 2020 18:30:23 +0800 Subject: [PATCH 11/12] error message add format --- ge/common/formats/format_transfers/datatype_transfer.cc | 2 +- ge/common/formats/utils/formats_trans_utils.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index 54600000..ba3fcdf3 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -141,7 +141,7 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result } if (args.src_data_size > static_cast(SIZE_MAX / size)) { std::string error = "args.src_data_size" + FmtToStr(args.src_data_size) + - " or data type size" + FmtToStr(std::to_string(size)) + " is too big"; + " or data type size" + FmtToStr(size) + " is too big"; GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return PARAM_INVALID; } diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index 8a4b0729..18f2d70f 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -59,7 +59,7 @@ int64_t GetItemNumByShape(const std::vector &shape) { bool CheckShapeValid(const std::vector &shape, const int64_t expect_dims) { if (expect_dims <= 0 || shape.size() != static_cast(expect_dims)) { - std::string error = " Invalid shape, dims num " + FmtToStr(shape.size()) + + std::string error = "Invalid shape, dims num " + FmtToStr(shape.size()) + ", expect " + FmtToStr(expect_dims); GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; @@ -74,7 +74,7 @@ bool IsShapeValid(const std::vector &shape) { int64_t num = 1; for (auto dim : shape) { if (dim < 0) { - std::string error = "Invalid negative dims in the shape " + FmtToStr(ShapeToString(shape)); + std::string error = "Invalid negative dims in the shape " + FmtToStr(ShapeToString(shape)); GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); return false; } From 19a5f5df2b90fb2e77ce7dfc47ebdf80611a0c7e Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Wed, 18 Nov 2020 09:20:45 +0800 Subject: [PATCH 12/12] error message add format --- inc/framework/common/debug/log.h | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/framework/common/debug/log.h b/inc/framework/common/debug/log.h index 2e5a8566..249271a6 100644 --- a/inc/framework/common/debug/log.h +++ b/inc/framework/common/debug/log.h @@ -276,6 +276,7 @@ std::string FmtToStr(const T &t) { std::string fmt; std::stringstream st; st << "[" << t << "]"; + fmt = st.str(); return fmt; }