fixed sc warning

pull/1345/head
李磊 4 years ago
parent f19cd2fca9
commit 4fe73f77bc

@ -155,12 +155,12 @@ std::shared_ptr<GraphInfo> Analyzer::GetJsonObject(uint64_t session_id, uint64_t
std::lock_guard<std::recursive_mutex> lg(mutex_); std::lock_guard<std::recursive_mutex> lg(mutex_);
auto iter = graph_infos_.find(session_id); auto iter = graph_infos_.find(session_id);
if (iter == graph_infos_.end()) { if (iter == graph_infos_.end()) {
GELOGE(PARAM_INVALID, "[Check][Session_id]session_id:%lu does not exist! graph_id:%lu.", session_id, graph_id); GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! graph_id:%lu", session_id, graph_id);
return nullptr; return nullptr;
} else { } else {
auto iter1 = (iter->second).find(graph_id); auto iter1 = (iter->second).find(graph_id);
if (iter1 == (iter->second).end()) { if (iter1 == (iter->second).end()) {
GELOGE(PARAM_INVALID, "[Check][Graph_id]graph_id:%lu does not exist! session_id:%lu.", graph_id, session_id); GELOGE(PARAM_INVALID, "[Check][GraphId]graph_id:%lu does not exist! session_id:%lu.", graph_id, session_id);
return nullptr; return nullptr;
} }
GELOGI("GetJsonObject Success!session_id:%lu graph_id:%lu", session_id, graph_id); GELOGI("GetJsonObject Success!session_id:%lu graph_id:%lu", session_id, graph_id);
@ -200,7 +200,7 @@ ge::Status Analyzer::CreateAnalyzerFile() {
} }
ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) {
GELOGD("start to save analyze file."); GELOGD("start to save analyze file");
auto graph_info = GetJsonObject(session_id, graph_id); auto graph_info = GetJsonObject(session_id, graph_id);
GE_CHECK_NOTNULL(graph_info); GE_CHECK_NOTNULL(graph_info);
@ -221,7 +221,10 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_
try { try {
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; json_file_ << jsn.dump(kJsonDumpLevel) << std::endl;
} catch (nlohmann::detail::type_error &e) { } catch (nlohmann::detail::type_error &e) {
GELOGE(FAILED, "[Json.dump][GraphInfo]json.dump to analyze file [%s] failed because [%s], session_id:%lu, graph_id:%lu", json_file_name_.c_str(), e.what(), session_id, graph_id); GELOGE(FAILED,
"[Json.dump][GraphInfo]json.dump to analyze file [%s] failed because [%s],"
"session_id:%lu, graph_id:%lu",
json_file_name_.c_str(), e.what(), session_id, graph_id);
ret_failed = true; ret_failed = true;
} }
json_file_.close(); json_file_.close();
@ -229,7 +232,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_
} }
ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {
GELOGD("start to do analyzer process!"); GELOGD("start to do analyzer process");
auto pnode = data_info.node_ptr; auto pnode = data_info.node_ptr;
GE_CHECK_NOTNULL(pnode); GE_CHECK_NOTNULL(pnode);
@ -241,7 +244,9 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {
GE_CHECK_NOTNULL(graph_info); GE_CHECK_NOTNULL(graph_info);
auto status = SaveOpInfo(desc, data_info, graph_info); auto status = SaveOpInfo(desc, data_info, graph_info);
if (status != SUCCESS) { if (status != SUCCESS) {
GELOGE(status, "[Check][SaveOpInfo]save op info: desc_name [%s] desc_type [%s] failed!", desc->GetName().c_str(), desc->GetType().c_str()); GELOGE(status,
"[Check][SaveOpInfo]save op info: desc_name [%s] desc_type [%s] failed!",
desc->GetName().c_str(), desc->GetType().c_str());
return FAILED; return FAILED;
} }
// create json file // create json file

@ -154,7 +154,8 @@ 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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); GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION,
"Failed to alloc the memory for dst buf %zu, data size %zu", total_size, args.src_data_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
} }

