error message add format

pull/311/head
wangwenhua1@huawei.com 4 years ago
parent d05ff88ae5
commit 1debfced28

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

@ -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<int64_t> &expect_shape);
bool IsTransShapeDstCorrect(const TransArgs &args, std::vector<int64_t> &expect_shape);
} // namespace formats
} // namespace ge
#endif // GE_COMMON_FORMATS_FORMATS_H_

@ -19,6 +19,7 @@
#include <cstdint>
#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<int64_t> &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<int64_t> &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

@ -61,6 +61,10 @@ bool IsShapeValid(const std::vector<int64_t> &shape);
bool IsShapeEqual(const GeShape &src, const GeShape &dst);
bool IsTransShapeSrcCorrect(const TransArgs &args, std::vector<int64_t> &expect_shape);
bool IsTransShapeDstCorrect(const TransArgs &args, std::vector<int64_t> &expect_shape);
template <typename T>
T Ceil(T n1, T n2) {
if (n1 == 0) {

Loading…
Cancel
Save