!1393 common formats log optimize

Merge pull request !1393 from liyihan123/master
pull/1393/MERGE
计晨 4 years ago committed by Gitee
commit 751a5839a9

@ -155,7 +155,10 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result
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 alloc the memory for dst buf %zu, data size %zu", total_size, args.src_data_size);
"[Allocate][DSTMemory]Failed, memory for dst buf %zu, data size %zu",
total_size, args.src_data_size);
REPORT_CALL_ERROR("E19999", "Failed to allocate memory for dst buf %zu, data size %zu",
total_size, args.src_data_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}

@ -49,11 +49,15 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) {
return ACL_ERROR_GE_DATATYPE_INVALID;
}
if (!CheckShapeValid(src_shape, kC1hwncoc0DimsNum)) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str());
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][SrcShape]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][DSTShape]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;
}
auto cube_size = GetCubeSizeByDataType(args.src_data_type);
@ -74,9 +78,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 to allcoate 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_CALL_ERROR("E19999", "Failed to allcoate 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;
}
@ -116,10 +127,16 @@ 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 C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld to "
"[Operate][Memory]Failed to copy data from "
"C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld to "
"HWCN[%ld, %ld, %ld, %ld] offset %ld, err-code %d",
c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, src_offset, h_idx, w_idx, c_idx, n_idx, dst_offset,
ret);
c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, src_offset,
h_idx, w_idx, c_idx, n_idx, dst_offset, ret);
REPORT_CALL_ERROR("E19999", "Failed to copy data from "
"C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld to "
"HWCN[%ld, %ld, %ld, %ld] offset %ld, err-code %d",
c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, src_offset,
h_idx, w_idx, c_idx, n_idx, dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
}
@ -145,8 +162,13 @@ Status FormatTransferC1hwncoc0Hwcn::TransFormat(const TransArgs &args, TransResu
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", "Get shape faield, 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 C1HWNCoC0 to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld.",
@ -154,9 +176,16 @@ Status FormatTransferC1hwncoc0Hwcn::TransFormat(const TransArgs &args, TransResu
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 when 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;

@ -94,10 +94,14 @@ Status TransFormatDhwckToFz3D(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, "[Allocate][DSTMemory]Failed to allcoate 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_CALL_ERROR("E19999", "Failed to allcoate 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;
}
@ -123,9 +127,10 @@ Status TransFormatDhwckToFz3D(const TransArgs &args, TransResult &result) {
args.data + src_idx * data_size, static_cast<size_t>(data_size));
}
if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d",
dst_offset, ret, pad_zero);
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Operate][DSTMemory]Failed at "
"offset %ld, error-code %d, pad mode %d", dst_offset, ret, pad_zero);
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory at offset %ld, "
"error-code %d, pad mode %d", dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
}

@ -95,10 +95,14 @@ Status TransFormatDhwncToFz3DTranspose(const TransArgs &args, TransResult &resul
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, "[Allocate][DSTMemory]Failed to allcoate 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_CALL_ERROR("E19999", "Failed to allcoate 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;
}
@ -124,9 +128,10 @@ Status TransFormatDhwncToFz3DTranspose(const TransArgs &args, TransResult &resul
args.data + src_idx * data_size, static_cast<size_t>(data_size));
}
if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d",
dst_offset, ret, pad_zero);
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Operate][DSTMemory]Failed at "
"offset %ld, error-code %d, pad mode %d", dst_offset, ret, pad_zero);
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory at offset %ld, "
"error-code %d, pad mode %d", dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
}