@ -73,7 +73,8 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) {
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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,
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.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(), total_size, ShapeToString(args.dst_shape).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;

@ -94,7 +94,8 @@ 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -122,7 +123,8 @@ Status TransFormatDhwckToFz3D(const TransArgs &args, TransResult &result) {
args.data + src_idx * data_size, static_cast<size_t>(data_size)); args.data + src_idx * data_size, static_cast<size_t>(data_size));
} }
if (ret != EOK) { 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", 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); dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }

@ -95,7 +95,8 @@ 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -123,7 +124,8 @@ Status TransFormatDhwncToFz3DTranspose(const TransArgs &args, TransResult &resul
args.data + src_idx * data_size, static_cast<size_t>(data_size)); args.data + src_idx * data_size, static_cast<size_t>(data_size));
} }
if (ret != EOK) { 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", 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); dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }

@ -139,7 +139,8 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -175,7 +176,8 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size * w0)); static_cast<size_t>(size * w0));
if (ret != EOK) { if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -189,7 +191,8 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size)); static_cast<size_t>(size));
if (ret != EOK) { if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -210,7 +213,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -246,7 +250,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size * w0)); static_cast<size_t>(size * w0));
if (ret != EOK) { if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -260,7 +265,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size)); static_cast<size_t>(size));
if (ret != EOK) { if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -274,14 +280,16 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con
Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult &result) { Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult &result) {
if (!IsDataTypeSupport(args.src_data_type)) { if (!IsDataTypeSupport(args.src_data_type)) {
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", GELOGE(ACL_ERROR_GE_DATATYPE_INVALID,
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
return ACL_ERROR_GE_DATATYPE_INVALID; return ACL_ERROR_GE_DATATYPE_INVALID;
} }
if (!CheckShape(args.src_format, args.src_shape) || !IsShapeValid(args.dst_shape)) { if (!CheckShape(args.src_format, args.src_shape) || !IsShapeValid(args.dst_shape)) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
@ -325,7 +333,8 @@ Status FormatTransferFractalNz::TransShape(Format src_format, const ShapeVector
Status FormatTransferFractalNzND::TransFormat(const TransArgs &args, TransResult &result) { Status FormatTransferFractalNzND::TransFormat(const TransArgs &args, TransResult &result) {
if (!IsDataTypeSupport(args.src_data_type)) { if (!IsDataTypeSupport(args.src_data_type)) {
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", GELOGE(ACL_ERROR_GE_DATATYPE_INVALID,
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
@ -333,7 +342,8 @@ Status FormatTransferFractalNzND::TransFormat(const TransArgs &args, TransResult
} }
if (!IsShapeValid(args.src_shape) || !CheckShape(args.dst_format, args.dst_shape)) { if (!IsShapeValid(args.src_shape) || !CheckShape(args.dst_format, args.dst_shape)) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
"Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());

@ -127,7 +127,8 @@ 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[]>()); 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( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
dst == nullptr, 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION;); return ACL_ERROR_GE_MEMORY_ALLOCATION;);
@ -173,8 +174,9 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) {
} }
} }
if (ret != EOK) { 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, GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
ret, need_pad_zero); "Failed to operate the dst memory at offset %ld, error-code %d pad mode %d",
offset, ret, need_pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -213,7 +215,8 @@ 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[]>()); 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( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
dst == nullptr, 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION;); return ACL_ERROR_GE_MEMORY_ALLOCATION;);
@ -235,7 +238,8 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) {
static_cast<size_t>(data_size)); static_cast<size_t>(data_size));
} else { } else {
if (protected_size < data_size) { 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,
"Failed to operate the dst memory, protected_size is %ld and size is %ld",
protected_size, data_size); protected_size, data_size);
return ACL_ERROR_GE_PARAM_INVALID; return ACL_ERROR_GE_PARAM_INVALID;
} }
@ -247,7 +251,8 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) {
} }
} }
if (ret != EOK) { 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", 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); dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
@ -288,7 +293,8 @@ 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[]>()); 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( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
dst == nullptr, 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION;); return ACL_ERROR_GE_MEMORY_ALLOCATION;);
@ -310,7 +316,8 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) {
static_cast<size_t>(data_size)); static_cast<size_t>(data_size));
} else { } else {
if (protected_size < data_size) { 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,
"Failed to operate the dst memory, protected_size is %ld and size is %ld",
protected_size, data_size); protected_size, data_size);
return ACL_ERROR_GE_PARAM_INVALID; return ACL_ERROR_GE_PARAM_INVALID;
} }
@ -322,7 +329,8 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) {
} }
} }
if (ret != EOK) { 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", 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); dst_offset, ret, pad_zero);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }

@ -140,7 +140,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -179,7 +180,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size * w0)); static_cast<size_t>(size * w0));
if (ret != EOK) { if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -217,7 +219,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -257,7 +260,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size * w0)); static_cast<size_t>(size * w0));
if (ret != EOK) { if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -273,7 +277,8 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size)); static_cast<size_t>(size));
if (ret != EOK) { if (ret != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED,
"Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
@ -288,14 +293,16 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con
Status FormatTransferFractalZz::TransFormat(const TransArgs &args, TransResult &result) { Status FormatTransferFractalZz::TransFormat(const TransArgs &args, TransResult &result) {
if (!IsDataTypeSupport(args.src_data_type)) { if (!IsDataTypeSupport(args.src_data_type)) {
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", GELOGE(ACL_ERROR_GE_DATATYPE_INVALID,
"Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
return ACL_ERROR_GE_DATATYPE_INVALID; return ACL_ERROR_GE_DATATYPE_INVALID;
} }
if (!CheckShape(args.src_format, args.src_shape) || !IsShapeValid(args.dst_shape)) { if (!CheckShape(args.src_format, args.src_shape) || !IsShapeValid(args.dst_shape)) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
"Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
@ -339,7 +346,8 @@ Status FormatTransferFractalZz::TransShape(Format src_format, const ShapeVector
Status FormatTransferFractalZzND::TransFormat(const TransArgs &args, TransResult &result) { Status FormatTransferFractalZzND::TransFormat(const TransArgs &args, TransResult &result) {
if (!IsDataTypeSupport(args.src_data_type)) { if (!IsDataTypeSupport(args.src_data_type)) {
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", GELOGE(ACL_ERROR_GE_DATATYPE_INVALID,
"Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
@ -347,7 +355,8 @@ Status FormatTransferFractalZzND::TransFormat(const TransArgs &args, TransResult
} }
if (!IsShapeValid(args.src_shape) || !CheckShape(args.dst_format, args.dst_shape)) { if (!IsShapeValid(args.src_shape) || !CheckShape(args.dst_format, args.dst_shape)) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
"Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(),
ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());

@ -74,7 +74,8 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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,
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.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(), total_size, ShapeToString(args.dst_shape).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;

@ -37,7 +37,7 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) {
std::string error = "Dose not support trans format from " + std::string error = "Dose not support trans format from " +
FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " +
FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); FmtToStr(TypeUtils::FormatToSerialString(args.dst_format));
GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str());
return ACL_ERROR_GE_FORMAT_INVALID; return ACL_ERROR_GE_FORMAT_INVALID;
} }
if (!CheckDataTypeSupported(args.src_data_type)) { if (!CheckDataTypeSupported(args.src_data_type)) {
@ -59,9 +59,10 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) {
} }
int64_t c1 = Ceil(dst_shape.at(kNchwC), c0); int64_t c1 = Ceil(dst_shape.at(kNchwC), c0);
int64_t n0 = Ceil(dst_shape.at(kNchwN), static_cast<int64_t>(kNiSize)); int64_t n0 = Ceil(dst_shape.at(kNchwN), static_cast<int64_t>(kNiSize));
if (src_shape.at(kFracZHWC1) != dst_shape.at(kNchwH) * dst_shape.at(kNchwW) * c1 || src_shape.at(kFracZC0) != c0 || if (src_shape.at(kFracZHWC1) != dst_shape.at(kNchwH) * dst_shape.at(kNchwW) * c1 ||
src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { 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", 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()); ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str());
return ACL_ERROR_GE_SHAPE_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
@ -72,7 +73,8 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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,
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.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(), total_size, ShapeToString(args.dst_shape).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;

@ -37,33 +37,34 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) {
std::string error = "Dose not support trans format from " + std::string error = "Dose not support trans format from " +
FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " +
FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); FmtToStr(TypeUtils::FormatToSerialString(args.dst_format));
GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str());
return UNSUPPORTED; return ACL_ERROR_GE_FORMAT_INVALID;
} }
if (!CheckDataTypeSupported(args.src_data_type)) { if (!CheckDataTypeSupported(args.src_data_type)) {
GELOGE(UNSUPPORTED, "Failed to trans shape from FORMAT_FRACTAL_Z to NHWC, invalid data type %s", GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from FORMAT_FRACTAL_Z to NHWC, invalid data type %s",
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
return UNSUPPORTED; return ACL_ERROR_GE_DATATYPE_INVALID;
} }
if (!CheckShapeValid(src_shape, kFracZDimsNum)) { if (!CheckShapeValid(src_shape, kFracZDimsNum)) {
GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str());
return PARAM_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
if (!CheckShapeValid(dst_shape, kNhwcDimsNum)) { if (!CheckShapeValid(dst_shape, kNhwcDimsNum)) {
GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str());
return PARAM_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); int64_t c0 = GetCubeSizeByDataType(args.src_data_type);
if (c0 < 0) { if (c0 < 0) {
return PARAM_INVALID; return ACL_ERROR_GE_DATATYPE_INVALID;
} }
int64_t c1 = Ceil(dst_shape.at(kNhwcC), c0); int64_t c1 = Ceil(dst_shape.at(kNhwcC), c0);
int64_t n0 = Ceil(dst_shape.at(kNhwcN), static_cast<int64_t>(kNiSize)); int64_t n0 = Ceil(dst_shape.at(kNhwcN), static_cast<int64_t>(kNiSize));
if (src_shape.at(kFracZHWC1) != dst_shape.at(kNhwcH) * dst_shape.at(kNhwcW) * c1 || src_shape.at(kFracZC0) != c0 || if (src_shape.at(kFracZHWC1) != dst_shape.at(kNhwcH) * dst_shape.at(kNhwcW) * c1 ||
src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) {
GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", 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()); ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str());
return PARAM_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
return SUCCESS; return SUCCESS;
@ -72,10 +73,11 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) {
std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", 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",
TypeUtils::FormatToSerialString(args.src_format).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(), total_size, ShapeToString(args.dst_shape).c_str());
return OUT_OF_MEMORY; return ACL_ERROR_GE_MEMORY_ALLOCATION;
} }
auto n0 = args.src_shape.at(kFracZN0); auto n0 = args.src_shape.at(kFracZN0);
@ -111,10 +113,10 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size
auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset, auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size)); static_cast<size_t>(size));
if (ret != EOK) { if (ret != EOK) {
GELOGE(INTERNAL_ERROR, 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", "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); src_offset, n_idx, h_idx, w_idx, c_idx, dst_offset, ret);
return INTERNAL_ERROR; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
} }
@ -127,8 +129,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size
} // namespace } // namespace
Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &result) { Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &result) {
if (CheckArgsForFracZToNhwc(args) != SUCCESS) { Status ret = CheckArgsForFracZToNhwc(args);
return PARAM_INVALID; if (ret != SUCCESS) {
return ret;
} }
int size = GetSizeByDataType(args.src_data_type); int size = GetSizeByDataType(args.src_data_type);
auto total_size = GetItemNumByShape(args.dst_shape) * size; auto total_size = GetItemNumByShape(args.dst_shape) * size;
@ -139,18 +142,19 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &
return SUCCESS; return SUCCESS;
} }
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, 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()); ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str());
return PARAM_INVALID; 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", GELOGD("Begin to trans format from FracZ to NHWC, 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.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),
ShapeToString(args.dst_shape).c_str(), total_size); ShapeToString(args.dst_shape).c_str(), total_size);
if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { ret = GetDstDataAfterTrans(args, result, size, total_size);
GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", 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.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),
ShapeToString(args.dst_shape).c_str(), total_size); ShapeToString(args.dst_shape).c_str(), total_size);
return INTERNAL_ERROR; return ret;
} }
return SUCCESS; return SUCCESS;
} }
@ -158,7 +162,7 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &
Status FormatTransferFracZNhwc::TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type, Status FormatTransferFracZNhwc::TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type,
Format dst_format, std::vector<int64_t> &dst_shape) { Format dst_format, std::vector<int64_t> &dst_shape) {
GELOGD("The shape derivation from FracZ to NHWC is not unique. Trans shape in this direction is not supported"); GELOGD("The shape derivation from FracZ to NHWC is not unique. Trans shape in this direction is not supported");
return UNSUPPORTED; return ACL_ERROR_GE_FORMAT_INVALID;
} }
REGISTER_FORMAT_TRANSFER(FormatTransferFracZNhwc, FORMAT_FRACTAL_Z, FORMAT_NHWC) REGISTER_FORMAT_TRANSFER(FormatTransferFracZNhwc, FORMAT_FRACTAL_Z, FORMAT_NHWC)

