| @@ -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<int64_t> &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<int64_t> &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; | |||