@ -73,8 +73,9 @@ Status TransShapeToFz(int64_t n, int64_t c, int64_t h, int64_t w, DataType data_
dst_shape.push_back(kNiSize);
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;
@ -102,8 +103,9 @@ Status TransShapeToFzWithGroups(int64_t n, int64_t c, int64_t h, int64_t w, Data
dst_shape.push_back(16);
dst_shape.push_back(cube_k);
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;
@ -190,10 +192,14 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) {
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
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, "[Allocate][DSTMemory]Failed to allcoate 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_CALL_ERROR("E19999", "Failed to allcoate 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;);
for (int64_t vfi = 0; vfi < vf_cnt; vfi++) {
@ -237,9 +243,12 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) {
}
}
if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d pad mode %d", offset,
ret, need_pad_zero);
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,"[Operate][DSTMemory]Failed at offset %ld, "
"error-code %d pad mode %d",
offset, ret, need_pad_zero);
REPORT_CALL_ERROR("E19999","Failed to operate dst memory at offset %ld, "
"error-code %d pad mode %d",
offset, ret, need_pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
}
@ -260,8 +269,11 @@ Status TransFormatHwcnToFzWithGroups(const TransArgs &args, TransResult &result,
int64_t cin_ori = c_dim;
int64_t cout_ori = n_dim / groups;
if (cin_ori == 0 || cout_ori == 0) {
GELOGE(GRAPH_FAILED, "Cin_ori, cout_ori must not be equal 0, and current cin_ori, cout_ori,"
"groups are %ld %ld %ld",cin_ori, cout_ori, groups);
GELOGE(GRAPH_FAILED, "[Check][Param]Failed, cin_ori, cout_ori must not be equal 0, "
"and current cin_ori, cout_ori, groups are %ld %ld %ld", cin_ori, cout_ori, groups);
REPORT_CALL_ERROR("E19999", "Check graph param failed, cin_ori, cout_ori must not be equal 0,"
"and current cin_ori, cout_ori, groups are %ld %ld %ld",
cin_ori, cout_ori, groups);
return GRAPH_FAILED;
}
const int64_t cube_k = GetCubeSizeByDataType(args.src_data_type);
@ -282,14 +294,20 @@ Status TransFormatHwcnToFzWithGroups(const TransArgs &args, TransResult &result,
errno_t ret = EOK;
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[size_output_data], 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(), size_output_data);
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allocate][DSTMemory]Failed to allcoate memory "
"for dst buf %ld when trans format from %s to %s",
size_output_data, TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str());
REPORT_CALL_ERROR("E19999", "Failed to allcoate memory for dst buf %ld "
"when trans format from %s to %s",
size_output_data, TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
ret = memset_s(dst.get(), static_cast<size_t>(size_output_data), 0, static_cast<size_t>(size_output_data));
if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory, ret is %d", ret);
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Operate][DSTMemory]Failed, ret is %d", ret);
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory, ret is %d", ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
for (int64_t g = 0; g < groups; g++) {
@ -352,10 +370,14 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) {
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
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, "[Allocate][DSTMemory]Failed to allcoate 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_CALL_ERROR("E19999", "Failed to allcoate 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;);
for (int64_t c1i = 0; c1i < c1; c1i++) {
@ -375,8 +397,8 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) {
static_cast<size_t>(data_size));
} else {
if (protected_size < data_size) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID,
"Failed to operate the dst memory, protected_size is %ld and size is %ld",
GELOGE(ACL_ERROR_GE_PARAM_INVALID,"[Operate][DSTMemory]Failed, protected_size "
"is %ld and size is %ld",
protected_size, data_size);
return ACL_ERROR_GE_PARAM_INVALID;
}
@ -388,9 +410,11 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) {
}
}
if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d",
dst_offset, ret, pad_zero);
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Operate][DSTMemory]Failed, "
"at offset %ld, error-code %d, pad mode %d", dst_offset, ret, pad_zero);
REPORT_CALL_ERROR("E19999", "Failed to operate dst memoery at offset %ld, "
"error-code %d, pad mode %d",
dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
}
@ -430,10 +454,14 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) {
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
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, "[Allocate][DSTMemory]Failed to allcoate 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_CALL_ERROR("E19999", "Failed to allcoate 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;);
for (int64_t c1i = 0; c1i < c1; c1i++) {
@ -453,8 +481,8 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) {
static_cast<size_t>(data_size));
} else {
if (protected_size < data_size) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID,
"Failed to operate the dst memory, protected_size is %ld and size is %ld",
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Operate][DSTMemory]Failed, protected_size "
"is %ld and size is %ld",
protected_size, data_size);
return ACL_ERROR_GE_PARAM_INVALID;
}
@ -466,9 +494,11 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) {
}
}
if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d",
dst_offset, ret, pad_zero);
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "[Operate][DSTMemory]Failed at offset %ld,"
" error-code %d, pad mode %d", dst_offset, ret, pad_zero);
REPORT_CALL_ERROR("E19999", "Failed to operate dst memory at offset %ld, "
"error-code %d, pad mode %d",
dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
}

Loading…
Cancel
Save