@ -91,7 +91,8 @@ Status CheckArgsForHwcnToC1hwncoc0(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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,
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.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(), total_size, ShapeToString(args.dst_shape).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;

@ -37,33 +37,33 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) {
std::string error = "Dose not support trans format from " + std::string error = "Dose not support trans format from " +
FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " +
FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); FmtToStr(TypeUtils::FormatToSerialString(args.dst_format));
GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str());
return UNSUPPORTED; return ACL_ERROR_GE_FORMAT_INVALID;
} }
if (!CheckDataTypeSupported(args.src_data_type)) { if (!CheckDataTypeSupported(args.src_data_type)) {
GELOGE(UNSUPPORTED, "Failed to trans shape from NC1HWC0 to NCHW, invalid data type %s", GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from NC1HWC0 to NCHW, invalid data type %s",
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
return UNSUPPORTED; return ACL_ERROR_GE_DATATYPE_INVALID;
} }
if (!CheckShapeValid(args.src_shape, kNc1hwc0DimsNum)) { if (!CheckShapeValid(args.src_shape, kNc1hwc0DimsNum)) {
GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str());
return PARAM_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
if (!CheckShapeValid(args.dst_shape, kNchwDimsNum)) { if (!CheckShapeValid(args.dst_shape, kNchwDimsNum)) {
GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str());
return PARAM_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
int64_t c0 = GetCubeSizeByDataType(args.src_data_type); int64_t c0 = GetCubeSizeByDataType(args.src_data_type);
if (c0 <= 0) { if (c0 <= 0) {
GELOGE(PARAM_INVALID, "Failed to get cube size, the data type is invalid"); GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to get cube size, the data type is invalid");
return PARAM_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
if (src_shape.at(kNc1hwc0H) != dst_shape.at(kNchwH) || src_shape.at(kNc1hwc0W) != dst_shape.at(kNchwW) || 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(kNc1hwc0N) != dst_shape.at(kNchwN) || src_shape.at(kNc1hwc0C0) != c0 ||
src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNchwC), c0))) { src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNchwC), c0))) {
GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", 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()); ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str());
return PARAM_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
return SUCCESS; return SUCCESS;
@ -72,10 +72,11 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { if (dst == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", 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",
TypeUtils::FormatToSerialString(args.src_format).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(), total_size, ShapeToString(args.dst_shape).c_str());
return OUT_OF_MEMORY; return ACL_ERROR_GE_MEMORY_ALLOCATION;
} }
auto h = args.src_shape.at(kNc1hwc0H); auto h = args.src_shape.at(kNc1hwc0H);
@ -109,11 +110,11 @@ 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, auto ret = memcpy_s(dst.get() + dst_offset, static_cast<size_t>(protected_size), args.data + src_offset,
static_cast<size_t>(size)); static_cast<size_t>(size));
if (ret != EOK) { if (ret != EOK) {
GELOGE(INTERNAL_ERROR, 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]" "Failed to copy data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld to NCHW[%ld, %ld, %ld, %ld]"
" offset %ld, err-code %d", " 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); n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret);
return INTERNAL_ERROR; return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
} }
} }
} }
@ -126,8 +127,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in
} // namespace } // namespace
Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult &result) { Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult &result) {
if (CheckArgsForNc1hwc0ToNchw(args) != SUCCESS) { Status ret = CheckArgsForNc1hwc0ToNchw(args);
return PARAM_INVALID; if (ret != SUCCESS) {
return ret;
} }
int size = GetSizeByDataType(args.src_data_type); int size = GetSizeByDataType(args.src_data_type);
auto total_size = GetItemNumByShape(args.dst_shape) * size; auto total_size = GetItemNumByShape(args.dst_shape) * size;
@ -138,18 +140,19 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult
return SUCCESS; return SUCCESS;
} }
GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, 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()); ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str());
return PARAM_INVALID; 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", GELOGD("Begin to trans format from NC1HWC0 to NCHW, 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.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),
ShapeToString(args.dst_shape).c_str(), total_size); ShapeToString(args.dst_shape).c_str(), total_size);
if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { ret = GetDstDataAfterTrans(args, result, size, total_size);
GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", 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.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),
ShapeToString(args.dst_shape).c_str(), total_size); ShapeToString(args.dst_shape).c_str(), total_size);
return INTERNAL_ERROR; return ret;
} }
return SUCCESS; return SUCCESS;
} }
@ -157,7 +160,7 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult
Status FormatTransferNc1hwc0Nchw::TransShape(Format src_format, const std::vector<int64_t> &src_shape, Status FormatTransferNc1hwc0Nchw::TransShape(Format src_format, const std::vector<int64_t> &src_shape,
DataType data_type, Format dst_format, std::vector<int64_t> &dst_shape) { DataType data_type, Format dst_format, std::vector<int64_t> &dst_shape) {
GELOGD("The shape derivation from NC1HWC0 to NCHW is not unique. Trans shape in this direction is not supported"); GELOGD("The shape derivation from NC1HWC0 to NCHW is not unique. Trans shape in this direction is not supported");
return UNSUPPORTED; return ACL_ERROR_GE_FORMAT_INVALID;
} }
REGISTER_FORMAT_TRANSFER(FormatTransferNc1hwc0Nchw, FORMAT_NC1HWC0, FORMAT_NCHW) REGISTER_FORMAT_TRANSFER(FormatTransferNc1hwc0Nchw, FORMAT_NC1HWC0, FORMAT_NCHW)

