@@ -71,8 +71,9 @@ Status CheckOptionsValid(const std::map<string, string> &options) { | |||
if (job_id_iter->second.length() > kMaxStrLen) { | |||
GELOGE(PARAM_INVALID,"[Check][JobId]Failed," | |||
"the job_id [%s] string length: %zu > max string length: %d", | |||
job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen); | |||
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id","length"}), std::vector<std::string>({job_id_iter->second, std::to_string(kMaxStrLen)})); | |||
job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen); | |||
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id","length"}), | |||
std::vector<std::string>({job_id_iter->second, std::to_string(kMaxStrLen)})); | |||
return FAILED; | |||
} | |||
} | |||
@@ -41,16 +41,26 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { | |||
return ACL_ERROR_GE_FORMAT_INVALID; | |||
} | |||
if (!CheckDataTypeSupported(args.src_data_type)) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from FORMAT_FRACTAL_Z to HWCN, invalid data type %s", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Shape]Failed, " | |||
"shape from FORMAT_FRACTAL_Z to HWCN, invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans shape from FORMAT_FRACTAL_Z to HWCN, " | |||
"invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(src_shape, kFracZDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
if (!CheckShapeValid(dst_shape, kHwcnDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
@@ -75,9 +85,16 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
"[Allocate][DSTMemory]Failed, memory for dst buf %ld, shape %s " | |||
"when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, shape %s " | |||
"when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -115,9 +132,12 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from FracZ offset %ld to HWCN[%ld, %ld, %ld, %ld] " | |||
"offset %ld, err-code %d", | |||
"[Operate][Memory]Failed to copy data from FracZ offset %ld to " | |||
"HWCN[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
src_offset, h_idx, w_idx, c_idx, n_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to copy data from FracZ offset %ld to " | |||
"HWCN[%ld, %ld, %ld, %ld], offset %ld, err-code %d", | |||
src_offset, h_idx, w_idx, c_idx, n_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -143,9 +163,12 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult & | |||
result.length = static_cast<size_t>(total_size); | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Get][Shape]Failed, " | |||
"total size %ld from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get total size %ld from " | |||
"dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
GELOGD("Begin to trans format from FracZ to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -153,9 +176,16 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult & | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
GELOGE(ret, "[Get][Data]Failed after trans, src shape %s, " | |||
"data type %s, dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to get data after trans, src shape %s, " | |||
"data type %s, dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -41,16 +41,26 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) { | |||
return ACL_ERROR_GE_FORMAT_INVALID; | |||
} | |||
if (!CheckDataTypeSupported(args.src_data_type)) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from FORMAT_FRACTAL_Z to NCHW, invalid data type %s", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Shape]Failed, " | |||
"shape from FORMAT_FRACTAL_Z to NCHW, invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans shape from FORMAT_FRACTAL_Z to NCHW, " | |||
"invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(src_shape, kFracZDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
if (!CheckShapeValid(dst_shape, kNchwDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
@@ -62,8 +72,12 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) { | |||
if (src_shape.at(kFracZHWC1) != dst_shape.at(kNchwH) * dst_shape.at(kNchwW) * c1 || | |||
src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
"Failed to check relationship between src and dst shape, src shape %s, dst shape %s", | |||
"[Check][Shape]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()); | |||
REPORT_INNER_ERROR("E19999", "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()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -74,9 +88,16 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
"[Allocate][DSTMemory]Failed, memory for dst buf %ld, shape %s " | |||
"when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, shape %s " | |||
"when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -114,9 +135,12 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from FracZ offset %ld to NCHW[%ld, %ld, %ld, %ld] offset %ld, " | |||
"err-code %d", | |||
"[Operate][Memory]Failed to copy data from FracZ offset %ld to " | |||
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999","Failed to copy data from FracZ offset %ld to " | |||
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret ); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -143,8 +167,12 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult & | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Get][Shape]Failed, total size %ld from dst shape %s, " | |||
"src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get total size %ld from dst shape %s, src shape %s", | |||
total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -153,9 +181,16 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult & | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
GELOGE(ret, "[Get][Data]Failed, after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
REPORT_CALL_ERROR("E19999", "Failed to get data after trans, src shape %s, " | |||
"data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -41,16 +41,26 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { | |||
return ACL_ERROR_GE_FORMAT_INVALID; | |||
} | |||
if (!CheckDataTypeSupported(args.src_data_type)) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from FORMAT_FRACTAL_Z to NHWC, invalid data type %s", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Shape]Failed, " | |||
"shape from FORMAT_FRACTAL_Z to NCHW, invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans shape from FORMAT_FRACTAL_Z to NCHW, " | |||
"invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(src_shape, kFracZDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
if (!CheckShapeValid(dst_shape, kNhwcDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
@@ -62,8 +72,12 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { | |||
if (src_shape.at(kFracZHWC1) != dst_shape.at(kNhwcH) * dst_shape.at(kNhwcW) * c1 || | |||
src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_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()); | |||
"[Check][Shape]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()); | |||
REPORT_INNER_ERROR("E19999", "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()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -74,9 +88,16 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
"[Allocate][DSTMemory]Failed, memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -114,8 +135,12 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from FracZ offset %ld to HHWC[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
src_offset, n_idx, h_idx, w_idx, c_idx, dst_offset, ret); | |||
"[Operate][Memory]Failed to copy data from FracZ offset %ld to " | |||
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999","Failed to copy data from FracZ offset %ld to " | |||
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -142,8 +167,12 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Get][Shape]Failed, total size %ld from dst shape %s, " | |||
"src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get total size %ld from dst shape %s, src shape %s", | |||
total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_PARAM_INVALID; | |||
} | |||
GELOGD("Begin to trans format from FracZ to NHWC, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -151,9 +180,16 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
GELOGE(ret, "[Get][Data]Failed, after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
REPORT_CALL_ERROR("E19999","Failed to get data after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -43,8 +43,10 @@ Status TransShapeHwcnToC1hwncoc0(const DataType &data_type, const std::vector<in | |||
dst_shape.push_back(cube_size); | |||
dst_shape.push_back(cube_size); | |||
if (!CheckShapeValid(dst_shape, kC1hwncoc0DimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
REPROT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
return SUCCESS; | |||
@@ -59,16 +61,26 @@ Status CheckArgsForHwcnToC1hwncoc0(const TransArgs &args) { | |||
return ACL_ERROR_GE_FORMAT_INVALID; | |||
} | |||
if (!CheckDataTypeSupported(args.src_data_type)) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from HWCN to C1HWNCoC0, invalid data type %s", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Shape]Failed, " | |||
"shape from HWCN to C1HWNCoC0, invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans shape from HWCN to C1HWNCoC0, " | |||
"invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.src_shape, kHwcnDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.dst_shape, kC1hwncoc0DimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
std::vector<int64_t> expect_dst_shape; | |||
@@ -78,10 +90,14 @@ Status CheckArgsForHwcnToC1hwncoc0(const TransArgs &args) { | |||
} | |||
if (args.dst_shape != expect_dst_shape) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
"Failed to trans format, src and dst shape are not compatible. src shape %s, dst shape %s, " | |||
"[Trans][Shape]Failed, src shape %s and dst shape %s are not compatible. " | |||
"expect dst shape %s", | |||
ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), | |||
ShapeToString(expect_dst_shape).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans format, src shape %s and dst shape %s " | |||
"are not compatible. expect dst shape %s", | |||
ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), | |||
ShapeToString(expect_dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -91,10 +107,16 @@ Status CheckArgsForHwcnToC1hwncoc0(const TransArgs &args) { | |||
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allocate][DSTMemory]Failed, " | |||
"memory for dst buf %ld, shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -136,11 +158,15 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from HWCN[%ld, %ld, %ld, %ld] offset %ld to " | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Copy][Data]Failed, " | |||
"data from HWCN[%ld, %ld, %ld, %ld] offset %ld to " | |||
"C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
h_idx, w_idx, c_idx, n_idx, src_offset, c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, | |||
dst_offset, ret); | |||
h_idx, w_idx, c_idx, n_idx, src_offset, c1_idx, h_idx, w_idx, | |||
n_idx, co_idx, c0_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to copy data from HWCN[%ld, %ld, %ld, %ld] offset %ld " | |||
"to, C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
h_idx, w_idx, c_idx, n_idx, src_offset, c1_idx, h_idx, w_idx, | |||
n_idx, co_idx, c0_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} else { | |||
@@ -148,9 +174,12 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to set to 0 to C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, " | |||
"err-code %d", | |||
"[Operate][Memory]Failed to set to 0 to " | |||
"C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to set to 0 to " | |||
"C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -180,8 +209,12 @@ Status FormatTransferHwcnC1hwncoc0::TransFormat(const TransArgs &args, TransResu | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Get][Shape]Failed, total size %ld from dst shape %s, " | |||
"src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get total size %ld from dst shape %s, src shape %s", | |||
total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
GELOGD("Begin to trans format from HWCN to C1HWNCoC0, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -190,9 +223,16 @@ Status FormatTransferHwcnC1hwncoc0::TransFormat(const TransArgs &args, TransResu | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
GELOGE(ret, "[Get][Data]Failed, after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to get data after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -202,8 +242,10 @@ Status FormatTransferHwcnC1hwncoc0::TransShape(Format src_format, const std::vec | |||
DataType data_type, Format dst_format, std::vector<int64_t> &dst_shape) { | |||
if (src_format == FORMAT_HWCN && CheckDataTypeSupported(data_type)) { | |||
if (!CheckShapeValid(src_shape, kHwcnDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
return TransShapeHwcnToC1hwncoc0(data_type, src_shape, dst_shape); | |||
@@ -41,29 +41,43 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) { | |||
return ACL_ERROR_GE_FORMAT_INVALID; | |||
} | |||
if (!CheckDataTypeSupported(args.src_data_type)) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from NC1HWC0 to NCHW, invalid data type %s", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Shape]Failed, shape from NC1HWC0 to NCHW, " | |||
"invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans shape from NC1HWC0 to NCHW, invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.src_shape, kNc1hwc0DimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.dst_shape, kNchwDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
if (c0 <= 0) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Get][Cube]Failed, the data type %s is invalid", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get cube size, the data tyep %s is invalid", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (src_shape.at(kNc1hwc0H) != dst_shape.at(kNchwH) || src_shape.at(kNc1hwc0W) != dst_shape.at(kNchwW) || | |||
src_shape.at(kNc1hwc0N) != dst_shape.at(kNchwN) || src_shape.at(kNc1hwc0C0) != c0 || | |||
src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNchwC), c0))) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
"Failed to check relationship between src and dst shape, src shape %s, dst shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed to check relationship between " | |||
"src shape %s and dst shape %s", | |||
ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to check relationship between src shape %s and dst shape %s", | |||
ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -73,10 +87,16 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) { | |||
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allocate][DSTMemory]Failed, " | |||
"memory for dst buf %ld, shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -111,10 +131,15 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld to NCHW[%ld, %ld, %ld, %ld]" | |||
" offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Copy][Data]Failed, data from " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] " | |||
"src offset %ld to NCHW[%ld, %ld, %ld, %ld], dst offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, | |||
c_idx, h_idx, w_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to copy data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] " | |||
"src offset %ld to NCHW[%ld, %ld, %ld, %ld], dst offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, | |||
c_idx, h_idx, w_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -141,8 +166,12 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Get][Shape]Failed, total size %ld from dst shape %s, " | |||
"src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get total size %ld from dst shape %s, src shape %s", | |||
total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_PARAM_INVALID; | |||
} | |||
GELOGD("Begin to trans format from NC1HWC0 to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -150,9 +179,16 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
GELOGE(ret, "[Get][Data]Failed, after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
REPORT_CALL_ERROR("E19999", "Failed to get data after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -41,29 +41,43 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) { | |||
return ACL_ERROR_GE_FORMAT_INVALID; | |||
} | |||
if (!CheckDataTypeSupported(args.src_data_type)) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from NC1HWC0 to NHWC, invalid data type %s", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Shape]Failed, shape from NC1HWC0 to NHWC, " | |||
"invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans shape from NC1HWC0 to NHWC, invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.src_shape, kNc1hwc0DimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.dst_shape, kNhwcDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
if (c0 <= 0) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Get][Cube]Failed, the data type %s is invalid", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get cube size, the data type %s is invalid", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (src_shape.at(kNc1hwc0H) != dst_shape.at(kNhwcH) || src_shape.at(kNc1hwc0W) != dst_shape.at(kNhwcW) || | |||
src_shape.at(kNc1hwc0N) != dst_shape.at(kNhwcN) || src_shape.at(kNc1hwc0C0) != c0 || | |||
src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNhwcC), c0))) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
"Failed to check relationship between src and dst shape, src shape %s, dst shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed to check relationship between " | |||
"src shape %s and dst shape %s", | |||
ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to check relationship between src shape %s and dst shape %s", | |||
ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -73,10 +87,16 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) { | |||
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allocate][DSTMemory]Failed, memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -112,9 +132,14 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld to NHWC[%ld, %ld, %ld, %ld]" | |||
" offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); | |||
"[Copy][Data]Failed, data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] " | |||
"offset %ld to NHWC[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, | |||
h_idx, w_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to copy data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] " | |||
"offset %ld to NHWC[%ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, | |||
h_idx, w_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -141,8 +166,12 @@ Status FormatTransferNc1hwc0Nhwc::TransFormat(const TransArgs &args, TransResult | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Get][Shape]Failed, total size %ld from dst shape %s, " | |||
"src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get total size %ld from dst shape %s, src shape %s", | |||
total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
GELOGD("Begin to trans format from NC1HWC0 to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -151,9 +180,16 @@ Status FormatTransferNc1hwc0Nhwc::TransFormat(const TransArgs &args, TransResult | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
GELOGE(ret, "[Get][Data]Failed, after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
REPORT_CALL_ERROR("E19999", "[Get][Data]Failed, after trans, src shape %s, " | |||
"data type %s, dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -59,8 +59,9 @@ Status TransShape(int64_t n, int64_t c, int64_t h, int64_t w, DataType data_type | |||
dst_shape.push_back(c0); | |||
if (!IsShapeValid(dst_shape)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
return SUCCESS; | |||
@@ -94,7 +95,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||
std::vector<int64_t> expect_shape = {n, h, w, c}; | |||
auto ret = ge::formats::Transpose(data, args.src_shape, args.src_data_type, perm_arg_1, trans_result_1); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to Transpose from NCHW to HWCN"); | |||
GELOGE(ret, "[Trans][Formats]Failed from NCHW to HWCN, error_code %u", ret); | |||
REPORT_CALL_ERROR("E19999", "Failede to trans formats from NCHW to HWCN, error_code %u", ret); | |||
return ret; | |||
} | |||
@@ -104,7 +106,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||
// check size it should be same with original | |||
size_t expect_size = n * c * h * w * size; // before has do check about mul | |||
if (trans_result_1.length != expect_size) { | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "size is not match after transpose!"); | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Shape]size %zu is not match expect size %u after transpose", | |||
trans_result_1.length, expect_size); | |||
return ACL_ERROR_GE_PARAM_INVALID; | |||
} | |||
@@ -118,20 +121,32 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||
// data overflow check totally | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, int64 mul overflow.A[%ld], B[%ld]", | |||
h_o, w_o); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, int64 mul overflow.A[%ld], B[%ld]", | |||
n_o, c_o); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
auto t1 = h_o * w_o; | |||
auto t2 = n_o * c_o; | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, " | |||
"int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
int64_t total_ele_cnt = n_o * c_o * h_o * w_o; | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, int64 mul overflow.A[%ld], B[%ld]", | |||
total_ele_cnt, size); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
int64_t dst_size = total_ele_cnt * size; | |||
if (dst_size == 0) { | |||
@@ -141,15 +156,20 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to alloc the memory for dst buf %ld " | |||
"when trans format from %s to %s", | |||
dst_size, TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld when trans format from %s to %s", | |||
dst_size, TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
auto retMem = memset_s(dst.get(), dst_size, 0, dst_size); | |||
if (retMem != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "memst failed!"); | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Set][Memory]Failed, dst buf %ld, error_code %d", | |||
dst_size, ret); | |||
REPORT_CALL_ERROR("E19999", "Set memory failed, dst buf %ld, error_code %d", dst_size, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
// copy data | |||
@@ -161,7 +181,10 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||
for (auto k = 0; k < n; k++) { | |||
ret = memcpy_s(p_d + k * stride, protectSize, p_s + k * block, block); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "memcpy_s failed!"); | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Set][Memcpy]Failed, block %zu, stride %zu, " | |||
"protect_size %ld, error_code %d", block, stride, protectSize, ret); | |||
REPROT_CALL_ERROR("E19999", "[Set][Memcpy]Failed, block %zu, stride %zu, " | |||
"protect_size %ld, error_code %d", block, stride, protectSize, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
protectSize = protectSize - block; | |||
@@ -171,7 +194,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||
std::vector<int64_t> perm_arg_2 = {2, 0, 1, 3}; | |||
ret = ge::formats::Transpose(dst.get(), shape_o, args.src_data_type, perm_arg_2, result); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to Transpose from NCHW to HWCN"); | |||
GELOGE(ret, "[Trans][Formats]Failed from NCHW to HWCN, error_code %u", ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to trans formats from NCHW to HWCN, error_code %u", ret); | |||
return ret; | |||
} | |||
@@ -192,7 +216,8 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr<uin | |||
auto w = src_shape.at(kNchwW); | |||
if (c > kMaxDimsNumC) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Invalie dim c num[%lu].It should be in (0,4]", c); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Invalid dim c num[%lu]. " | |||
"It should be in (0,4]", c); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -207,21 +232,33 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr<uin | |||
// data overflow check | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, int64 mul overflow.A[%ld], B[%ld]", | |||
h_o, w_o); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, int64 mul overflow.A[%ld], B[%ld]", | |||
n_o, c_o); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
auto t1 = h_o * w_o; | |||
auto t2 = n_o * c_o; | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, int64 mul overflow.A[%ld], B[%ld]", | |||
t1, t2); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
int64_t total_ele_cnt = n_o * c_o * h_o * w_o; | |||
int size = GetSizeByDataType(args.src_data_type); | |||
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); | |||
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Shape]Failed, " | |||
"int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, int64 mul overflow.A[%ld], B[%ld]", | |||
total_ele_cnt, size); | |||
return ACL_ERROR_GE_INTERNAL_ERROR); | |||
int64_t dst_size = total_ele_cnt * size; | |||
@@ -231,15 +268,21 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr<uin | |||
dst.reset(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to alloc the memory for dst buf %ld when " | |||
"trans format from %s to %s", | |||
dst_size, TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld when " | |||
"trans format from %s to %s", | |||
dst_size, TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
auto ret = memset_s(dst.get(), dst_size, 0, dst_size); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "memst failed!"); | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Set][Memory]Failed, dst buf %ld, error_code %d", | |||
dst_size, ret); | |||
REPORT_CALL_ERROR("E19999", "Set memory failed, dst buf %ld, error_code %d", dst_size, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
@@ -253,7 +296,10 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr<uin | |||
ret = memcpy_s(p_d + (i * c_o * h_o * w_o + j * h_o * w_o) * size, protectSize, | |||
p_s + (i * c * h * w + j * h * w) * size, block); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "memcpy_s failed!"); | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Set][Memcpy]Failed, block %zu, " | |||
"protect_size %ld, error_code %d", block, protectSize, ret); | |||
REPROT_CALL_ERROR("E19999", "[Set][Memcpy]Failed, block %zu, protect_size %ld," | |||
"error_code %d", block, protectSize, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
protectSize = protectSize - block; | |||
@@ -274,7 +320,8 @@ Status FormatTransferNchwToFZC04::TransFormat(const TransArgs &args, TransResult | |||
std::shared_ptr<uint8_t> dst = nullptr; | |||
auto ret = PaddingNC(args, args_tmp, dst); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Padding in NC axis failed!"); | |||
GELOGE(ret, "[Padding][NCAxis]Failed, error_code %u", ret); | |||
REPORT_CALL_ERROR("E19999", "Padding in NC axis failed, error_code %u", ret); | |||
return ret; | |||
} | |||
@@ -32,12 +32,17 @@ Status TransShapeNchwToNc1hwc0(const std::vector<int64_t> &src_shape, DataType d | |||
std::vector<int64_t> &dst_shape) { | |||
int64_t c0 = GetCubeSizeByDataType(data_type); | |||
if (c0 <= 0) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Get][Cube]Failed, the data type %s is invalid", | |||
TypsUtils::DataTypeToSerialString(data_type).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get cube size, the data type %s is invalid", | |||
TypsUtils::DataTypeToSerialString(data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(src_shape, kNchwDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
dst_shape.clear(); | |||
@@ -47,8 +52,10 @@ Status TransShapeNchwToNc1hwc0(const std::vector<int64_t> &src_shape, DataType d | |||
dst_shape.push_back(src_shape.at(kNchwW)); | |||
dst_shape.push_back(c0); | |||
if (!CheckShapeValid(dst_shape, kNc1hwc0DimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
return SUCCESS; | |||
@@ -69,10 +76,16 @@ Status CheckArgsForNchwToNc1hwc0(const TransArgs &args) { | |||
} | |||
if (expect_5d_shape != args.dst_shape) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
"Failed to trans format, the src and dst shape are not compatible. data" | |||
" type %s, src shape %s, dst shape %s, expect dst shape %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.src_shape).c_str(), | |||
"[Trans][Format]Failed, the src and dst shape are not compatible. " | |||
"data type %s, src shape %s, dst shape %s, expect dst shape %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.src_shape).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(expect_5d_shape).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans formats, the src and dst shape are not compatible. " | |||
"data type %s, src shape %s, dst shape %s, expect dst shape %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.src_shape).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(expect_5d_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -83,10 +96,16 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for" | |||
" dst buf %ld, shape %s", | |||
"[Allcoate][Memory]Failed to alloc the memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -97,7 +116,10 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
if (c0 <= 0) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "The c0 is invalid %ld", c0); | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Check][Shape]The c0 is invalid %ld, data_type %s", | |||
c0, TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Check shape failed, the c0 is invalid %ld, data_type %s", | |||
c0, TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
int64_t c1 = (c - 1) / c0 + 1; | |||
@@ -130,9 +152,12 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from NCHW[%ld] offset %ld to " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
"[Operate][Memory]Failed to copy data from NCHW[%ld] offset %ld " | |||
"to NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
srcIdx, src_offset, n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to copy data from NCHW[%ld] offset %ld " | |||
"to NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
srcIdx, src_offset, n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} else { | |||
@@ -140,9 +165,12 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
memset_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), 0, static_cast<size_t>(size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to set to 0 to " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
"[Operate][Memory]Failed to set to 0 to NC1HWC0[%ld, %ld, %ld, %ld, %ld] " | |||
"offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to set to 0 to " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -173,8 +201,12 @@ Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Get][Shape]Failed, total size %ld from dst shape %s, " | |||
"src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get total size %ld from dst shape %s, src shape %s", | |||
total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
GELOGD( | |||
@@ -184,9 +216,16 @@ Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
GELOGE(ret, "[Get][Data]Failed, after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to get data after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -34,7 +34,10 @@ Status TransShapeNhwcToNc1hwc0(const std::vector<int64_t> &src_shape, DataType d | |||
std::vector<int64_t> &dst_shape) { | |||
int64_t c0 = GetCubeSizeByDataType(data_type); | |||
if (c0 <= 0) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Get][Cube]Failed, the data type %s is invalid", | |||
TypeUtilsToSerialString(data_type).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to get cube size, the data type %s is invalid", | |||
TypeUtilsToSerialString(data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
dst_shape.clear(); | |||
@@ -44,8 +47,10 @@ Status TransShapeNhwcToNc1hwc0(const std::vector<int64_t> &src_shape, DataType d | |||
dst_shape.push_back(src_shape.at(kNhwcW)); | |||
dst_shape.push_back(c0); | |||
if (!CheckShapeValid(dst_shape, kNc1hwc0DimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
return SUCCESS; | |||
@@ -60,16 +65,25 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { | |||
return ACL_ERROR_GE_FORMAT_INVALID; | |||
} | |||
if (!CheckDataTypeSupported(args.src_data_type)) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from NHWC to NC1HWC0, invalid data type %s", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Shape]Failed from NHWC to NC1HWC0, " | |||
"invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to trans shape from NHWC to NC1HWC0, invalid data type %s", | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.src_shape, kNhwcDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
if (!CheckShapeValid(args.dst_shape, kNc1hwc0DimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check dst shape %s", | |||
ShapeToString(args.dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
std::vector<int64_t> expect_dst_shape; | |||
@@ -79,10 +93,14 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { | |||
} | |||
if (args.dst_shape != expect_dst_shape) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
"Failed to trans format, the src and dst shape are not compatible. src shape %s, dst shape %s, " | |||
"[Trans][Format]Failed , the src shape %s and dst shape %s are not compatible. " | |||
"expect dst shape %s", | |||
ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), | |||
ShapeToString(expect_dst_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to trans format, the src shape %s and " | |||
"dst shape %s are not compatible. expect dst shape %s", | |||
ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), | |||
ShapeToString(expect_dst_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
@@ -92,10 +110,16 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { | |||
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { | |||
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
if (dst == nullptr) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allcoate][Memory]Failed, memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
REPORT_INNER_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, " | |||
"shape %s when trans format from %s to %s", | |||
total_size, ShapeToString(args.dst_shape).c_str(), | |||
TypeUtils::FormatToSerialString(args.src_format).c_str(), | |||
TypeUtils::FormatToSerialString(args.dst_format).c_str()); | |||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
} | |||
@@ -133,17 +157,26 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
auto ret = memcpy_s(dst.get() + dst_offset, protected_size, args.data + src_offset, size); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to copy data from NHWC[%ld, %ld, %ld, %ld] offset %ld to " | |||
"[Operate][Memory]Failed to copy data from NHWC[%ld, %ld, %ld, %ld] offset %ld to " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld err-code %d", | |||
n_idx, h_idx, w_idx, c_idx, src_offset, n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
n_idx, h_idx, w_idx, c_idx, src_offset, | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
REPROT_CALL_ERROR("E19999", "Failed to copy data from NHWC[%ld, %ld, %ld, %ld] offset %ld to " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld err-code %d", | |||
n_idx, h_idx, w_idx, c_idx, src_offset, | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} else { | |||
auto ret = memset_s(dst.get() + dst_offset, protected_size, 0, size); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to set 0 to NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld base err-code %d", n_idx, c1_idx, | |||
h_idx, w_idx, c0_idx, dst_offset, ret); | |||
"[Operate][Memory]Failed to set 0 to " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld base err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to set 0 to " | |||
"NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld base err-code %d", | |||
n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
} | |||
@@ -172,8 +205,12 @@ Status FormatTransferNhwcNc1hwc0::TransFormat(const TransArgs &args, TransResult | |||
return SUCCESS; | |||
} | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Get][Shape]Failed, " | |||
"total size %ld from dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "[Get][Shape]Failed, total size %ld from " | |||
"dst shape %s, src shape %s", total_size, | |||
ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_DATATYPE_INVALID; | |||
} | |||
GELOGD("Begin to trans format from NHWC to NC1HWC0, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
@@ -182,9 +219,16 @@ Status FormatTransferNhwcNc1hwc0::TransFormat(const TransArgs &args, TransResult | |||
ret = GetDstDataAfterTrans(args, result, size, total_size); | |||
if (ret != SUCCESS) { | |||
GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size); | |||
GELOGE(ret, "[Get][Data]Failed, after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
REPORT_CALL_ERROR("E19999", "Failed to get data after trans, src shape %s, data type %s, " | |||
"dst shape %s, memory size %ld, error_code %u", | |||
ShapeToString(args.src_shape).c_str(), | |||
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
ShapeToString(args.dst_shape).c_str(), total_size, ret); | |||
return ret; | |||
} | |||
return SUCCESS; | |||
@@ -194,8 +238,10 @@ Status FormatTransferNhwcNc1hwc0::TransShape(Format src_format, const std::vecto | |||
DataType data_type, Format dst_format, std::vector<int64_t> &dst_shape) { | |||
if (src_format == FORMAT_NHWC && CheckDataTypeSupported(data_type)) { | |||
if (!CheckShapeValid(src_shape, kNhwcDimsNum)) { | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Failed, src shape %s", | |||
ShapeToString(src_shape).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to check src shape %s", | |||
ShapeToString(args.src_shape).c_str()); | |||
return ACL_ERROR_GE_SHAPE_INVALID; | |||
} | |||
return TransShapeNhwcToNc1hwc0(src_shape, data_type, dst_shape); | |||
@@ -50,8 +50,8 @@ std::map<Format, std::map<Format, std::vector<int64_t>>> perm_args{ | |||
bool IsShapeArgValid(const std::vector<int64_t> &src_shape, const std::vector<int64_t> &perm_arg) { | |||
if (src_shape.empty()) { | |||
std::string error = "Failed to transpose, empty src shape"; | |||
GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_SHAPE_INVALID, error.c_str()); | |||
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to transpose, empty src shape"); | |||
GE_ERRORLOG_AND_ERRORMSG((ACL_ERROR_GE_SHAPE_INVALID, error.c_str()); | |||
GELOGE((ACL_ERROR_GE_SHAPE_INVALID, "[Trans][Shape]Failed, empty src shape"); | |||
return false; | |||
} | |||
for (auto dim : src_shape) { | |||
@@ -82,12 +82,14 @@ bool IsShapeArgValid(const std::vector<int64_t> &src_shape, const std::vector<in | |||
bool IsTransposeArgValid(const uint8_t *src, const std::vector<int64_t> &src_shape, DataType src_data_type, | |||
const std::vector<int64_t> &perm_arg) { | |||
if (src == nullptr) { | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Failed to transpose, the src is null"); | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Trans][Param]Failed, the src is null"); | |||
return false; | |||
} | |||
if (GetSizeByDataType(src_data_type) < 0) { | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to transpose, the data type %s is not support", | |||
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Trans][Param]Failed, the data type %s is not support", | |||
TypeUtils::DataTypeToSerialString(src_data_type).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to transpose, the data type %s is not support", | |||
TypeUtils::DataTypeToSerialString(src_data_type).c_str()); | |||
return false; | |||
} | |||
return IsShapeArgValid(src_shape, perm_arg); | |||
@@ -173,10 +175,14 @@ Status Transpose(const uint8_t *src, const std::vector<int64_t> &src_shape, Data | |||
static_cast<size_t>(data_size)); | |||
if (ret != EOK) { | |||
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, | |||
"Failed to transpose, src shape %s, perm arg %s, dst shape %s, " | |||
"[Operate][Memory]Failed to transpose, src shape %s, perm arg %s, dst shape %s, " | |||
"failed to write to dst offset %ld, current dim offset %s", | |||
ShapeToString(src_shape).c_str(), ShapeToString(perm_arg).c_str(), ShapeToString(dst_shape).c_str(), | |||
dst_offset_bytes, ShapeToString(dst_indexes).c_str()); | |||
REPORT_CALL_ERROR("E19999", "Failed to transpose, src shape %s, perm arg %s, dst shape %s, " | |||
"failed to write to dst offset %ld, current dim offset %s", | |||
ShapeToString(src_shape).c_str(), ShapeToString(perm_arg).c_str(), ShapeToString(dst_shape).c_str(), | |||
dst_offset_bytes, ShapeToString(dst_indexes).c_str()); | |||
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
} | |||
AddOne(dst_shape, dst_indexes); | |||
@@ -44,7 +44,10 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArg | |||
auto src_shape_size = GetItemNumByShape(args.src_shape); | |||
if (args.data == nullptr && src_shape_size != 0) { | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid input null data"); | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Shape]Failed, input data is null, src_shape %s", | |||
TypeUtilsToSerialString(args.src_shap).c_str()); | |||
REPROT_CALL-ERROR("E19999","Failed to chech shape, input data is null, src_shape %s", | |||
TypeUtilsToSerialString(args.src_shap).c_str()); | |||
return ACL_ERROR_GE_PARAM_INVALID; | |||
} | |||
@@ -82,7 +85,8 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransDataType(const CastAr | |||
} | |||
if (args.data == nullptr && args.src_data_size != 0) { | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid input null data"); | |||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Param]Failed, input data is null, " | |||
"src_data_size %ld", args.src_data_size); | |||
return ACL_ERROR_GE_PARAM_INVALID; | |||
} | |||