@ -61,7 +61,8 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) {
if (src_shape.at(kNc1hwc0H) != dst_shape.at(kNhwcH) || src_shape.at(kNc1hwc0W) != dst_shape.at(kNhwcW) || 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(kNc1hwc0N) != dst_shape.at(kNhwcN) || src_shape.at(kNc1hwc0C0) != c0 ||
src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNhwcC), 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,
"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()); ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str());
return ACL_ERROR_GE_SHAPE_INVALID; return ACL_ERROR_GE_SHAPE_INVALID;
} }
@ -72,7 +73,8 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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,
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.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(), total_size, ShapeToString(args.dst_shape).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;

@ -125,7 +125,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) {
return ACL_ERROR_GE_INTERNAL_ERROR); return ACL_ERROR_GE_INTERNAL_ERROR);
auto t1 = h_o * w_o; auto t1 = h_o * w_o;
auto t2 = n_o * c_o; auto t2 = n_o * c_o;
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2),
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2);
return ACL_ERROR_GE_INTERNAL_ERROR); return ACL_ERROR_GE_INTERNAL_ERROR);
int64_t total_ele_cnt = n_o * c_o * h_o * w_o; int64_t total_ele_cnt = n_o * c_o * h_o * w_o;
@ -140,7 +141,8 @@ 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -212,7 +214,8 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr<uin
return ACL_ERROR_GE_INTERNAL_ERROR); return ACL_ERROR_GE_INTERNAL_ERROR);
auto t1 = h_o * w_o; auto t1 = h_o * w_o;
auto t2 = n_o * c_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); GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2),
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR,"int64 mul overflow.A[%ld], B[%ld]", t1, t2);
return ACL_ERROR_GE_INTERNAL_ERROR); return ACL_ERROR_GE_INTERNAL_ERROR);
int64_t total_ele_cnt = n_o * c_o * h_o * w_o; int64_t total_ele_cnt = n_o * c_o * h_o * w_o;
@ -228,7 +231,8 @@ 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[]>()); dst.reset(new (std::nothrow) uint8_t[dst_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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", 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.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;
@ -275,7 +279,8 @@ Status FormatTransferNchwToFZC04::TransFormat(const TransArgs &args, TransResult
} }
std::vector<int64_t> expect_shape; std::vector<int64_t> expect_shape;
ret = TransShape(args_tmp.src_format, args_tmp.src_shape, args_tmp.src_data_type, args_tmp.dst_format, expect_shape); ret = TransShape(args_tmp.src_format, args_tmp.src_shape, args_tmp.src_data_type,
args_tmp.dst_format, expect_shape);
if (ret != SUCCESS) { if (ret != SUCCESS) {
return ret; return ret;
} }

@ -92,7 +92,8 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) {
Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { 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[]>()); std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>());
if (dst == nullptr) { 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,
"Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s",
TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.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(), total_size, ShapeToString(args.dst_shape).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION; return ACL_ERROR_GE_MEMORY_ALLOCATION;

@ -1748,7 +1748,8 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector<int64_t> &ranges) {
if (has_tvm_workspace_mem_type_attr && (temp.size() != tvm_workspace_memory_type.size())) { if (has_tvm_workspace_mem_type_attr && (temp.size() != tvm_workspace_memory_type.size())) {
REPORT_INNER_ERROR("E19999", "Attr[%s]size:%zu is not equal to workspace size:%zu, node_name:%s", REPORT_INNER_ERROR("E19999", "Attr[%s]size:%zu is not equal to workspace size:%zu, node_name:%s",
TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), temp.size(), n->GetName().c_str()); TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(),
temp.size(), n->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Attr]Attr %s size:%zu is not equal to workspace size:%zu, node_name:%s", GELOGE(INTERNAL_ERROR, "[Check][Attr]Attr %s size:%zu is not equal to workspace size:%zu, node_name:%s",
TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), temp.size(), n->GetName().c_str()); TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), temp.size(), n->GetName().c_str());
return; return;
@ -2161,7 +2162,8 @@ bool BlockMemAssigner::GetWorkSpaceMemoryType(const NodePtr &node, size_t index,
if (has_workspace_mem_type_attr && (workspace_memory_type.size() <= index)) { if (has_workspace_mem_type_attr && (workspace_memory_type.size() <= index)) {
REPORT_INNER_ERROR("E19999", "get workspace mem_type failed, " REPORT_INNER_ERROR("E19999", "get workspace mem_type failed, "
"index %zu invalid, bigger than attr %s size:%zu, node_name:%s", "index %zu invalid, bigger than attr %s size:%zu, node_name:%s",
index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), workspace_memory_type.size(), node->GetName().c_str()); index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(),
workspace_memory_type.size(), node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][WorkspaceMemType]index %zu invalid, bigger than attr %s size:%zu, node_name:%s", GELOGE(INTERNAL_ERROR, "[Get][WorkspaceMemType]index %zu invalid, bigger than attr %s size:%zu, node_name:%s",
index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), workspace_memory_type.size(), node->GetName().c_str()); index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), workspace_memory_type.size(), node->GetName().c_str());
return false; return false;

@ -384,7 +384,8 @@ Status ModelUtils::GetVarAddr(const RuntimeParam &model_param, const ConstOpDesc
switch (mem_type) { switch (mem_type) {
case RT_MEMORY_RDMA_HBM: case RT_MEMORY_RDMA_HBM:
if (offset < 0) { if (offset < 0) {
GELOGE(PARAM_INVALID, "rdma var addr is invalid, addr=%p", reinterpret_cast<uint8_t *>(offset)); GELOGE(PARAM_INVALID, "rdma var addr is invalid, addr=%p",
reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset)));
return PARAM_INVALID; return PARAM_INVALID;
} }
var_addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset)); var_addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset));

@ -1772,8 +1772,8 @@ Status GraphPrepare::CheckUserInput(const std::vector<GeTensor> &user_input) {
if (dim < UNKNOWN_DIM_NUM) { if (dim < UNKNOWN_DIM_NUM) {
std::string situation = "data dim[" + std::to_string(i) + "][" + std::to_string(dim) + "]" ; std::string situation = "data dim[" + std::to_string(i) + "][" + std::to_string(dim) + "]" ;
std::string reason = "it need >= -2"; std::string reason = "it need >= -2";
REPORT_INPUT_ERROR( REPORT_INPUT_ERROR("E19025", std::vector<std::string>({"situation", "reason"}),
"E19025", std::vector<std::string>({"situation", "reason"}),std::vector<std::string>({situation, reason})); std::vector<std::string>({situation, reason}));
GELOGE(GE_GRAPH_INIT_FAILED, "[Check][InputDim]data dim %zu is not supported, need >= -2, real:%ld.", i, dim); GELOGE(GE_GRAPH_INIT_FAILED, "[Check][InputDim]data dim %zu is not supported, need >= -2, real:%ld.", i, dim);
return GE_GRAPH_INIT_FAILED; return GE_GRAPH_INIT_FAILED;
} }

@ -407,7 +407,8 @@ Status GatherV2Kernel::Compute(const OpDescPtr op_desc_ptr, const vector<ConstGe
// check input data type // check input data type
auto x_data_type = tensor0->GetTensorDesc().GetDataType(); auto x_data_type = tensor0->GetTensorDesc().GetDataType();
if (supported_type.find(x_data_type) == supported_type.end()) { if (supported_type.find(x_data_type) == supported_type.end()) {
GELOGI("GatherV2Kernel does not support this Data type:%s.", TypeUtils::DataTypeToSerialString(x_data_type).c_str()); GELOGI("GatherV2Kernel does not support this Data type:%s.",
TypeUtils::DataTypeToSerialString(x_data_type).c_str());
return NOT_CHANGED; return NOT_CHANGED;
} }
// calc output shape // calc output shape

@ -105,7 +105,7 @@ Status HybridModelAsyncExecutor::Init() {
executor_ = std::unique_ptr<HybridModelExecutor>(new(std::nothrow) HybridModelExecutor(model_, device_id_, stream_)); executor_ = std::unique_ptr<HybridModelExecutor>(new(std::nothrow) HybridModelExecutor(model_, device_id_, stream_));
GE_CHECK_NOTNULL(executor_); GE_CHECK_NOTNULL(executor_);
GE_CHK_STATUS_RET(executor_->Init(), "Failed to init hybrid engine"); GE_CHK_STATUS_RET(executor_->Init(), "Failed to init hybrid engine");
GE_CHK_STATUS_RET(DumpOpDebug(),"Dump op debug failed in hybrid engine"); GE_CHK_STATUS_RET(DumpOpDebug(), "Dump op debug failed in hybrid engine");
GELOGI("HybridModel stage nums:%zu", model_->GetRootGraphItem()->NumGroups()); GELOGI("HybridModel stage nums:%zu", model_->GetRootGraphItem()->NumGroups());
if (model_->GetRootGraphItem()->NumGroups() >= kMinimumPiplineStages) { if (model_->GetRootGraphItem()->NumGroups() >= kMinimumPiplineStages) {

@ -34,6 +34,8 @@ const int64_t kDynamicImageSizeNum = 2;
const size_t kMaxDynamicDimNum = 100; const size_t kMaxDynamicDimNum = 100;
const size_t kMaxNDDimNum = 4; const size_t kMaxNDDimNum = 4;
const size_t kMinNDDimNum = 1; const size_t kMinNDDimNum = 1;
const size_t kSquareBracketsSize = 2;
const size_t kRangePairSize = 2;
// datatype/formats from user to GE, Unified to util interface file later // datatype/formats from user to GE, Unified to util interface file later
const std::map<std::string, ge::DataType> kOutputTypeSupportDatatype = { const std::map<std::string, ge::DataType> kOutputTypeSupportDatatype = {
{"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}};
@ -292,7 +294,8 @@ bool ParseSingleShapeRange(std::string &shape_range, vector<pair<int64_t, int64_
} }
} }
bool is_square_brackets = (square_brackets[0] == '[') && (square_brackets[1] == ']') && (square_brackets.size() == 2); bool is_square_brackets = (square_brackets[0] == '[') && (square_brackets[1] == ']') &&
(square_brackets.size() == kSquareBracketsSize);
if (!is_square_brackets) { if (!is_square_brackets) {
ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"},
{shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample2}); {shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample2});
@ -320,7 +323,7 @@ bool ParseSingleShapeRange(std::string &shape_range, vector<pair<int64_t, int64_
} else { } else {
range_pair = std::make_pair(range_value, range_value); range_pair = std::make_pair(range_value, range_value);
} }
} else if (range_pair_set.size() == 2) { } else if (range_pair_set.size() == kRangePairSize) {
// unknown dim, should get range. // unknown dim, should get range.
long range_left = 0; long range_left = 0;
if (!StringToLongNoThrow(range_pair_set.at(0), range_left)) { if (!StringToLongNoThrow(range_pair_set.at(0), range_left)) {
@ -334,7 +337,8 @@ bool ParseSingleShapeRange(std::string &shape_range, vector<pair<int64_t, int64_
ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"},
{shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample3}); {shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample3});
GELOGE(PARAM_INVALID, GELOGE(PARAM_INVALID,
"Parse input parameter [--input_shape_range]'s shape range[%s] failed, reason: %s, correct sample is %s.", "Parse input parameter [--input_shape_range]'s shape range[%s] failed,"
"reason: %s, correct sample is %s.",
shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample3); shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample3);
return false; return false;
} }
@ -402,7 +406,7 @@ Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_i
if (param_size == 0) { if (param_size == 0) {
if (!input_shape_range.empty()) { if (!input_shape_range.empty()) {
std::map<string, std::vector<std::pair<int64_t, int64_t>>> shape_range_map; std::map<string, std::vector<std::pair<int64_t, int64_t>>> shape_range_map;
if(!ParseInputShapeRange(input_shape_range, shape_range_map)) { if (!ParseInputShapeRange(input_shape_range, shape_range_map)) {
GELOGE(ge::PARAM_INVALID, "Failed to parse input shape range: %s", input_shape_range.c_str()); GELOGE(ge::PARAM_INVALID, "Failed to parse input shape range: %s", input_shape_range.c_str());
return ge::PARAM_INVALID; return ge::PARAM_INVALID;
} }

@ -569,7 +569,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape1) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape2) { TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape2) {
@ -579,7 +579,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape2) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape1) { TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape1) {
@ -588,7 +588,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape1) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape2) { TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape2) {
@ -598,7 +598,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape2) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_dst_shape_relation) { TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_dst_shape_relation) {
@ -608,7 +608,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_dst_shape_relation) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_format) { TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_format) {
@ -618,10 +618,10 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_format) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID);
Status status = Status status =
transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape);
EXPECT_EQ(status, UNSUPPORTED); EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID);
} }
TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_format) { TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_format) {
@ -631,7 +631,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_format) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID);
} }
TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_data_type) { TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_data_type) {
@ -642,7 +642,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_data_type) {
TransResult result; TransResult result;
FormatTransferNc1hwc0Nchw transfer; FormatTransferNc1hwc0Nchw transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID);
} }
} // namespace formats } // namespace formats
} // namespace ge } // namespace ge

@ -39,7 +39,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_data_type) {
TransResult result; TransResult result;
FormatTransferFracZNhwc transfer; FormatTransferFracZNhwc transfer;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_format_reserved) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_format_reserved) {
@ -50,7 +50,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_format_reserved)
reinterpret_cast<uint8_t *>(data), FORMAT_RESERVED, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT}; reinterpret_cast<uint8_t *>(data), FORMAT_RESERVED, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_format_reserved) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_format_reserved) {
@ -61,7 +61,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_format_reserved)
reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_RESERVED, {16, 1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT}; reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_RESERVED, {16, 1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape) {
@ -71,7 +71,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape) {
TransArgs args{reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16}, {1, 4, 4, 1}, DT_FLOAT}; TransArgs args{reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16}, {1, 4, 4, 1}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape2) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape2) {
@ -82,7 +82,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape2) {
reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, -1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT}; reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, -1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape) {
@ -93,7 +93,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape) {
reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4}, DT_FLOAT}; reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape2) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape2) {
@ -104,7 +104,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape2) {
reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, -1}, DT_FLOAT}; reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, -1}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relation1) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relation1) {
@ -115,7 +115,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relatio
reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {17, 4, 4, 1}, DT_FLOAT}; reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {17, 4, 4, 1}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relation2) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relation2) {
@ -126,7 +126,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relatio
reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, 17}, DT_FLOAT}; reinterpret_cast<uint8_t *>(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, 17}, DT_FLOAT};
TransResult result; TransResult result;
EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_lt_cube) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_lt_cube) {
@ -301,7 +301,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_eq_cube) {
} }
Status status = Status status =
transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape);
EXPECT_EQ(status, UNSUPPORTED); EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID);
} }
TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_gt_cube) { TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_gt_cube) {

@ -67,4 +67,22 @@ TEST_F(UtestModelUtils, get_var_addr_rdma_hbm) {
EXPECT_EQ(reinterpret_cast<uint8_t *>(offset), var_addr); EXPECT_EQ(reinterpret_cast<uint8_t *>(offset), var_addr);
VarManager::Instance(runtime_param.session_id)->Destory(); VarManager::Instance(runtime_param.session_id)->Destory();
} }
TEST_F(UtestModelUtils, get_var_addr_rdma_hbm_negative_offset) {
uint8_t test = 2;
uint8_t *pf = &test;
RuntimeParam runtime_param;
runtime_param.session_id = 0;
runtime_param.logic_var_base = 0;
runtime_param.var_base = pf;
int64_t offset = -1;
EXPECT_EQ(VarManager::Instance(runtime_param.session_id)->Init(0, 0, 0, 0), SUCCESS);
EXPECT_NE(VarManager::Instance(runtime_param.session_id)->var_resource_, nullptr);
VarManager::Instance(runtime_param.session_id)->var_resource_->var_offset_map_[offset] = RT_MEMORY_RDMA_HBM;
std::shared_ptr<OpDesc> op_desc = std::make_shared<OpDesc>("test", "test");
uint8_t *var_addr = nullptr;
EXPECT_NE(ModelUtils::GetVarAddr(runtime_param, op_desc, offset, var_addr), SUCCESS);
VarManager::Instance(runtime_param.session_id)->Destory();
}
} // namespace ge } // namespace ge

Loading…
Cancel
Save