| @@ -937,6 +937,10 @@ add_library(atc_stub_ge_compiler SHARED | |||
| add_dependencies(atc_stub_ge_compiler ge_stub) | |||
| target_compile_options(atc_stub_ge_compiler PRIVATE | |||
| -fno-common | |||
| ) | |||
| target_link_libraries(atc_stub_ge_compiler PRIVATE | |||
| $<BUILD_INTERFACE:intf_pub> | |||
| ) | |||
| @@ -973,6 +977,10 @@ add_library(fwk_stub_ge_runner SHARED | |||
| add_dependencies(fwk_stub_ge_runner ge_stub) | |||
| target_compile_options(fwk_stub_ge_runner PRIVATE | |||
| -fno-common | |||
| ) | |||
| target_link_libraries(fwk_stub_ge_runner PRIVATE | |||
| $<BUILD_INTERFACE:intf_pub> | |||
| ) | |||
| @@ -155,12 +155,12 @@ std::shared_ptr<GraphInfo> Analyzer::GetJsonObject(uint64_t session_id, uint64_t | |||
| std::lock_guard<std::recursive_mutex> lg(mutex_); | |||
| auto iter = graph_infos_.find(session_id); | |||
| 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; | |||
| } else { | |||
| auto iter1 = (iter->second).find(graph_id); | |||
| 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; | |||
| } | |||
| 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) { | |||
| GELOGD("start to save analyze file."); | |||
| GELOGD("start to save analyze file"); | |||
| auto graph_info = GetJsonObject(session_id, graph_id); | |||
| GE_CHECK_NOTNULL(graph_info); | |||
| @@ -221,7 +221,10 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ | |||
| try { | |||
| json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; | |||
| } 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; | |||
| } | |||
| 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) { | |||
| GELOGD("start to do analyzer process!"); | |||
| GELOGD("start to do analyzer process"); | |||
| auto pnode = data_info.node_ptr; | |||
| GE_CHECK_NOTNULL(pnode); | |||
| @@ -241,7 +244,9 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { | |||
| GE_CHECK_NOTNULL(graph_info); | |||
| auto status = SaveOpInfo(desc, data_info, graph_info); | |||
| 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; | |||
| } | |||
| // 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[]>()); | |||
| 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; | |||
| } | |||
| @@ -73,7 +73,8 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { | |||
| 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[]>()); | |||
| 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.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
| 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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| 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)); | |||
| } | |||
| 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); | |||
| 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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| 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)); | |||
| } | |||
| 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); | |||
| 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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| 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, | |||
| static_cast<size_t>(size * w0)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -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, | |||
| static_cast<size_t>(size)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| 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, | |||
| static_cast<size_t>(size * w0)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -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, | |||
| static_cast<size_t>(size)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -274,14 +280,16 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con | |||
| Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult &result) { | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), | |||
| ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
| return ACL_ERROR_GE_DATATYPE_INVALID; | |||
| } | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).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) { | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).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)) { | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).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[]>()); | |||
| 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", | |||
| 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); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION;); | |||
| @@ -173,7 +174,8 @@ 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, | |||
| 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); | |||
| 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[]>()); | |||
| 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", | |||
| 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); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION;); | |||
| @@ -235,7 +238,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, | |||
| "Failed to operate the dst memory, protected_size is %ld and size is %ld", | |||
| protected_size, data_size); | |||
| return ACL_ERROR_GE_PARAM_INVALID; | |||
| } | |||
| @@ -247,7 +251,8 @@ 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", | |||
| 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); | |||
| 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[]>()); | |||
| 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", | |||
| 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); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION;); | |||
| @@ -310,7 +316,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, | |||
| "Failed to operate the dst memory, protected_size is %ld and size is %ld", | |||
| protected_size, data_size); | |||
| return ACL_ERROR_GE_PARAM_INVALID; | |||
| } | |||
| @@ -322,7 +329,8 @@ 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", | |||
| 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); | |||
| 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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| 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, | |||
| static_cast<size_t>(size * w0)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -195,7 +197,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, | |||
| static_cast<size_t>(size)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -217,7 +220,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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
| @@ -257,7 +261,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, | |||
| static_cast<size_t>(size * w0)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -273,7 +278,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, | |||
| static_cast<size_t>(size)); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -288,14 +294,16 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con | |||
| Status FormatTransferFractalZz::TransFormat(const TransArgs &args, TransResult &result) { | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), | |||
| ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
| return ACL_ERROR_GE_DATATYPE_INVALID; | |||
| } | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), | |||
| ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
| @@ -339,7 +347,8 @@ Status FormatTransferFractalZz::TransShape(Format src_format, const ShapeVector | |||
| Status FormatTransferFractalZzND::TransFormat(const TransArgs &args, TransResult &result) { | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), | |||
| ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); | |||
| @@ -347,7 +356,8 @@ Status FormatTransferFractalZzND::TransFormat(const TransArgs &args, TransResult | |||
| } | |||
| 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.dst_format).c_str(), ShapeToString(args.src_shape).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) { | |||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
| if (dst == nullptr) { | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
| "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.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
| @@ -37,7 +37,7 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) { | |||
| std::string error = "Dose not support trans format from " + | |||
| FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + | |||
| 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; | |||
| } | |||
| 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 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 || | |||
| 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", | |||
| if (src_shape.at(kFracZHWC1) != dst_shape.at(kNchwH) * dst_shape.at(kNchwW) * c1 || | |||
| src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
| "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", | |||
| ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); | |||
| 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) { | |||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
| if (dst == nullptr) { | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
| "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.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
| @@ -37,33 +37,34 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { | |||
| std::string error = "Dose not support trans format from " + | |||
| FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + | |||
| FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); | |||
| GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); | |||
| return UNSUPPORTED; | |||
| GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); | |||
| return ACL_ERROR_GE_FORMAT_INVALID; | |||
| } | |||
| 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()); | |||
| return UNSUPPORTED; | |||
| return ACL_ERROR_GE_DATATYPE_INVALID; | |||
| } | |||
| if (!CheckShapeValid(src_shape, kFracZDimsNum)) { | |||
| GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); | |||
| return PARAM_INVALID; | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); | |||
| return ACL_ERROR_GE_SHAPE_INVALID; | |||
| } | |||
| if (!CheckShapeValid(dst_shape, kNhwcDimsNum)) { | |||
| GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); | |||
| return PARAM_INVALID; | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); | |||
| return ACL_ERROR_GE_SHAPE_INVALID; | |||
| } | |||
| int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
| if (c0 < 0) { | |||
| return PARAM_INVALID; | |||
| return ACL_ERROR_GE_DATATYPE_INVALID; | |||
| } | |||
| int64_t c1 = Ceil(dst_shape.at(kNhwcC), c0); | |||
| 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 || | |||
| 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", | |||
| if (src_shape.at(kFracZHWC1) != dst_shape.at(kNhwcH) * dst_shape.at(kNhwcW) * c1 || | |||
| src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
| "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", | |||
| ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); | |||
| return PARAM_INVALID; | |||
| return ACL_ERROR_GE_SHAPE_INVALID; | |||
| } | |||
| return SUCCESS; | |||
| @@ -72,10 +73,11 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { | |||
| 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[]>()); | |||
| 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.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); | |||
| @@ -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, | |||
| static_cast<size_t>(size)); | |||
| 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", | |||
| 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 | |||
| Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &result) { | |||
| if (CheckArgsForFracZToNhwc(args) != SUCCESS) { | |||
| return PARAM_INVALID; | |||
| Status ret = CheckArgsForFracZToNhwc(args); | |||
| if (ret != SUCCESS) { | |||
| return ret; | |||
| } | |||
| int size = GetSizeByDataType(args.src_data_type); | |||
| auto total_size = GetItemNumByShape(args.dst_shape) * size; | |||
| @@ -139,18 +142,19 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & | |||
| 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()); | |||
| 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", | |||
| ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
| ShapeToString(args.dst_shape).c_str(), total_size); | |||
| if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { | |||
| GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
| 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); | |||
| return INTERNAL_ERROR; | |||
| return ret; | |||
| } | |||
| 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, | |||
| 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"); | |||
| return UNSUPPORTED; | |||
| return ACL_ERROR_GE_FORMAT_INVALID; | |||
| } | |||
| 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) { | |||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
| if (dst == nullptr) { | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
| "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.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
| @@ -37,33 +37,34 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) { | |||
| std::string error = "Dose not support trans format from " + | |||
| FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + | |||
| FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); | |||
| GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); | |||
| return UNSUPPORTED; | |||
| GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); | |||
| return ACL_ERROR_GE_FORMAT_INVALID; | |||
| } | |||
| 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()); | |||
| return UNSUPPORTED; | |||
| return ACL_ERROR_GE_DATATYPE_INVALID; | |||
| } | |||
| if (!CheckShapeValid(args.src_shape, kNc1hwc0DimsNum)) { | |||
| GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); | |||
| return PARAM_INVALID; | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); | |||
| return ACL_ERROR_GE_SHAPE_INVALID; | |||
| } | |||
| if (!CheckShapeValid(args.dst_shape, kNchwDimsNum)) { | |||
| GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); | |||
| return PARAM_INVALID; | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); | |||
| return ACL_ERROR_GE_SHAPE_INVALID; | |||
| } | |||
| int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | |||
| if (c0 <= 0) { | |||
| GELOGE(PARAM_INVALID, "Failed to get cube size, the data type is invalid"); | |||
| return PARAM_INVALID; | |||
| GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); | |||
| return ACL_ERROR_GE_DATATYPE_INVALID; | |||
| } | |||
| if (src_shape.at(kNc1hwc0H) != dst_shape.at(kNchwH) || src_shape.at(kNc1hwc0W) != dst_shape.at(kNchwW) || | |||
| src_shape.at(kNc1hwc0N) != dst_shape.at(kNchwN) || src_shape.at(kNc1hwc0C0) != c0 || | |||
| src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNchwC), c0))) { | |||
| GELOGE(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()); | |||
| return PARAM_INVALID; | |||
| return ACL_ERROR_GE_SHAPE_INVALID; | |||
| } | |||
| return SUCCESS; | |||
| @@ -72,10 +73,11 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) { | |||
| Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { | |||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
| if (dst == nullptr) { | |||
| GELOGE(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.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); | |||
| @@ -109,11 +111,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, | |||
| static_cast<size_t>(size)); | |||
| 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]" | |||
| " offset %ld, err-code %d", | |||
| n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); | |||
| return INTERNAL_ERROR; | |||
| return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; | |||
| } | |||
| } | |||
| } | |||
| @@ -126,8 +128,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||
| } // namespace | |||
| Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult &result) { | |||
| if (CheckArgsForNc1hwc0ToNchw(args) != SUCCESS) { | |||
| return PARAM_INVALID; | |||
| Status ret = CheckArgsForNc1hwc0ToNchw(args); | |||
| if (ret != SUCCESS) { | |||
| return ret; | |||
| } | |||
| int size = GetSizeByDataType(args.src_data_type); | |||
| auto total_size = GetItemNumByShape(args.dst_shape) * size; | |||
| @@ -138,18 +141,19 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult | |||
| 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()); | |||
| 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", | |||
| ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), | |||
| ShapeToString(args.dst_shape).c_str(), total_size); | |||
| if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { | |||
| GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", | |||
| 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); | |||
| return INTERNAL_ERROR; | |||
| return ret; | |||
| } | |||
| return SUCCESS; | |||
| } | |||
| @@ -157,7 +161,7 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult | |||
| 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) { | |||
| 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) | |||
| @@ -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) || | |||
| src_shape.at(kNc1hwc0N) != dst_shape.at(kNhwcN) || src_shape.at(kNc1hwc0C0) != c0 || | |||
| src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNhwcC), c0))) { | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", | |||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, | |||
| "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", | |||
| ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); | |||
| return ACL_ERROR_GE_SHAPE_INVALID; | |||
| } | |||
| @@ -72,7 +73,8 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) { | |||
| Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { | |||
| std::shared_ptr<uint8_t> dst(new (std::nothrow) uint8_t[total_size], std::default_delete<uint8_t[]>()); | |||
| if (dst == nullptr) { | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | |||
| "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.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
| @@ -125,7 +125,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { | |||
| return ACL_ERROR_GE_INTERNAL_ERROR); | |||
| auto t1 = h_o * w_o; | |||
| auto t2 = n_o * c_o; | |||
| GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(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); | |||
| 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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| 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); | |||
| auto t1 = h_o * w_o; | |||
| auto t2 = n_o * c_o; | |||
| GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); | |||
| 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); | |||
| 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[]>()); | |||
| 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.dst_format).c_str(), dst_size); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
| @@ -275,7 +279,8 @@ Status FormatTransferNchwToFZC04::TransFormat(const TransArgs &args, TransResult | |||
| } | |||
| 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) { | |||
| return ret; | |||
| } | |||
| @@ -87,12 +87,13 @@ Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) { | |||
| std::shared_ptr<ModelTaskDef> model_task_def = ge_model->GetModelTaskDefPtr(); | |||
| if (model_task_def == nullptr) { | |||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Create model task def ptr failed"); | |||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||
| GELOGD("SaveSizeToModelDef task_info_size is 0."); | |||
| om_info.push_back(0); | |||
| } else { | |||
| size_t partition_task_size = model_task_def->ByteSizeLong(); | |||
| GELOGD("SaveSizeToModelDef task_info_size is %zu", partition_task_size); | |||
| om_info.push_back(partition_task_size); | |||
| } | |||
| size_t partition_task_size = model_task_def->ByteSizeLong(); | |||
| GELOGD("SaveSizeToModelDef task_info_size is %zu", partition_task_size); | |||
| om_info.push_back(partition_task_size); | |||
| GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(*(ge_model.get()), "om_info_list", om_info), | |||
| GELOGE(FAILED, "SetListInt of om_info_list failed."); | |||
| @@ -212,6 +212,7 @@ target_link_libraries(ge_executor PRIVATE | |||
| add_library(ge_executor_shared SHARED ${SRC_LIST} ${PROTO_HDRS}) | |||
| target_compile_options(ge_executor_shared PRIVATE | |||
| -fno-common | |||
| -Werror | |||
| -O2 | |||
| -Wno-deprecated-declarations | |||
| @@ -30,6 +30,8 @@ | |||
| #include "single_op/single_op_manager.h" | |||
| #include "graph/load/model_manager/davinci_model.h" | |||
| #include "opskernel_manager/ops_kernel_builder_manager.h" | |||
| #include "graph/opsproto_manager.h" | |||
| #include "ge_local_engine/engine/host_cpu_engine.h" | |||
| using std::string; | |||
| using std::vector; | |||
| @@ -199,6 +201,33 @@ bool IsDynmaicDimsSizeMatchModel(const vector<uint64_t> cur_dynamic_dims, | |||
| namespace ge { | |||
| bool GeExecutor::isInit_ = false; | |||
| static void InitOpsProtoManager() { | |||
| string opsproto_path; | |||
| const char *path_env = std::getenv("ASCEND_OPP_PATH"); | |||
| if (path_env != nullptr) { | |||
| string path = path_env; | |||
| string file_path = RealPath(path.c_str()); | |||
| if (file_path.empty()) { | |||
| GELOGE(FAILED, "[Check][EnvPath]ASCEND_OPP_PATH path [%s] is invalid.", path.c_str()); | |||
| REPORT_INPUT_ERROR("E68016", {"ASCEND_OPP_PATH", path}); | |||
| return; | |||
| } | |||
| opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); | |||
| GELOGI("Get opsproto so path from env : %s", path.c_str()); | |||
| } else { | |||
| string path_base = PluginManager::GetPath(); | |||
| GELOGI("path_base is %s", path_base.c_str()); | |||
| path_base = path_base.substr(0, path_base.rfind('/')); | |||
| path_base = path_base.substr(0, path_base.rfind('/') + 1); | |||
| opsproto_path = (path_base + "ops/op_proto/custom/" + ":") + (path_base + "ops/op_proto/built-in/"); | |||
| } | |||
| GELOGI("Get opsproto path is %s", opsproto_path.c_str()); | |||
| OpsProtoManager *manager = OpsProtoManager::Instance(); | |||
| map<string, string> option_tmp; | |||
| option_tmp.emplace(std::pair<string, string>(string("ge.opsProtoLibPath"), opsproto_path)); | |||
| (void)manager->Initialize(option_tmp); | |||
| } | |||
| GeExecutor::GeExecutor() {} | |||
| Status GeExecutor::Initialize() { | |||
| @@ -208,6 +237,16 @@ Status GeExecutor::Initialize() { | |||
| return ge::SUCCESS; | |||
| } | |||
| OpTilingManager::GetInstance().LoadSo(); | |||
| Status init_hostcpu_engine_status = HostCpuEngine::GetInstance().Initialize(); | |||
| if (init_hostcpu_engine_status != SUCCESS) { | |||
| GELOGE(init_hostcpu_engine_status, "Failed to initialize HostCpuEngine"); | |||
| return init_hostcpu_engine_status; | |||
| } | |||
| InitOpsProtoManager(); | |||
| std::vector<rtMemType_t> mem_type(1, RT_MEMORY_HBM); | |||
| mem_type.push_back(RT_MEMORY_P2P_DDR); | |||
| auto ret = MemManager::Instance().Initialize(mem_type); | |||
| @@ -50,6 +50,8 @@ const char *const kFileNameSuffix = "online"; | |||
| const char *const kAicpuAllshape = "_AllShape"; | |||
| constexpr char const *kAttrSupportDynamicShape = "support_dynamicshape"; | |||
| const int64_t kDynamicDimValue = -2; | |||
| const int kDefaultDeviceId = 0; | |||
| const int kDefaultJobId = 0; | |||
| std::map<ge::OpEngineType, std::string> engine_type_map{ | |||
| {ge::ENGINE_SYS, kEngineNameDefault}, | |||
| @@ -85,8 +87,9 @@ static Status CheckEngineTypeSupport(const NodePtr &node, OpEngineType engine_ty | |||
| } else { | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E14001", {"opname", "optype", "value", "reason"}, | |||
| {op_desc->GetName(), op_desc->GetType(), "engine type", | |||
| "it only support kEngineNameDefault/kAIcoreEngine/kVectorEngine"}); | |||
| GELOGE(FAILED, "CheckEngineType: engine type: %d not support.", static_cast<int>(engine_type)); | |||
| "it only support default/AIcoreEngine/VectorEngine"}); | |||
| GELOGE(FAILED, "[Check][EngineType]value:%d not support, " | |||
| "only support default/AIcoreEngine/VectorEngine now", static_cast<int>(engine_type)); | |||
| return FAILED; | |||
| } | |||
| @@ -190,17 +193,20 @@ static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, const | |||
| (void)AttrUtils::SetBool(data_op, "_is_single_op", true); | |||
| GE_CHK_BOOL_EXEC(data_op->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add input desc fail"); | |||
| GE_CHK_BOOL_EXEC(data_op->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add output desc fail"); | |||
| GE_CHK_BOOL_EXEC(data_op->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, | |||
| "[Add][InputDesc]fail for node:%s", data_op->GetName().c_str()); | |||
| GE_CHK_BOOL_EXEC(data_op->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, | |||
| "[Add][OutputDesc]fail for node:%s", data_op->GetName().c_str()); | |||
| if (attr) { | |||
| GE_CHK_BOOL_EXEC(AttrUtils::SetInt(data_op, ATTR_NAME_INDEX, index), return FAILED, "Set index fail"); | |||
| GE_CHK_BOOL_EXEC(AttrUtils::SetInt(data_op, ATTR_NAME_INDEX, index), return FAILED, | |||
| "[Set][Attr:%s]fail for node:%s", ATTR_NAME_INDEX.c_str(), data_op->GetName().c_str()); | |||
| } | |||
| ge::NodePtr arg_node = graph->AddNode(data_op); | |||
| GE_CHK_BOOL_EXEC(arg_node != nullptr, return FAILED, "Insert Data node fail"); | |||
| GE_CHK_STATUS(GraphUtils::AddEdge(arg_node->GetOutDataAnchor(0), node->GetInDataAnchor(index)), | |||
| "Add edge[%s->%s] fail", data_op->GetName().c_str(), node->GetName().c_str()); | |||
| "[Add][Edge]fail from node:%s to node:%s", data_op->GetName().c_str(), node->GetName().c_str()); | |||
| return SUCCESS; | |||
| } | |||
| @@ -215,20 +221,23 @@ static Status AddOutputs(const ComputeGraphPtr &graph, const NodePtr &node, cons | |||
| for (const auto &out_desc : outputs) { | |||
| GeTensorDesc tensor = out_desc.GetTensorDesc(); | |||
| TensorUtils::SetInputTensor(tensor, true); | |||
| GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add input desc fail."); | |||
| GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, | |||
| "[Add][InputDesc]fail for node:%s", op_desc->GetName().c_str()); | |||
| TensorUtils::SetInputTensor(tensor, false); | |||
| TensorUtils::SetOutputTensor(tensor, true); | |||
| GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add output desc fail."); | |||
| GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, | |||
| "[Add][OutputDesc]fail for node:%s", op_desc->GetName().c_str()); | |||
| count++; | |||
| } | |||
| GE_CHECK_NOTNULL_EXEC(graph, return PARAM_INVALID); | |||
| ge::NodePtr out_node = graph->AddNode(op_desc); | |||
| GE_CHK_BOOL_EXEC(out_node != nullptr, return FAILED, "Insert Output node fail"); | |||
| GE_CHK_BOOL_EXEC(out_node != nullptr, return FAILED, | |||
| "[Add][Node:%s]fail in graph:%u", op_desc->GetName().c_str(), graph->GetGraphID()); | |||
| GE_CHECK_NOTNULL_EXEC(node, return PARAM_INVALID); | |||
| for (int32_t i = 0; i < count; ++i) { | |||
| GE_CHK_STATUS(GraphUtils::AddEdge(node->GetOutDataAnchor(i), out_node->GetInDataAnchor(i)), | |||
| "Add edge[%s->%s] fail", node->GetName().c_str(), out_node->GetName().c_str()); | |||
| "[Add][Edge]fail from node:%s to node:%s", node->GetName().c_str(), out_node->GetName().c_str()); | |||
| } | |||
| return SUCCESS; | |||
| @@ -248,7 +257,7 @@ static void GetOpsProtoPath(string &opsproto_path) { | |||
| return; | |||
| } | |||
| string path_base = PluginManager::GetPath(); | |||
| GELOGI("path_base is %s.", path_base.c_str()); | |||
| GELOGI("path_base is %s", path_base.c_str()); | |||
| path_base = path_base.substr(0, path_base.rfind('/')); | |||
| path_base = path_base.substr(0, path_base.rfind('/') + 1); | |||
| opsproto_path = (path_base + "ops/op_proto/custom/" + ":") + (path_base + "ops/op_proto/built-in/"); | |||
| @@ -333,7 +342,7 @@ Status GeGenerator::Initialize(const map<string, string> &options, OmgContext &o | |||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kInitialize, ErrorMessage::kOpsProtoInit); | |||
| string opsproto_path; | |||
| GetOpsProtoPath(opsproto_path); | |||
| GELOGI("Get opsproto path is %s.", opsproto_path.c_str()); | |||
| GELOGI("Get opsproto path is %s", opsproto_path.c_str()); | |||
| OpsProtoManager *manager = OpsProtoManager::Instance(); | |||
| map<string, string> option_tmp; | |||
| option_tmp.emplace(std::pair<string, string>(string("ge.opsProtoLibPath"), opsproto_path)); | |||
| @@ -556,6 +565,44 @@ bool GeGenerator::Impl::SetOmSystemInfo(AttrHolder &obj) { | |||
| return true; | |||
| } | |||
| Status GeGenerator::SetModelNameForDump(const GeRootModelPtr &ge_root_model) { | |||
| bool is_unknown_shape = false; | |||
| Status ret = ge_root_model->CheckIsUnknownShape(is_unknown_shape); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(FAILED, "[Check][IsUnknownShape]Check root model is unknown shape failed, model id:%u", | |||
| ge_root_model->GetModelId()); | |||
| REPORT_CALL_ERROR("E19999", "Check root model is unknown shape failed, model id:%zu", | |||
| ge_root_model->GetModelId()); | |||
| return FAILED; | |||
| } | |||
| GeModelPtr model_root = nullptr; | |||
| if (is_unknown_shape) { | |||
| model_root = MakeShared<GeModel>(); | |||
| GE_CHECK_NOTNULL(model_root); | |||
| model_root->SetGraph(GraphUtils::CreateGraphFromComputeGraph(ge_root_model->GetRootGraph())); | |||
| ge_root_model->SetSubgraphInstanceNameToModel(ge_root_model->GetRootGraph()->GetName(), model_root); | |||
| } | |||
| ModelHelper model_helper; | |||
| string model_name; | |||
| GE_CHECK_NOTNULL(ge_root_model->GetRootGraph()); | |||
| Status name_ret = model_helper.GetModelNameFromMergedGraphName(ge_root_model->GetRootGraph()->GetName(), | |||
| model_name); | |||
| if (name_ret != SUCCESS) { | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E10000", {"parameter"}, {"output"}); | |||
| GELOGE(FAILED, "[Check][GetModelNameStep]Get model_name failed. Param --output is invalid, root graph name: %s", | |||
| ge_root_model->GetRootGraph()->GetName().c_str()); | |||
| REPORT_CALL_ERROR("E19999", "Get model_name failed. Param --output is invalid,", | |||
| "root graph name: %s", ge_root_model->GetRootGraph()->GetName().c_str()); | |||
| return PARAM_INVALID; | |||
| } | |||
| map<string, GeModelPtr> name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); | |||
| GeModelPtr &ge_model = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; | |||
| GE_CHECK_NOTNULL(ge_model); | |||
| ge_model->SetName(model_name); | |||
| return SUCCESS; | |||
| } | |||
| Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_prefix, const vector<GeTensor> &inputs, | |||
| ModelBufferData &model, bool is_offline) { | |||
| rtContext_t ctx = nullptr; | |||
| @@ -590,20 +637,10 @@ Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_pr | |||
| } | |||
| GE_CHECK_NOTNULL(ge_root_model); | |||
| GE_CHECK_NOTNULL(ge_root_model->GetRootGraph()); | |||
| ModelHelper model_helper; | |||
| string model_name = ""; | |||
| Status name_ret = model_helper.GetModelNameFromMergedGraphName(ge_root_model->GetRootGraph()->GetName(), | |||
| model_name); | |||
| if (name_ret != SUCCESS) { | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E10000", {"parameter"}, {"output"}); | |||
| GELOGE(FAILED, "Get model_name failed. Param --output is invalid."); | |||
| return PARAM_INVALID; | |||
| ret = SetModelNameForDump(ge_root_model); | |||
| if (ret != SUCCESS) { | |||
| return ret; | |||
| } | |||
| map<string, GeModelPtr> name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); | |||
| GeModelPtr &ge_model = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; | |||
| GE_RETURN_WITH_LOG_IF_FALSE(ge_model != nullptr, "ge_model cannot be null"); | |||
| ge_model->SetName(model_name); | |||
| ret = impl_->SaveRootModel(file_name_prefix, ge_root_model, model); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(ret, "Save model failed"); | |||
| @@ -712,7 +749,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in | |||
| auto node = comp_graph->FindNode(op_desc->GetName()); | |||
| Status ret = CheckEngineTypeSupport(node, engine_type); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(ret, "check engine type failed"); | |||
| GELOGE(ret, "[Check][EngineType]value:%d for node:%s not support", engine_type, node->GetName().c_str()); | |||
| return ret; | |||
| } | |||
| } | |||
| @@ -786,9 +823,9 @@ Status GeGenerator::BuildSingleOpModel(OpDescPtr &op_desc, const vector<GeTensor | |||
| const vector<GeTensor> &outputs, OpEngineType engine_type, | |||
| ModelBufferData &model_buff) { | |||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | |||
| GELOGI("Start to build single op online, input size: %zu, output size: %zu.", inputs.size(), outputs.size()); | |||
| GELOGI("Start to build single op online, input size: %zu, output size: %zu", inputs.size(), outputs.size()); | |||
| Status status = BuildSingleOp(op_desc, inputs, outputs, kFileNameSuffix, engine_type, model_buff, false); | |||
| GELOGI("Finish build single online model, status: %u.", status); | |||
| GELOGI("Finish build single online model, status: %u", status); | |||
| return status; | |||
| } | |||
| @@ -873,13 +910,12 @@ Status GeGenerator::Impl::SaveRootModel(const string &file_name_prefix, GeRootMo | |||
| "ge root model has no sub model") | |||
| GeModelPtr model_root = nullptr; | |||
| if (is_unknown_shape) { | |||
| model_root = make_shared<GeModel>(); | |||
| model_root->SetGraph(GraphUtils::CreateGraphFromComputeGraph(ge_root_model->GetRootGraph())); | |||
| ge_root_model->SetSubgraphInstanceNameToModel(ge_root_model->GetRootGraph()->GetName(), model_root); | |||
| model_root->SetName(ge_root_model->GetRootGraph()->GetName()); | |||
| auto name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); | |||
| model_root = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; | |||
| } else { | |||
| model_root = ge_root_model->GetSubgraphInstanceNameToModel().begin()->second; | |||
| } | |||
| GE_CHECK_NOTNULL(model_root); | |||
| // set atc version | |||
| if (!SetAtcVersionInfo(*(model_root.get()))) { | |||
| GELOGW("SetPackageVersionInfo of atc failed!"); | |||
| @@ -917,6 +953,13 @@ Status GeGenerator::Impl::BuildModel(const Graph &graph, const vector<GeTensor> | |||
| static std::atomic<uint64_t> atomic_session_id(0); | |||
| auto session_id = atomic_session_id.fetch_add(1); | |||
| // This is a temporary add for graph with variable | |||
| auto version = static_cast<int32_t>(SessionVersion::ClOUD_VERSION); | |||
| ret = VarManager::Instance(session_id)->Init(version, session_id, kDefaultDeviceId, kDefaultJobId); | |||
| GELOGI("Start init var instance, session_id %lu", session_id); | |||
| if (ret != SUCCESS) { | |||
| GELOGW("Failed init var instance, session_id %lu", session_id); | |||
| } | |||
| if (is_singleop_unregistered_) { | |||
| ret = graph_manager_.BuildGraphForUnregisteredOp(graph_id, inputs, ge_root_model, session_id); | |||
| } else { | |||
| @@ -387,7 +387,7 @@ static Status InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDataAnchor | |||
| GE_CHECK_NOTNULL(out_anchor); | |||
| NodePtr in_node = out_anchor->GetOwnerNode(); | |||
| GE_CHECK_NOTNULL(in_node); | |||
| OpDescBuilder op_desc_builder(name, MEMCPYADDRASYNC); | |||
| OpDescBuilder op_desc_builder(name, MEMCPYASYNC); | |||
| OpDescPtr op_desc = op_desc_builder.AddInput("x", in_node->GetOpDesc()->GetOutputDesc(0)) | |||
| .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) | |||
| .Build(); | |||
| @@ -400,6 +400,10 @@ static Status InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDataAnchor | |||
| } | |||
| static Status GenerateTaskForConstant(const std::shared_ptr<ComputeGraph> &graph) { | |||
| if (graph->GetGraphUnknownFlag()) { | |||
| GELOGI("Graph %s is unknown graph, ignore gen_task for constant.", graph->GetName().c_str()); | |||
| return SUCCESS; | |||
| } | |||
| for (auto &node : graph->GetDirectNode()) { | |||
| // CONSTANT not generate task, so insert IDENTITY between CONSTANT and NETOUTPUT | |||
| auto op_desc = node->GetOpDesc(); | |||
| @@ -33,13 +33,21 @@ using std::queue; | |||
| namespace ge { | |||
| LogicalStreamPass::LogicalStreamPass(const string &name) : name_(name) {} | |||
| const string &LogicalStreamPass::GetName() const { return name_; } | |||
| const string &LogicalStreamPass::GetName() const { | |||
| return name_; | |||
| } | |||
| bool LogicalStreamPass::IsEngineSkip(const Subgraph &subgraph) const { return subgraph.engine_conf.skip_assign_stream; } | |||
| bool LogicalStreamPass::IsEngineSkip(const Subgraph &subgraph) const { | |||
| return subgraph.engine_conf.skip_assign_stream; | |||
| } | |||
| bool LogicalStreamPass::IsEngineAttach(const Subgraph &subgraph) const { return subgraph.engine_conf.attach; } | |||
| bool LogicalStreamPass::IsEngineAttach(const Subgraph &subgraph) const { | |||
| return subgraph.engine_conf.attach; | |||
| } | |||
| bool LogicalStreamPass::IsEngineIndependent(const Subgraph &subgraph) const { return subgraph.engine_conf.independent; } | |||
| bool LogicalStreamPass::IsEngineIndependent(const Subgraph &subgraph) const { | |||
| return subgraph.engine_conf.independent; | |||
| } | |||
| bool LogicalStreamPass::HasStreamLabel(const Subgraph &subgraph) const { | |||
| return !subgraph.subgraph_info.GetStreamLabel().empty(); | |||
| @@ -60,14 +68,14 @@ Status AssignByLabelPass::Run(ComputeGraphPtr graph, const vector<SubgraphPtr> & | |||
| // Subgraphs of the same stream_label are assigned to the same stream, | |||
| // and different stream_labels are assigned new streams. | |||
| auto iter = label_streams.find(stream_label); | |||
| if (iter != label_streams.end()) { | |||
| subgraph->stream_id = iter->second; | |||
| } else { | |||
| if (iter == label_streams.end()) { | |||
| subgraph->stream_id = next_stream; | |||
| GELOGI("Assign new stream %ld for label %s", next_stream, stream_label.c_str()); | |||
| GELOGI("[Assign][NewStreamId] %ld for label %s.", next_stream, stream_label.c_str()); | |||
| label_streams.emplace(stream_label, next_stream); | |||
| ++next_stream; | |||
| next_stream++; | |||
| } else { | |||
| subgraph->stream_id = iter->second; | |||
| } | |||
| changed = true; | |||
| } | |||
| @@ -92,15 +100,15 @@ Status IndependentStreamPass::Run(ComputeGraphPtr graph, const vector<SubgraphPt | |||
| const string &stream_label = subgraph->subgraph_info.GetStreamLabel(); | |||
| auto &label_streams = engine_streams[engine]; | |||
| auto iter = label_streams.find(stream_label); | |||
| if (iter != label_streams.end()) { | |||
| subgraph->stream_id = iter->second; | |||
| } else { | |||
| if (iter == label_streams.end()) { | |||
| subgraph->stream_id = next_stream; | |||
| GELOGI("Assign new independent stream %ld for engine %s (label: %s)", next_stream, engine.c_str(), | |||
| GELOGI("[Assign][NewStreamId:independent] %ld for engine %s (label: %s).", next_stream, engine.c_str(), | |||
| stream_label.c_str()); | |||
| label_streams.emplace(stream_label, next_stream); | |||
| ++next_stream; | |||
| next_stream++; | |||
| } else { | |||
| subgraph->stream_id = iter->second; | |||
| } | |||
| changed = true; | |||
| } | |||
| @@ -121,14 +129,16 @@ Status AssignByDependencyPass::Run(ComputeGraphPtr graph, const vector<SubgraphP | |||
| } | |||
| SubgraphPtr reusable_subgraph = GetReusableSubgraph(subgraph, end_subgraph_map, pld_subgraph_map); | |||
| if (reusable_subgraph != nullptr) { | |||
| if (reusable_subgraph == nullptr) { | |||
| (void)AssignNewStream(subgraph); | |||
| } else { | |||
| if (HasAssignedStream(*reusable_subgraph)) { | |||
| subgraph->stream_id = reusable_subgraph->stream_id; | |||
| } else { | |||
| int64_t stream_id = AssignNewStream(reusable_subgraph); | |||
| subgraph->stream_id = stream_id; | |||
| GELOGI("Reusable subgraph %s has not been assigned a stream, now assign new stream %ld", | |||
| reusable_subgraph->name.c_str(), stream_id); | |||
| GELOGI("[Assign][NewStreamId] %ld for Reusable subgraph %s cause has not been assigned before.", | |||
| stream_id, reusable_subgraph->name.c_str()); | |||
| } | |||
| if (reusable_subgraph->reused_subgraph != nullptr) { | |||
| @@ -137,11 +147,10 @@ Status AssignByDependencyPass::Run(ComputeGraphPtr graph, const vector<SubgraphP | |||
| subgraph->reused_subgraph = reusable_subgraph; | |||
| reused_subgraphs_.emplace_back(subgraph, reusable_subgraph); | |||
| GELOGI("Subgraph %s of engine %s reuses stream of subgraph %s of engine %s", subgraph->name.c_str(), | |||
| GELOGI("[Reuse][Stream]Subgraph %s of engine %s reuses stream of subgraph %s of engine %s.", | |||
| subgraph->name.c_str(), | |||
| subgraph->engine_conf.id.c_str(), reusable_subgraph->name.c_str(), | |||
| reusable_subgraph->engine_conf.id.c_str()); | |||
| } else { | |||
| (void)AssignNewStream(subgraph); | |||
| } | |||
| changed = true; | |||
| } | |||
| @@ -191,13 +200,15 @@ bool AssignByDependencyPass::CouldReuse(const SubgraphPtr &subgraph, const Subgr | |||
| auto iter = pld_subgraph_map.find(end_pld_pair.second); | |||
| if (iter != pld_subgraph_map.end()) { | |||
| const SubgraphPtr &pred_subgraph_succ = iter->second; | |||
| if (pred_subgraph_succ != subgraph && pred_subgraph_succ->engine_conf.id == pred_subgraph->engine_conf.id) { | |||
| if ((pred_subgraph_succ != subgraph) && | |||
| (pred_subgraph_succ->engine_conf.id == pred_subgraph->engine_conf.id)) { | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| if ((subgraph->engine_conf.id == pred_subgraph->engine_conf.id) || IsEngineAttach(*subgraph)) { | |||
| if ((subgraph->engine_conf.id == pred_subgraph->engine_conf.id) || | |||
| IsEngineAttach(*subgraph)) { | |||
| return true; | |||
| } | |||
| @@ -249,7 +260,7 @@ int64_t AssignByDependencyPass::AssignNewStream(SubgraphPtr subgraph) { | |||
| engine_stream_num_[engine_name] = stream_id + 1; | |||
| } | |||
| GELOGI("Subgraph %s assigns new temp stream %ld (engine: %s)", subgraph->name.c_str(), stream_id, | |||
| GELOGI("[Assign][NewStreamId:temp]id:%ld for Subgraph %s (engine: %s).", stream_id, subgraph->name.c_str(), | |||
| engine_name.c_str()); | |||
| return stream_id; | |||
| @@ -282,7 +293,7 @@ void AssignByDependencyPass::UpdateAssignedSubgraphs(Context &context) { | |||
| GELOGI("Subgraph %s of engine %s reuses default stream %ld.", subgraph->name.c_str(), | |||
| subgraph->engine_conf.id.c_str(), context.default_stream); | |||
| } else { | |||
| GELOGI("Stream of subgraph %s has been updated to %ld", subgraph->name.c_str(), subgraph->stream_id); | |||
| GELOGI("[Update][StreamId]id:%ld for subgraph %s.", subgraph->stream_id, subgraph->name.c_str()); | |||
| } | |||
| } | |||
| } | |||
| @@ -293,7 +304,7 @@ void AssignByDependencyPass::UpdateReusedSubgraphs() { | |||
| auto &cur_subgraph = item.first; | |||
| auto &reused_graph = item.second; | |||
| cur_subgraph->stream_id = reused_graph->stream_id; | |||
| GELOGI("Stream of subgraph %s has been updated to %ld", cur_subgraph->name.c_str(), cur_subgraph->stream_id); | |||
| GELOGI("[Update][StreamId]id:%ld for subgraph %s.", cur_subgraph->stream_id, cur_subgraph->name.c_str()); | |||
| } | |||
| } | |||
| @@ -330,7 +341,7 @@ Status NodeStreamUpdatePass::Run(ComputeGraphPtr graph, const vector<SubgraphPtr | |||
| engine_name.c_str()); | |||
| return INTERNAL_ERROR; | |||
| } else { | |||
| GELOGI("Subgraph %s is assigned stream %ld (engine: %s)", subgraph->name.c_str(), subgraph->stream_id, | |||
| GELOGI("[Assign][StreamId] %ld for Subgraph %s (engine: %s).", subgraph->stream_id, subgraph->name.c_str(), | |||
| engine_name.c_str()); | |||
| } | |||
| } | |||
| @@ -353,12 +364,12 @@ Status NodeStreamUpdatePass::Run(ComputeGraphPtr graph, const vector<SubgraphPtr | |||
| GELOGD("Node %s of type %s in subgraph %s is assigned parent stream %ld (engine: %s).", node->GetName().c_str(), | |||
| node->GetType().c_str(), subgraph->name.c_str(), context.default_stream, engine_name.c_str()); | |||
| } else if (IsEngineSkip(*subgraph) && node->GetInNodes().empty()) { | |||
| GELOGD("Node %s of type %s in subgraph %s doesn't need to assign a stream (engine: %s)", | |||
| GELOGD("[Skip][StreamIdAssign]Node %s of type %s in subgraph %s doesn't need (engine: %s).", | |||
| node->GetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), engine_name.c_str()); | |||
| } else { | |||
| node->GetOpDesc()->SetStreamId(stream_id); | |||
| GELOGD("Node %s of type %s in subgraph %s is assigned stream %ld (engine: %s)", node->GetName().c_str(), | |||
| node->GetType().c_str(), subgraph->name.c_str(), stream_id, engine_name.c_str()); | |||
| GELOGD("[Assign][StreamId]id:%ld for Node %s of type %s in subgraph %s (engine: %s).", stream_id, | |||
| node->GetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), engine_name.c_str()); | |||
| } | |||
| } | |||
| } | |||
| @@ -387,8 +398,8 @@ int64_t UpdateForSkippedEnginePass::GetSingleInoutStream(const NodePtr &node) co | |||
| if (stream_ids.size() == 1) { | |||
| int64_t stream_id = *(stream_ids.begin()); | |||
| GELOGI("The stream of all input and output nodes of node %s (type: %s) is %ld", node->GetName().c_str(), | |||
| node->GetType().c_str(), stream_id); | |||
| GELOGI("[Get][SingleStreamId]The stream of all input and output nodes of node %s (type: %s) is %ld.", | |||
| node->GetName().c_str(), node->GetType().c_str(), stream_id); | |||
| return stream_id; | |||
| } | |||
| @@ -406,7 +417,7 @@ Status UpdateForSkippedEnginePass::Run(ComputeGraphPtr graph, const vector<Subgr | |||
| auto op_desc = node->GetOpDesc(); | |||
| GE_CHECK_NOTNULL(op_desc); | |||
| auto stream_id = op_desc->GetStreamId(); | |||
| if (stream_id != kInvalidStream && !HasStreamLabel(*subgraph)) { | |||
| if ((stream_id != kInvalidStream) && !HasStreamLabel(*subgraph)) { | |||
| ops_without_label.emplace(op_desc); | |||
| } | |||
| } | |||
| @@ -427,8 +438,8 @@ Status UpdateForSkippedEnginePass::Run(ComputeGraphPtr graph, const vector<Subgr | |||
| int64_t inout_stream = GetSingleInoutStream(node); | |||
| if (inout_stream != kInvalidStream) { | |||
| op_desc->SetStreamId(inout_stream); | |||
| GELOGI("Node %s of type %s reassign to stream %ld from stream %ld", node->GetName().c_str(), | |||
| node->GetType().c_str(), inout_stream, stream_id); | |||
| GELOGI("[Reassign][StreamId]%ld for %ld Node %s of type %s from stream %ld.", | |||
| inout_stream, node->GetName().c_str(), node->GetType().c_str(), stream_id); | |||
| } | |||
| } | |||
| } | |||
| @@ -455,7 +466,7 @@ Status AllReduceParallelPass::Run(ComputeGraphPtr graph, const vector<SubgraphPt | |||
| return NOT_CHANGED; | |||
| } | |||
| GELOGI("AllReduceParallelPass is enabled"); | |||
| GELOGI("AllReduceParallelPass is enabled."); | |||
| GE_DUMP(graph, "BeforeAllReduceParallel"); | |||
| // All successors of HcomAllReduce. | |||
| @@ -463,7 +474,7 @@ Status AllReduceParallelPass::Run(ComputeGraphPtr graph, const vector<SubgraphPt | |||
| for (const NodePtr &node : graph->GetDirectNode()) { | |||
| if (!IsHcomNode(node->GetType()) || | |||
| node->GetInDataNodes().size() <= 1) { | |||
| (node->GetInDataNodes().size() <= 1)) { | |||
| continue; | |||
| } | |||
| @@ -565,7 +576,7 @@ Status LogicalStreamAllocator::Assign(const ComputeGraphPtr &root_graph, const G | |||
| RefreshContinuousStreams(root_graph); | |||
| stream_num = context_.next_stream; | |||
| GELOGI("Assigned logical stream num: %ld", stream_num); | |||
| GELOGI("Assigned logical stream num: %ld.", stream_num); | |||
| return SUCCESS; | |||
| } | |||
| @@ -575,7 +586,7 @@ Status LogicalStreamAllocator::DoAssign(const ComputeGraphPtr &graph, const Grap | |||
| GE_CHECK_NOTNULL(graph); | |||
| NodePtr parent_node = graph->GetParentNode(); | |||
| if (parent_node == nullptr || parent_node->GetOpDesc() == nullptr) { | |||
| if ((parent_node == nullptr) || (parent_node->GetOpDesc() == nullptr)) { | |||
| context_.default_stream = kInvalidStream; | |||
| } else { | |||
| context_.default_stream = parent_node->GetOpDesc()->GetStreamId(); | |||
| @@ -597,10 +608,10 @@ Status LogicalStreamAllocator::DoAssign(const ComputeGraphPtr &graph, const Grap | |||
| return status; | |||
| } | |||
| GELOGD("Subgraphs of graph %s.", graph->GetName().c_str()); | |||
| GELOGD("Subgraphs of graph %s", graph->GetName().c_str()); | |||
| for (const auto &subgraph : subgraphs) { | |||
| if (subgraph != nullptr) { | |||
| GELOGD("subgraph: %s.", subgraph->name.c_str()); | |||
| GELOGD("subgraph: %s", subgraph->name.c_str()); | |||
| } | |||
| } | |||
| @@ -664,9 +675,9 @@ Status LogicalStreamAllocator::RunPasses(const ComputeGraphPtr &graph, const vec | |||
| Status status = pass->Run(graph, subgraphs, context_); | |||
| if (status == SUCCESS) { | |||
| GELOGD("Stream pass %s return SUCCESS", pass->GetName().c_str()); | |||
| GELOGD("Stream pass %s return SUCCESS.", pass->GetName().c_str()); | |||
| } else if (status == NOT_CHANGED) { | |||
| GELOGD("Stream pass %s return NOT_CHANGED", pass->GetName().c_str()); | |||
| GELOGD("Stream pass %s return NOT_CHANGED.", pass->GetName().c_str()); | |||
| } else { | |||
| GELOGE(status, "Stream pass %s failed.", pass->GetName().c_str()); | |||
| return status; | |||
| @@ -686,7 +697,7 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra | |||
| auto op_desc = node->GetOpDesc(); | |||
| if (op_desc != nullptr) { | |||
| int64_t stream_id = op_desc->GetStreamId(); | |||
| if (stream_id != kInvalidStream && stream_id < stream_num) { | |||
| if ((stream_id != kInvalidStream) && (stream_id < stream_num)) { | |||
| stream_has_node[stream_id] = true; | |||
| } | |||
| } | |||
| @@ -695,10 +706,10 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra | |||
| context_.next_stream = 0; | |||
| vector<int64_t> old_to_new_streams(stream_num, kInvalidStream); | |||
| for (size_t old_stream = 0; old_stream < stream_has_node.size(); ++old_stream) { | |||
| for (size_t old_stream = 0; old_stream < stream_has_node.size(); old_stream++) { | |||
| if (stream_has_node[old_stream]) { | |||
| old_to_new_streams[old_stream] = context_.next_stream; | |||
| ++context_.next_stream; | |||
| context_.next_stream++; | |||
| } | |||
| } | |||
| @@ -706,7 +717,7 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra | |||
| auto op_desc = node->GetOpDesc(); | |||
| if (op_desc != nullptr) { | |||
| int64_t stream_id = op_desc->GetStreamId(); | |||
| if (stream_id != kInvalidStream && stream_id < stream_num) { | |||
| if ((stream_id != kInvalidStream) && (stream_id < stream_num)) { | |||
| op_desc->SetStreamId(old_to_new_streams[stream_id]); | |||
| } | |||
| } | |||
| @@ -597,11 +597,13 @@ void BlockMemAssigner::GetOutAndWorkSpaceMem(vector<int64_t> &all_memory_size) { | |||
| int64_t size = 0; | |||
| GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(output_desc, size) != SUCCESS, GELOGI("Get size failed")); | |||
| GE_IF_BOOL_EXEC(size < 0, | |||
| GELOGE(FAILED, "[Check][TensorSize]tensor_size:%ld is invalid, maybe it is unknown shape node, Node_name:%s", | |||
| size, node_op_desc->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "tensor_size:%ld is invalid, maybe it is unknown shape node, Node_name:%s", | |||
| size, node_op_desc->GetName().c_str()); | |||
| return;); | |||
| GELOGE(FAILED, "[Check][TensorSize]tensor_size:%ld is invalid, " | |||
| "maybe it is unknown shape node, Node_name:%s", | |||
| size, node_op_desc->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "tensor_size:%ld is invalid, " | |||
| "maybe it is unknown shape node, Node_name:%s", | |||
| size, node_op_desc->GetName().c_str()); | |||
| return;); | |||
| batch_all_memory_size[batch_label].emplace_back(size); | |||
| if (batch_total_size.find(batch_label) == batch_total_size.end()) { | |||
| batch_total_size[batch_label] = size; | |||
| @@ -692,23 +694,23 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou | |||
| auto out_anchor = n->GetOutDataAnchor(out_index); | |||
| GE_IF_BOOL_EXEC(out_anchor == nullptr, | |||
| GELOGE(FAILED, "[Check][Anchor]Node[%s] output[%u] anchor is null.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| REPORT_INNER_ERROR("E19999", "output anchor is null, node_name: %s output_index: %u.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| return false;); | |||
| for (auto const &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { | |||
| GE_IF_BOOL_EXEC(peer_in_anchor == nullptr, | |||
| GELOGE(FAILED, "[Check][Anchor]Node[%s] output[%u] peer_in_anchor 0 is null.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| REPORT_INNER_ERROR("E19999", "output anchor peer is null, node_name: %s output_index: %u.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| return false;); | |||
| auto peer_node = peer_in_anchor->GetOwnerNode(); | |||
| GE_IF_BOOL_EXEC(peer_node == nullptr, | |||
| GELOGE(FAILED, "[Check][Node]Node[%s] output[%u] peer node is null.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| REPORT_INNER_ERROR("E19999", "output anchor peer node is null, node_name: %s output_index: %u.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| return false;); | |||
| // Get the continuous input type of the node, default is false | |||
| @@ -716,9 +718,9 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou | |||
| auto peer_in_node_desc = peer_node->GetOpDesc(); | |||
| GE_IF_BOOL_EXEC(peer_in_node_desc == nullptr, | |||
| GELOGE(FAILED, "[Check][OpDesc]Node[%s] output[%u] nodedesc is null.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| REPORT_INNER_ERROR("E19999", "output anchor peer op_desc is null, node_name:%s output_index:%u.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| return false;); | |||
| // If GetBool fail, is_input_continuous is false. | |||
| @@ -819,7 +821,7 @@ bool BlockMemAssigner::IsContinuousMemoryReuse(const NodePtr &n, const NodePtr & | |||
| (in_anchor->GetPeerOutAnchor()->GetOwnerNode() == nullptr) || | |||
| (in_anchor->GetPeerOutAnchor()->GetOwnerNode()->GetOpDesc() == nullptr)) { | |||
| GELOGE(FAILED, "[Check][OpDesc]Node[%s] output[%u] peer input node desc is null.", | |||
| n->GetName().c_str(), out_index); | |||
| n->GetName().c_str(), out_index); | |||
| REPORT_INNER_ERROR("E19999", "get output anchor peer op_desc fail, node_name: %s output_index: %u.", | |||
| n->GetName().c_str(), out_index); | |||
| return false; | |||
| @@ -1105,9 +1107,10 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, | |||
| OpMemoryType mem_type, const NodePtr &n, uint32_t out_index, | |||
| const vector<bool> &workspace_reuse_flag, const bool is_op_reuse_mem, | |||
| const bool continuous, int64_t memory_type) { | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null, apply memory failed"); | |||
| return nullptr, "[Check][Param]Input parameter n(type:node_ptr) is null."); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| n == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null, apply memory failed"); | |||
| return nullptr, "[Check][Param]Input parameter n(type:node_ptr) is null."); | |||
| auto node_op_desc = n->GetOpDesc(); | |||
| GE_IF_BOOL_EXEC(node_op_desc == nullptr, return nullptr); | |||
| std::string batch_label; | |||
| @@ -1159,10 +1162,12 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, | |||
| } | |||
| auto block = new (std::nothrow) MemoryBlock(block_size, node_op_desc->GetStreamId(), is_reuse_memory, memory_type); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "new a memoryblock object failed. node_name:%s out_index:%u", | |||
| n->GetName().c_str(), out_index); | |||
| return nullptr, "[New][Object]new MemoryBlock failed, node_name:%s out_index:%u", n->GetName().c_str(), out_index); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| block == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "new a memoryblock object failed. node_name:%s out_index:%u", | |||
| n->GetName().c_str(), out_index); | |||
| return nullptr, | |||
| "[New][Object]new MemoryBlock failed, node_name:%s out_index:%u", n->GetName().c_str(), out_index); | |||
| // Data and netoutput need zero copy block | |||
| block->is_zero_copy_ = IsZeroCopyBlock(n, continuous); | |||
| @@ -1221,13 +1226,15 @@ void BlockMemAssigner::ContinuousOutRefCheck(bool &isAllOutputRef, bool &isOutpu | |||
| Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector<int64_t> &ranges, | |||
| const bool is_op_reuse_mem) { | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null"); | |||
| return INTERNAL_ERROR, "[check][param]Input parameter n(type:NodePtr) is null."); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| n == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null"); | |||
| return INTERNAL_ERROR, "[check][param]Input parameter n(type:NodePtr) is null."); | |||
| auto node_op_desc = n->GetOpDesc(); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); | |||
| return INTERNAL_ERROR, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| node_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); | |||
| return INTERNAL_ERROR, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); | |||
| // continuous output support ref only when all output ref input | |||
| bool isAllOutputRef = true; | |||
| @@ -1242,7 +1249,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector<in | |||
| if (!isAllOutputRef && isOutputHasRef) { | |||
| REPORT_INNER_ERROR("E19999", "continuous output node ref part input, not support now. node_name:%s", | |||
| n->GetName().c_str()); | |||
| n->GetName().c_str()); | |||
| GELOGE(INTERNAL_ERROR, "[Check][OutRefStatus]continuous output node ref part input, not support, node_name:%s", | |||
| n->GetName().c_str()); | |||
| return INTERNAL_ERROR; | |||
| @@ -1255,7 +1262,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector<in | |||
| auto output_op_desc = node_op_desc->GetOutputDescPtr(index); | |||
| if (output_op_desc == nullptr) { | |||
| REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", | |||
| n->GetName().c_str(), index); | |||
| n->GetName().c_str(), index); | |||
| GELOGE(INTERNAL_ERROR, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| @@ -1268,7 +1275,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector<in | |||
| int64_t size = 0; | |||
| if (ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS) { | |||
| REPORT_CALL_ERROR("E19999", "get tensor_size failed, node_name:%s, output_index:%u", | |||
| n->GetName().c_str(), index); | |||
| n->GetName().c_str(), index); | |||
| GELOGE(INTERNAL_ERROR, "[Get][TensorSize]node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| @@ -1310,7 +1317,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector<in | |||
| ++(block->ref_count_); | |||
| } else { | |||
| REPORT_CALL_ERROR("E19999", "apply continuousMemory failed, node_name:%s, total_size:%ld", | |||
| n->GetName().c_str(), total_size); | |||
| n->GetName().c_str(), total_size); | |||
| GELOGE(INTERNAL_ERROR, "[Apply][ContinuousMemory]node_name:%s, total_size:%ld", n->GetName().c_str(), total_size); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| @@ -1319,26 +1326,33 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector<in | |||
| MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, const vector<int64_t> &ranges, | |||
| const bool is_op_reuse_mem, const bool continuous) { | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:NodePtr) is null"); | |||
| return nullptr, "[Check][Param]Input parameter n(type:NodePtr) is null"); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| n == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:NodePtr) is null"); | |||
| return nullptr, "[Check][Param]Input parameter n(type:NodePtr) is null"); | |||
| auto node_op_desc = n->GetOpDesc(); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); | |||
| return nullptr, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| node_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); | |||
| return nullptr, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); | |||
| MemoryBlock *block = nullptr; | |||
| NodeIndexIO node_index_io(n, index, kOut); | |||
| int64_t size = 0; | |||
| auto output_op_desc = node_op_desc->GetOutputDescPtr(index); | |||
| GE_IF_BOOL_EXEC(output_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| GELOGE(FAILED, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| return nullptr); | |||
| GE_IF_BOOL_EXEC( | |||
| output_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", | |||
| n->GetName().c_str(), index); | |||
| GELOGE(FAILED, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| return nullptr); | |||
| GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS, GELOGI("Get size failed")); | |||
| size_t no_align_size = 0; | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, | |||
| REPORT_CALL_ERROR("E19999", "Get no align size failed, node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| return nullptr, "[Get][TensorSize]Get no align size, node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, | |||
| REPORT_CALL_ERROR("E19999", "Get no align size failed, node_name:%s, output_index:%u", | |||
| n->GetName().c_str(), index); | |||
| return nullptr, | |||
| "[Get][TensorSize]Get no align size, node_name:%s, output_index:%u", n->GetName().c_str(), index); | |||
| std::string symbol; | |||
| bool reuse_input = false; | |||
| @@ -1346,9 +1360,9 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, | |||
| block = symbol_blocks_[symbol]; | |||
| GE_IF_BOOL_EXEC(block == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "get ref block failed, node_name:%s, symbol:%s", | |||
| node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); | |||
| node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); | |||
| GELOGE(FAILED, "[Get][RefBlock]node_name:%s, symbol:%s", | |||
| node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); | |||
| node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); | |||
| return nullptr); | |||
| // reduce old size | |||
| size_t align_size = block->Size(); | |||
| @@ -1392,24 +1406,28 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, | |||
| vector<bool> workspace_reuse_flag; | |||
| block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, | |||
| workspace_reuse_flag, is_op_reuse_mem, continuous, memory_type); | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, | |||
| REPORT_CALL_ERROR("E19999", "apply out Memory failed, node_name:%s, block_size:%ld, out_index:%u", | |||
| n->GetName().c_str(), block_size, index); | |||
| return nullptr, "[Apply][Memory]node_name:%s, block_size:%ld, out_index:%u", | |||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( | |||
| block == nullptr, | |||
| REPORT_CALL_ERROR("E19999", "apply out Memory failed, node_name:%s, block_size:%ld, out_index:%u", | |||
| n->GetName().c_str(), block_size, index); | |||
| return nullptr, | |||
| "[Apply][Memory]node_name:%s, block_size:%ld, out_index:%u", | |||
| n->GetName().c_str(), block_size, index); | |||
| } | |||
| int out_count = 0; | |||
| GE_IF_BOOL_EXEC(index >= n->GetAllOutDataAnchors().size(), | |||
| REPORT_INNER_ERROR("E19999", "out index:%u exceed out_size:%lu, node_name:%s", | |||
| index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][OutIndex]index:%u exceed out_size:%lu, node_name:%s", | |||
| index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); | |||
| return nullptr); | |||
| GE_IF_BOOL_EXEC( | |||
| index >= n->GetAllOutDataAnchors().size(), | |||
| REPORT_INNER_ERROR("E19999", "out index:%u exceed out_size:%lu, node_name:%s", | |||
| index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][OutIndex]index:%u exceed out_size:%lu, node_name:%s", | |||
| index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); | |||
| return nullptr); | |||
| auto out_data_anchor = n->GetOutDataAnchor(index); | |||
| GE_IF_BOOL_EXEC(out_data_anchor == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "out anchor is null, index:%u, node_name:%s", index, n->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][OutAnchor]is null, index:%u, node_name:%s", index, n->GetName().c_str()); | |||
| return nullptr); | |||
| GE_IF_BOOL_EXEC( | |||
| out_data_anchor == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "out anchor is null, index:%u, node_name:%s", index, n->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][OutAnchor]is null, index:%u, node_name:%s", index, n->GetName().c_str()); | |||
| return nullptr); | |||
| for (const auto &in_anchor : out_data_anchor->GetPeerInDataAnchors()) { | |||
| auto owner_node = in_anchor->GetOwnerNode(); | |||
| auto op_desc = owner_node->GetOpDesc(); | |||
| @@ -1616,12 +1634,13 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector | |||
| op_desc->GetOutputsSize(), memorys_type.size()); | |||
| if (has_mem_type_attr && (memorys_type.size() != op_desc->GetOutputsSize())) { | |||
| REPORT_INNER_ERROR("E19999", "Attr[%s] size:%zu not equal to node output size:%zu, node_name:%s", | |||
| ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), | |||
| op_desc->GetOutputsSize(), op_desc->GetName().c_str()); | |||
| GELOGE(INTERNAL_ERROR, | |||
| "[Check][MemTypeAttr]Attr %s size:%zu not equal to node output size:%zu, node_name:%s", | |||
| ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), | |||
| op_desc->GetOutputsSize(), op_desc->GetName().c_str()); | |||
| ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), | |||
| op_desc->GetOutputsSize(), op_desc->GetName().c_str()); | |||
| GELOGE( | |||
| INTERNAL_ERROR, | |||
| "[Check][MemTypeAttr]Attr %s size:%zu not equal to node output size:%zu, node_name:%s", | |||
| ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), | |||
| op_desc->GetOutputsSize(), op_desc->GetName().c_str()); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| @@ -1748,9 +1767,11 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector<int64_t> &ranges) { | |||
| 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", | |||
| 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", | |||
| 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; | |||
| } | |||
| for (size_t i = 0; i < temp.size(); i++) { | |||
| @@ -2160,10 +2181,11 @@ bool BlockMemAssigner::GetWorkSpaceMemoryType(const NodePtr &node, size_t index, | |||
| ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_memory_type); | |||
| if (has_workspace_mem_type_attr && (workspace_memory_type.size() <= index)) { | |||
| REPORT_INNER_ERROR("E19999", "get workspace mem_type failed, " | |||
| "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 %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()); | |||
| 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; | |||
| } | |||
| memory_type = has_workspace_mem_type_attr ? workspace_memory_type[index] : RT_MEMORY_HBM; | |||
| @@ -99,7 +99,8 @@ Status VariableMemoryAssigner::AssignMemory2HasRefAttrNode() { | |||
| Status GraphMemoryAssigner::AssignMemory() { | |||
| ge::HybridMemAssignerPtr mem_assigner(new(std::nothrow) HybridMemAssigner(compute_graph_)); | |||
| if (mem_assigner->Assign() != ge::SUCCESS) { | |||
| GELOGE(ge::FAILED, "Memory assigner failed"); | |||
| GELOGE(ge::FAILED, "[Assign][GraphMem]graph_id:%u, graph_name:%s", | |||
| compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| MemoryOffset memory_offset(RT_MEMORY_HBM, mem_assigner->GetMemOffset()); | |||
| @@ -115,7 +116,10 @@ Status GraphMemoryAssigner::AssignMemory() { | |||
| auto variable_assigner = | |||
| std::unique_ptr<ge::VariableMemoryAssigner>(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); | |||
| if (variable_assigner == nullptr) { | |||
| GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); | |||
| GELOGE(ge::FAILED, "[New][Object:VariableMemoryAssigner]graph_id:%u, graph_name:%s", | |||
| compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| @@ -134,7 +138,10 @@ ge::Status GraphMemoryAssigner::AssignVarAttr2Nodes() { | |||
| auto variable_assigner = | |||
| std::unique_ptr<ge::VariableMemoryAssigner>(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); | |||
| if (variable_assigner == nullptr) { | |||
| GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); | |||
| GELOGE(ge::FAILED, "[New][Object:VariableMemoryAssigner]graph_id:%u, graph_name:%s", | |||
| compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| if (variable_assigner->AssignVarAttr2Nodes() != ge::SUCCESS) { | |||
| @@ -147,8 +154,10 @@ ge::Status GraphMemoryAssigner::AssignMemory2HasRefAttrNode() { | |||
| auto variable_assigner = | |||
| std::unique_ptr<ge::VariableMemoryAssigner>(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); | |||
| if (variable_assigner == nullptr) { | |||
| GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); | |||
| return ge::FAILED; | |||
| GELOGE(ge::FAILED, "[New][Object:VariableMemoryAssigner]graph_id:%u, graph_name:%s", | |||
| compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| } | |||
| if (variable_assigner->AssignMemory2HasRefAttrNode() != ge::SUCCESS) { | |||
| return ge::FAILED; | |||
| @@ -161,17 +170,18 @@ ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &out | |||
| int64_t &batch_dim_num, int64_t &out_size) { | |||
| graphStatus graph_status = ge::TensorUtils::GetSize(*output_desc, out_size); | |||
| if (graph_status != GRAPH_SUCCESS) { | |||
| GELOGE(FAILED, "Opdesc GetSize failed!"); | |||
| GELOGE(FAILED, "[Get][TensorSize]"); | |||
| REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory"); | |||
| return FAILED; | |||
| } | |||
| GeShape output_shape = output_desc->GetShape(); | |||
| std::vector<int64_t> output_dims = output_shape.GetDims(); | |||
| if (dim_index >= static_cast<int64_t>(output_dims.size())) { | |||
| std::string error = "Invaild value" + FmtToStr(dim_index) + | |||
| " of attr _reuse_input_on_dim_index, which is out of data range [0," | |||
| + std::to_string(output_dims.size()) + ")"; | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "Inner param dim_index value:%ld invalid, bigger than dim size:%lu in shape:%s", | |||
| dim_index, output_dims.size(), output_shape.ToString().c_str()); | |||
| GELOGE(FAILED, "[Check][Param:dim_index]value:%ld invalid, bigger than dim size:%lu in shape:%s", | |||
| dim_index, output_dims.size(), output_shape.ToString().c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -187,14 +197,23 @@ ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &out | |||
| graph_status = ge::TensorUtils::CalcTensorMemSize(output_shape, out_format, data_type, output_mem_size); | |||
| if (graph_status != GRAPH_SUCCESS) { | |||
| GELOGE(graph_status, "Opdesc CalcTensorMemSize failed!"); | |||
| GELOGE(graph_status, "[Calc][TensorSize]"); | |||
| return FAILED; | |||
| } | |||
| if (output_mem_size < 0) { | |||
| std::string error = "After calculating tensor memory size, output_mem_size" + FmtToStr(output_mem_size) + | |||
| " is out of data range [0," + std::to_string(INT64_MAX) + "]"; | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "After calculating, tensor memory size:%ld invalid, less than 0. " | |||
| "shape:%s, format:%s, dtype:%s, maybe has dynamic shape", | |||
| output_mem_size, | |||
| output_shape.ToString().c_str(), | |||
| TypeUtils::FormatToSerialString(out_format).c_str(), | |||
| TypeUtils::DataTypeToSerialString(data_type).c_str()); | |||
| GELOGE(FAILED, "[Check][TensorSize]value:%ld invalid after calc, less than 0. shape:%s, format:%s, dtype:%s, " | |||
| "maybe has dynamic shape", | |||
| output_mem_size, | |||
| output_shape.ToString().c_str(), | |||
| TypeUtils::FormatToSerialString(out_format).c_str(), | |||
| TypeUtils::DataTypeToSerialString(data_type).c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -203,7 +222,10 @@ ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &out | |||
| Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map<int64_t, size_t> &mem_type_to_offset) { | |||
| if (memory_offset_.empty()) { | |||
| GELOGE(FAILED, "memory_offset_ is empty."); | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ empty, not expected when ReAssignMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData:memory_offset_]empty is not expected, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| @@ -218,8 +240,10 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map<int64_t, size | |||
| auto session_id = compute_graph_->GetSessionID(); | |||
| if (total_mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) { | |||
| GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", total_mem_offset, | |||
| VarManager::Instance(session_id)->GetGraphMemoryMaxSize()); | |||
| GELOGE(ge::FAILED, "[Check][TotalMemOffset] %zu is greater than memory manager malloc max size %zu, " | |||
| "graph_id:%u, graph_name:%s, reduce your batchsize or scale your model may solve problem", | |||
| total_mem_offset, VarManager::Instance(session_id)->GetGraphMemoryMaxSize(), | |||
| compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| for (auto iter : mem_type_to_offset) { | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E19022", {"memType", "size", "item", "maxsize"}, | |||
| {std::to_string(iter.first), std::to_string(iter.second), "featuremap", | |||
| @@ -234,7 +258,13 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map<int64_t, size | |||
| Status GraphMemoryAssigner::AssignZeroCopyMemory(map<int64_t, size_t> &mem_offset, size_t &zero_mem_copy_size) { | |||
| BlockMemAssignerPtr priority_assigner = std::move(mem_assigner_->GetPriorityAssinger()); | |||
| GE_IF_BOOL_EXEC(priority_assigner == nullptr, GELOGE(FAILED, "Get priority_assigner failed."); return ge::FAILED;); | |||
| if (priority_assigner == nullptr) { | |||
| REPORT_INNER_ERROR("E19999", "InnerData priority_assigner nullptr, not expected when AssignZeroCopyMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData:priority_assigner]nullptr is invalid, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| size_t mem_offset_tmp = mem_offset[RT_MEMORY_HBM]; | |||
| @@ -254,8 +284,11 @@ Status GraphMemoryAssigner::AssignZeroCopyMemory(map<int64_t, size_t> &mem_offse | |||
| zero_mem_copy_size = mem_offset[RT_MEMORY_HBM] - mem_offset_tmp; | |||
| auto iter = memory_offset_.find(RT_MEMORY_HBM); | |||
| if (iter == memory_offset_.end()) { | |||
| std::string error = "Memory offset does not have memory type[HBM]"; | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " | |||
| "not expected when AssignZeroCopyMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| iter->second.mem_offset_ = mem_offset[RT_MEMORY_HBM]; | |||
| @@ -304,7 +337,7 @@ uint32_t GetContinuousMemoryType(const OpDescPtr &op_desc) { | |||
| } | |||
| if (continuous_type != 0) { | |||
| GELOGI("Current node %s continuous type %d.", op_desc->GetName().c_str(), continuous_type); | |||
| GELOGI("Current node %s continuous type %d", op_desc->GetName().c_str(), continuous_type); | |||
| } | |||
| return continuous_type; | |||
| } | |||
| @@ -312,8 +345,9 @@ uint32_t GetContinuousMemoryType(const OpDescPtr &op_desc) { | |||
| Status GetMemorySize(const OpDescPtr &op_desc, const ge::ConstGeTensorDescPtr &output_desc, uint32_t continuous_type, | |||
| int64_t &tensor_size, int64_t &nopadding_size) { | |||
| if ((op_desc == nullptr) || (output_desc == nullptr)) { | |||
| GELOGE(FAILED, "Input para is nullptr."); | |||
| return FAILED; | |||
| REPORT_INNER_ERROR("E19999", "InnerData param op_desc or output_desc is nullptr, " | |||
| "not expected when GetMemorySize"); | |||
| GELOGE(FAILED, "[Check][Param]op_desc or output_desc is nullptr"); | |||
| } | |||
| tensor_size = 0; | |||
| nopadding_size = 0; | |||
| @@ -322,7 +356,10 @@ Status GetMemorySize(const OpDescPtr &op_desc, const ge::ConstGeTensorDescPtr &o | |||
| int64_t attr_dim_index; | |||
| bool get_attr_dim_flag = ge::AttrUtils::GetInt(op_desc, ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX, attr_dim_index); | |||
| if (!get_attr_dim_flag) { | |||
| GELOGE(FAILED, "Get attr _reuse_input_on_dim_index failed."); | |||
| REPORT_INNER_ERROR("E19999", "Get Attr:%s failed when GetMemorySize, op_name:%s", | |||
| ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX.c_str(), op_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Get][Attr:%s]fail for op_name:%s", | |||
| ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX.c_str(), op_desc->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -330,17 +367,25 @@ Status GetMemorySize(const OpDescPtr &op_desc, const ge::ConstGeTensorDescPtr &o | |||
| int64_t batch_dim_num = 1; | |||
| if (CalculateTensorRealSizeAndOutSize(output_desc, attr_dim_index, nopadding_size, batch_dim_num, tensor_size) != | |||
| SUCCESS) { | |||
| GELOGE(FAILED, "CalculateTensorRealSizeAndOutSize failed for node %s.", op_desc->GetName().c_str()); | |||
| REPORT_CALL_ERROR("E19999", "CalculateTensorRealSizeAndOutSize failed, attr_dim_index:%ld, op_name:%s", | |||
| attr_dim_index, op_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Calculate][NopaddingSize]failed for node %s, attr_dim_index:%ld", | |||
| op_desc->GetName().c_str(), attr_dim_index); | |||
| return FAILED; | |||
| } | |||
| } else { | |||
| if (ge::TensorUtils::GetSize(*output_desc, tensor_size) != ge::SUCCESS) { | |||
| GELOGE(FAILED, "GetSize failed."); | |||
| REPORT_INNER_ERROR("E19999", "Get Tensor Size failed, op_name:%s", op_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Get][TensorSize]failed in padding case, op_name:%s", op_desc->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| } | |||
| if ((tensor_size < 0) || (nopadding_size < 0)) { | |||
| GELOGE(FAILED, "GetMemorySize for node %s failed.", op_desc->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "GetMemorySize fail, " | |||
| "tensor_size:%ld or nopadding_size:%ld less than 0, invalid, op_name:%s", | |||
| tensor_size, nopadding_size, op_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Get][MemorySize]tensor_size:%ld or nopadding_size:%ld less than 0, invalid, op_name:%s", | |||
| tensor_size, nopadding_size, op_desc->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| return SUCCESS; | |||
| @@ -374,7 +419,7 @@ bool IsContinuousInputConflict(const ge::NodePtr &node, const OpDescPtr &peer_op | |||
| // If GetBool fail, is_peer_reference is false. | |||
| (void) AttrUtils::GetBool(peer_op_desc, ATTR_NAME_REFERENCE, is_peer_reference); | |||
| GE_IF_BOOL_EXEC(is_peer_reference, | |||
| std::string warning = "Current op" + FmtToStr(node->GetOpDesc()->GetName()) + | |||
| std::string warning = "[Check][Continuous]Current op" + FmtToStr(node->GetOpDesc()->GetName()) + | |||
| " requires continuous input, while the previous op" + FmtToStr(peer_op_desc->GetName()) + | |||
| " is ref. There may be conflict between the two."; | |||
| GELOGW("%s", warning.c_str()); | |||
| @@ -404,7 +449,7 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { | |||
| if (continuous_input) { | |||
| if (AssignContinuousInputMemoryWithAtomicProcessDirectly(node, node_2_continuous_type)) { | |||
| GE_CHK_STATUS_RET(AssignContinuousInputMemoryWithAtomicProcess(node, continuous_type), | |||
| "Assign node %s continuous input memory failed.", node->GetName().c_str()) | |||
| "[Assign][Memory:Continuous:Input]fail for node:%s", node->GetName().c_str()) | |||
| } else { | |||
| nodes_stack.push_back(node); | |||
| } | |||
| @@ -413,10 +458,11 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { | |||
| int64_t memory_type = RT_MEMORY_HBM; | |||
| bool continuous_output = ((continuous_type & kTypeOutput) != 0) || ((continuous_type & kTypeOutputNoPadding) != 0); | |||
| if (continuous_output) { | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "output"), "Get node memory type failed."); | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "output"), | |||
| "[Get][MemType]fail for node:%s", node->GetName().c_str()); | |||
| ret = AssignContinuousOutputMemory(node, memory_type, continuous_type); | |||
| if (ret != ge::SUCCESS) { | |||
| GELOGE(ret, "Assign continuous output memory failed!"); | |||
| GELOGE(ret, "[Assign][Memory:Continuous:Ouput]fail for node:%s", node->GetName().c_str()); | |||
| return ret; | |||
| } | |||
| } | |||
| @@ -427,14 +473,16 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { | |||
| nodes_stack.pop_back(); | |||
| auto iter = node_2_continuous_type.find(node); | |||
| if (iter == node_2_continuous_type.end()) { | |||
| GELOGE(FAILED, "node %s has no continuous type!", node->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "Inner data error when process continuous memory alloc for node:%s, " | |||
| "but has no continuous type", node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Get][ContinuousType] find fail for node:%s", node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| GE_CHK_STATUS_RET(AssignContinuousInputMemoryWithAtomicProcess(node, iter->second, true), | |||
| "Assign node %s continuous input memory failed.", node->GetName().c_str()) | |||
| "[Assign][Memory:Continuous:Input]fail for node:%s.", node->GetName().c_str()) | |||
| } | |||
| for (auto pair : memory_offset_) { | |||
| GELOGD("After reassign continuous memory, memory type = %ld, mem_offset = %zu.", pair.first, | |||
| GELOGD("After reassign continuous memory, memory type = %ld, mem offset = %zu.", pair.first, | |||
| pair.second.mem_offset_); | |||
| } | |||
| return ge::SUCCESS; | |||
| @@ -442,11 +490,13 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { | |||
| Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, | |||
| int64_t &continuous_mem_size, int64_t memory_type, uint32_t continuous_type, bool reverse_refresh) { | |||
| GELOGI("Current node %s needs continuous input.", node->GetName().c_str()); | |||
| GELOGI("Current node %s needs continuous input", node->GetName().c_str()); | |||
| auto iter = memory_offset_.find(memory_type); | |||
| if (iter == memory_offset_.end()) { | |||
| std::string error = "Memory offset does not have memory type" + FmtToStr(memory_type); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "find memory offset fail for mem_type:%ld, " | |||
| "when assign continuous input memory for node:%s, ", memory_type, node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Find][MemOffset]fail for mem_type:%ld, when AssignContinuousInputMemory for node:%s", | |||
| memory_type, node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| // The head and tail of hcom continuous input should be added 512 | |||
| @@ -459,8 +509,9 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, | |||
| GE_CHECK_NOTNULL(op_desc); | |||
| vector<int64_t> output_list_this = op_desc->GetOutputOffset(); | |||
| if (output_list_this.empty()) { | |||
| std::string error = "node:" + FmtToStr(op_desc->GetName()) + "has no output offset"; | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "No output offset in node :%s, not expected when assign continuous input memory", | |||
| node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Get][OutputOffset] empty is invalid, node:%s", node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| (void) ge::AttrUtils::GetBool(op_desc, ATTR_NAME_CONTINUOUS_INPUT_ALLOC, is_continuous_input_allocated); | |||
| @@ -480,8 +531,9 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, | |||
| lx_fusion = lx_fusion && !offsets_of_fusion.empty(); | |||
| if (lx_fusion) { | |||
| if (peer_out_data_anchor->GetIdx() >= static_cast<int>(offsets_of_fusion.size())) { | |||
| std::string error = "fusion: peer node" + FmtToStr(peer_op_desc->GetName()) + | |||
| " index" + FmtToStr(peer_out_data_anchor->GetIdx()) + " is out of range."; | |||
| std::string error = "fusion: peer node:" + FmtToStr(peer_op_desc->GetName()) + | |||
| " anchor_index:" + FmtToStr(peer_out_data_anchor->GetIdx()) + | |||
| " is out of range:" + FmtToStr(offsets_of_fusion.size()); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -497,7 +549,9 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, | |||
| bool is_nopadding = ((continuous_type & kTypeInputNoPadding) != 0) || lx_fusion; | |||
| vector<int64_t> output_list = peer_op_desc->GetOutputOffset(); | |||
| if (peer_out_data_anchor->GetIdx() >= static_cast<int>(output_list.size())) { | |||
| std::string error = "index" + FmtToStr(peer_out_data_anchor->GetIdx()) + " is out of range."; | |||
| std::string error = "peer node:" + FmtToStr(peer_op_desc->GetName()) + | |||
| " anchor_index:" + FmtToStr(peer_out_data_anchor->GetIdx()) + | |||
| " is out of range:" + FmtToStr(output_list.size()); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -506,13 +560,13 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, | |||
| bool is_allocated_first_input = is_continuous_input_allocated && (in_data_anchor->GetIdx() == 0); | |||
| if (is_allocated_first_input) { | |||
| std::map<int32_t, int32_t> out2ins; | |||
| GE_CHK_STATUS_RET(GetAllRef(node, out2ins), "Node: %s get all ref failed", node->GetName().c_str()); | |||
| GE_CHK_STATUS_RET(GetAllRef(node, out2ins), "[Get][AllRef]fail for node: %s", node->GetName().c_str()); | |||
| // output is beginning offset, set offset for input; only support this case now | |||
| if ((out2ins.size() == 1) && (out2ins.begin()->second == 0) && (reverse_refresh)) { | |||
| auto peer_output_offset = output_list.at(peer_out_data_anchor->GetIdx()); | |||
| output_list.at(peer_out_data_anchor->GetIdx()) = output_list_this.at(out2ins.begin()->first); | |||
| peer_op_desc->SetOutputOffset(output_list); | |||
| GELOGI("Node %s out %d ref in %d input node %s, use output offset %ld update %ld.", node->GetName().c_str(), | |||
| GELOGI("Node %s out %d ref in %d input node %s, use output offset %ld update %ld", node->GetName().c_str(), | |||
| out2ins.begin()->first, out2ins.begin()->second, peer_op_desc->GetName().c_str(), | |||
| output_list_this.at(out2ins.begin()->first), peer_output_offset); | |||
| } else { | |||
| @@ -542,7 +596,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, | |||
| } | |||
| GELOGI("[IMAS]Continuous input : Set %s name[%s] optype[%s] output[%d] offset to [%zu] stream_id[%ld] memtype[%ld] " | |||
| "size[%zu] realsize[%ld] nopadding size[%d].", node->GetOwnerComputeGraph()->GetName().c_str(), | |||
| "size[%zu] realsize[%ld] nopadding size[%d]", node->GetOwnerComputeGraph()->GetName().c_str(), | |||
| peer_op_desc->GetName().c_str(), node->GetType().c_str(), peer_out_data_anchor->GetIdx(), | |||
| output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), memory_type, | |||
| is_continuous_input_allocated ? 0UL : align_size, real_size, is_nopadding); | |||
| @@ -563,17 +617,32 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, | |||
| Status GetFirstInputPeerOutOutputOffset(const ge::NodePtr &node, int64_t &mem_offset) { | |||
| auto in_data_anchor_list = node->GetAllInDataAnchors(); | |||
| if (in_data_anchor_list.empty()) { | |||
| GELOGE(FAILED, "Node %s's in data anchor is empty.", node->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "InAnchor list empty in node:%s, not expect when GetFirstInputPeerOutOutputOffset", | |||
| node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Get][InAnchor]empty is invalid, node:%s", node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| auto peer_out_data_anchor = in_data_anchor_list.at(0)->GetPeerOutAnchor(); | |||
| GE_IF_BOOL_EXEC(peer_out_data_anchor == nullptr, GELOGE(ge::FAILED, "peer_out_data_anchor is null."); | |||
| GE_IF_BOOL_EXEC(peer_out_data_anchor == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "PeerAcnhor is null, " | |||
| "not expect when GetFirstInputPeerOutOutputOffset for node:%s", | |||
| node->GetName().c_str()); | |||
| GELOGE(ge::FAILED, "[Check][PeerAnchor]null is invalid, node:%s", node->GetName().c_str()); | |||
| return ge::FAILED); | |||
| auto peer_op_desc = peer_out_data_anchor->GetOwnerNode()->GetOpDesc(); | |||
| GE_IF_BOOL_EXEC(peer_op_desc == nullptr, GELOGE(ge::FAILED, "peer_op_desc is null."); return ge::FAILED); | |||
| GE_IF_BOOL_EXEC(peer_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "PeerOpDesc is null, " | |||
| "not expect when GetFirstInputPeerOutOutputOffset for node:%s", | |||
| node->GetName().c_str()); | |||
| GELOGE(ge::FAILED, "[Check][PeerOpDesc]null is invalid, node:%s", node->GetName().c_str()); | |||
| return ge::FAILED); | |||
| vector<int64_t> in_node_output_offsets = peer_op_desc->GetOutputOffset(); | |||
| if (peer_out_data_anchor->GetIdx() >= static_cast<int>(in_node_output_offsets.size())) { | |||
| GELOGE(FAILED, "Index : %d is out of range.", peer_out_data_anchor->GetIdx()); | |||
| REPORT_INNER_ERROR("E19999", "PeerAnchorIndex:%d bigger than in_offset size:%lu, " | |||
| "judge invalid when GetFirstInputPeerOutOutputOffset for node:%s", | |||
| peer_out_data_anchor->GetIdx(), in_node_output_offsets.size(), node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][Index:PeerOutDataAnchor]PeerIndex:%d bigger than in_offset size:%lu, node:%s", | |||
| peer_out_data_anchor->GetIdx(), in_node_output_offsets.size(), node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| mem_offset = in_node_output_offsets.at(peer_out_data_anchor->GetIdx()); | |||
| @@ -584,11 +653,18 @@ Status GraphMemoryAssigner::AssignContinuousOutputMemory(const ge::NodePtr &node | |||
| uint32_t continuous_type) { | |||
| GELOGI("Current node %s needs continuous output.", node->GetName().c_str()); | |||
| auto out_op_desc = node->GetOpDesc(); | |||
| GE_IF_BOOL_EXEC(out_op_desc == nullptr, GELOGE(ge::FAILED, "out_op_desc is null."); return ge::FAILED); | |||
| GE_IF_BOOL_EXEC(out_op_desc == nullptr, | |||
| REPORT_INNER_ERROR("E19999", "OpDesc is null, " | |||
| "not expect when AssignContinuousOutputMemory for node:%s", | |||
| node->GetName().c_str()); | |||
| GELOGE(ge::FAILED, "[Check][OpDesc]null is invalid, node:%s", node->GetName().c_str())); | |||
| vector<int64_t> output_list = out_op_desc->GetOutputOffset(); | |||
| if ((out_op_desc->GetOutputsSize() > output_list.size()) || (output_list.size() == 0)) { | |||
| GELOGE(ge::FAILED, "The size %zu of node output desc is more than output_list's size %zu.", | |||
| out_op_desc->GetOutputsSize(), output_list.size()); | |||
| REPORT_INNER_ERROR("E19999", "Output size:%zu more than output offset size:%zu, invalid in node:%s, " | |||
| "when AssignContinuousOutputMemory", | |||
| out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); | |||
| GELOGE(ge::FAILED, "[Check][InnerData]Output size:%zu more than output offset size:%zu, invalid in node:%s", | |||
| out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| @@ -647,14 +723,18 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { | |||
| map<string, vector<NodePtr>> connecting_output_atomic_nodes; | |||
| Status status = FilterAtomicNodesForMemoryAssign(normal_atomic_and_clean_nodes_map, connecting_output_atomic_nodes); | |||
| if (status != SUCCESS) { | |||
| GELOGE(status, "Failed to filter atomic nodes for memory assignment."); | |||
| GELOGE(status, "[Filter][AtomicNode]failed in graph_id:%u, graph_name:%s", | |||
| compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return status; | |||
| } | |||
| auto mem_iter = memory_offset_.find(RT_MEMORY_HBM); | |||
| if (mem_iter == memory_offset_.end()) { | |||
| std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " | |||
| "not expected when ReAssignAtomicMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -670,7 +750,7 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { | |||
| vector<int64_t> mem_offset_end; | |||
| status = AssignAtomicOutputAndWorkspaceMemory(atomic_node, mem_offset_end); | |||
| if (status != SUCCESS) { | |||
| GELOGE(status, "Assign atomic output and workspace memory failed, node name is %s.", | |||
| GELOGE(status, "[Assign][Memory]output atomic mem and workspace mem, fail for node name is %s.", | |||
| atomic_node->GetName().c_str()); | |||
| return status; | |||
| } | |||
| @@ -679,7 +759,7 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { | |||
| int64_t atomic_mem_size = static_cast<int64_t>(mem_iter->second.mem_offset_) - atomic_mem_start; | |||
| if (atomic_mem_size != 0) { | |||
| GE_CHK_STATUS_RET(SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size}, RT_MEMORY_HBM), | |||
| "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str()); | |||
| "[Set][Attr]fail for atomic addr clean node %s.", iter.first->GetName().c_str()); | |||
| } | |||
| } | |||
| batch_max_mem_offset = std::max(batch_max_mem_offset, static_cast<int64_t>(mem_iter->second.mem_offset_)); | |||
| @@ -690,7 +770,8 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { | |||
| for (auto &iter_batch : connecting_output_atomic_nodes) { | |||
| mem_iter->second.mem_offset_ = batch_atomic_mem_start; | |||
| if (AssignConnectNetOutputAtomicMemory(iter_batch.second) != SUCCESS) { | |||
| GELOGE(FAILED, "Failed to assign memory of nodes that connect to netoutput."); | |||
| GELOGE(FAILED, "[Assign][Memory]for nodes that connect to netoutput failed." | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| batch_max_mem_offset = std::max(batch_max_mem_offset, static_cast<int64_t>(mem_iter->second.mem_offset_)); | |||
| @@ -721,9 +802,10 @@ Status GraphMemoryAssigner::FilterAtomicNodesForMemoryAssign( | |||
| // If GetBool fail, is_reference is false. | |||
| (void) ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_REFERENCE, is_reference); | |||
| if (is_reference) { | |||
| std::string error = "Op" + FmtToStr(peer_in_node_desc->GetName()) + | |||
| " cannot have both atomic and is_reference attribute."; | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "Op:%s cannot have both atomic and is_reference attribute, " | |||
| "not support now", peer_in_node_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][Attr]Op:%s cannot have both atomic and is_reference attribute, " | |||
| "not support now", peer_in_node_desc->GetName().c_str()); | |||
| return ge::PARAM_INVALID; | |||
| } | |||
| @@ -761,7 +843,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP | |||
| // Assign atomic node output memory | |||
| Status ret = AssignAtomicOutputMemory(node, mem_offset_end); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(ret, "Failed to assign atomic output memory, node is %s.", node_op_desc->GetName().c_str()); | |||
| GELOGE(ret, "[Assign][Memory:Ouput:Atomic]Failed for node:%s.", node_op_desc->GetName().c_str()); | |||
| return ret; | |||
| } | |||
| @@ -781,7 +863,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP | |||
| ret = AssignOrdinaryAtomicWorkspaceMemory(node_op_desc, atomic_workspace_info, mem_offset_end); | |||
| } | |||
| if (ret != SUCCESS) { | |||
| GELOGE(ret, "Assign atomic workspace memory failed, node is %s.", node_op_desc->GetName().c_str()); | |||
| GELOGE(ret, "[Assign][Memory:Atomic:Workspace]fail for node:%s.", node_op_desc->GetName().c_str()); | |||
| return ret; | |||
| } | |||
| } else { | |||
| @@ -794,8 +876,11 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP | |||
| Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector<NodePtr> &connect_netoutput_nodes) { | |||
| auto iter = memory_offset_.find(RT_MEMORY_HBM); | |||
| if (iter == memory_offset_.end()) { | |||
| std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " | |||
| "not expected when AssignConnectNetOutputAtomicMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| for (auto &node : connect_netoutput_nodes) { | |||
| @@ -811,13 +896,14 @@ Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector<NodePtr> & | |||
| node->GetName().c_str(), node->GetOpDesc()->GetType().c_str(), original_atomic_mem_start); | |||
| vector<int64_t> mem_offset_end; | |||
| if (AssignAtomicOutputAndWorkspaceMemory(node, mem_offset_end) != SUCCESS) { | |||
| GELOGE(FAILED, "Assign atomic output and workspace memory failed, node is %s.", node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Assign][Memory]output atomic mem and workspace mem, fail for node name is %s.", | |||
| node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| // All atomic nodes use atomic_addr_clean op independently, so we need to set the attr separately. | |||
| if (SetIndependentAtomicAttr(node, original_atomic_mem_start, mem_offset_end, RT_MEMORY_HBM) != SUCCESS) { | |||
| GELOGE(FAILED, "Failed to set atomic attr separately."); | |||
| GELOGE(FAILED, "[Set][Attr:IndependentAtomic]fail for node:%s", node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| } | |||
| @@ -842,8 +928,11 @@ Status GraphMemoryAssigner::AssignReferenceMemory() { | |||
| vector<int64_t> output_list = out_op_desc->GetOutputOffset(); | |||
| if (out_op_desc->GetOutputsSize() > output_list.size()) { | |||
| GELOGE(ge::FAILED, "The size %zu of node output desc is more than output_list's size %zu.", | |||
| out_op_desc->GetOutputsSize(), output_list.size()); | |||
| REPORT_INNER_ERROR("E19999", "Output size:%zu more than output offset size:%zu, judge invalid in node:%s " | |||
| "when AssignReferenceMemory", | |||
| out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); | |||
| GELOGE(ge::FAILED, "[Check][InnerData]Output size:%zu more than output offset size:%zu, invalid in node:%s", | |||
| out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| @@ -896,9 +985,12 @@ bool GraphMemoryAssigner::CheckInputIsSupportAtomic(const ge::NodePtr &node) { | |||
| } | |||
| if ((peer_op_desc->GetType() == CONSTANTOP) || (peer_op_desc->GetType() == AIPP_DATA_TYPE) || | |||
| (peer_op_desc->GetType() == VARIABLE)) { | |||
| std::string error = "Op" + FmtToStr(node->GetName()) + "'s peer out node" + | |||
| FmtToStr(peer_op_desc->GetName()) + " is invalid, Constant/AippData/Variable is not supported"; | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "node(type:%s, name:%s) link to atomic node(name:%s), " | |||
| "this situation not supported now", | |||
| peer_op_desc->GetType().c_str(), peer_op_desc->GetName().c_str(), node->GetName().c_str()); | |||
| GELOGE(ge::FAILED, "[Check][Link]node(type:%s, name:%s) link to atomic node(name:%s), " | |||
| "this situation not supported now", | |||
| peer_op_desc->GetType().c_str(), peer_op_desc->GetName().c_str(), node->GetName().c_str()); | |||
| return false; | |||
| } | |||
| } | |||
| @@ -918,22 +1010,27 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve | |||
| // Check atomic output | |||
| vector<int64_t> output_list = op_desc->GetOutputOffset(); | |||
| if (atomic_output_index.size() > output_list.size()) { | |||
| std::string error = "Op" + FmtToStr(node->GetName()) + | |||
| "'s size of atomic_output_index is more than the size of output_list"; | |||
| std::string error = | |||
| "Op:" + FmtToStr(node->GetName()) + "'s size:" + FmtToStr(atomic_output_index.size()) + | |||
| " of atomic_output_index is more than the size:" + FmtToStr(output_list.size()) + " of output_list"; | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| auto output_list_size = static_cast<int64_t>(output_list.size()); | |||
| auto iter = memory_offset_.find(RT_MEMORY_HBM); | |||
| if (iter == memory_offset_.end()) { | |||
| std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " | |||
| "not expected when AssignAtomicOutputMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| for (auto &output_index : atomic_output_index) { | |||
| if (output_index >= output_list_size) { | |||
| std::string error = "Op" + FmtToStr(node->GetName()) + "'s output index" + FmtToStr(output_index) + | |||
| " is more than the size" + FmtToStr(output_list_size) + " of output_list."; | |||
| std::string error = | |||
| "Op:" + FmtToStr(node->GetName()) + "'s atomic_output index:" + FmtToStr(output_index) + | |||
| " is more than the size:" + FmtToStr(output_list_size) + " of output_list."; | |||
| GE_ERRORLOG_AND_ERRORMSG(ge::PARAM_INVALID, error.c_str()); | |||
| return ge::PARAM_INVALID; | |||
| } | |||
| @@ -941,7 +1038,8 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve | |||
| // If the input of the cascade op needs to clear the atomic addr, there is no need to clear it separately here | |||
| bool is_assigned_mem = false; | |||
| if (GetMemoryAssignmentStatus(node, output_index, is_assigned_mem) != SUCCESS) { | |||
| GELOGE(ge::FAILED, "Failed to get memory assignment of node %s.", node->GetName().c_str()); | |||
| GELOGE(ge::FAILED, "[Get][MemoryAssignmentStatus]fail for node %s, out_index:%ld", | |||
| node->GetName().c_str(), output_index); | |||
| return ge::FAILED; | |||
| } | |||
| @@ -981,8 +1079,9 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve | |||
| Status GraphMemoryAssigner::GetMemoryAssignmentStatus(const ge::NodePtr &node, int64_t output_index, | |||
| bool &is_mem_assigned) { | |||
| if (static_cast<size_t>(output_index) >= node->GetAllOutDataAnchors().size()) { | |||
| std::string error = "Op" + FmtToStr(node->GetName()) + "'s output index" + FmtToStr(output_index) + | |||
| " is more than the size of node's AllOutDataAnchors."; | |||
| std::string error = | |||
| "Op:" + FmtToStr(node->GetName()) + "'s output index:" + FmtToStr(output_index) + | |||
| " is more than the size:" + FmtToStr(node->GetAllOutDataAnchors().size()) + " of node's AllOutDataAnchors."; | |||
| GE_ERRORLOG_AND_ERRORMSG(ge::PARAM_INVALID, error.c_str()); | |||
| return ge::PARAM_INVALID; | |||
| } | |||
| @@ -1010,8 +1109,11 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc | |||
| GELOGI("Begin to reassign normal atomic memory, node = %s.", op_desc->GetName().c_str()); | |||
| auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); | |||
| if (mem_type_iter == memory_offset_.end()) { | |||
| std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " | |||
| "not expected when AssignOrdinaryAtomicWorkspaceMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| vector<int64_t> workspace_vector = op_desc->GetWorkspace(); | |||
| @@ -1032,8 +1134,9 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc | |||
| auto workspace_index = static_cast<uint64_t>(info_iter.first); | |||
| auto workspace_size = info_iter.second; | |||
| if (workspace_index >= workspace_vector.size()) { | |||
| std::string error = "The workspace index" + FmtToStr(workspace_index) + | |||
| " is more than the size" + FmtToStr(workspace_vector.size()) + " of workspace vector."; | |||
| std::string error = "The workspace index:" + FmtToStr(workspace_index) + | |||
| " is more than the size:" + FmtToStr(workspace_vector.size()) + " of workspace vector in op:" + | |||
| op_desc->GetName().c_str(); | |||
| GE_ERRORLOG_AND_ERRORMSG(ge::PARAM_INVALID, error.c_str()); | |||
| return ge::PARAM_INVALID; | |||
| } | |||
| @@ -1063,8 +1166,11 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt | |||
| GELOGI("Begin to reassign fusion atomic memory, node = %s.", op_desc->GetName().c_str()); | |||
| auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); | |||
| if (mem_type_iter == memory_offset_.end()) { | |||
| std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " | |||
| "not expected when AssignFusionAtomicWorkspaceMemory, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| map<string, map<int64_t, int64_t>> sub_node_workspace_offset; | |||
| @@ -1095,7 +1201,10 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt | |||
| sub_node_workspace_offset.insert(std::make_pair(iter.first, index_offset)); | |||
| } | |||
| if (!(op_desc->SetExtAttr(EXT_ATTR_ATOMIC_WORKSPACE_OFFSET, sub_node_workspace_offset))) { | |||
| GELOGE(FAILED, "Set EXT_ATTR_ATOMIC_WORKSPACE_OFFSET failed, op name:%s.", op_desc->GetName().c_str()); | |||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for node:%s when AssignFusionAtomicWorkspaceMemory", | |||
| EXT_ATTR_ATOMIC_WORKSPACE_OFFSET.c_str(), op_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Set][Attr:%s]fail for node:%s.", | |||
| EXT_ATTR_ATOMIC_WORKSPACE_OFFSET.c_str(), op_desc->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -1106,7 +1215,7 @@ Status GraphMemoryAssigner::CheckOffset() { | |||
| std::map<std::string, std::string> anchor_to_symbol; | |||
| std::map<std::string, std::list<NodeIndexIO>> symbol_to_anchors; | |||
| if (GraphUtils::GetRefMapping(compute_graph_, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { | |||
| GELOGE(FAILED, "Get ref-mapping for graph %s failed.", compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Get][RefMapping]fail for graph %s", compute_graph_->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) { | |||
| @@ -1148,7 +1257,6 @@ Status GraphMemoryAssigner::CheckOffset() { | |||
| std::string error = "Invalid workspace" + FmtToStr(ge::kInvalidOffset) + | |||
| + " in node" + FmtToStr(node->GetName()); | |||
| GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); | |||
| GELOGE(FAILED, "Invalid workspace in node: %s workspace: %ld.", node->GetName().c_str(), ge::kInvalidOffset); | |||
| return FAILED; | |||
| } | |||
| } | |||
| @@ -1158,8 +1266,10 @@ Status GraphMemoryAssigner::CheckOffset() { | |||
| ge::Status GraphMemoryAssigner::SetInputOffset() { | |||
| if (memory_offset_.empty()) { | |||
| GELOGE(FAILED, "memory_offset_ is empty."); | |||
| return FAILED; | |||
| REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ empty, not expected when SetInputOffset, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][InnerData:memory_offset_]empty is not expected, " | |||
| "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | |||
| } | |||
| for (auto pair : memory_offset_) { | |||
| GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu], memtype[%ld]", compute_graph_->GetName().c_str(), | |||
| @@ -1168,7 +1278,7 @@ ge::Status GraphMemoryAssigner::SetInputOffset() { | |||
| for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) { | |||
| if (UpdateOpInputOffset(node) != ge::SUCCESS) { | |||
| GELOGE(ge::FAILED, "Update op input offset failed"); | |||
| GELOGE(ge::FAILED, "[Update][Offset:Input]fail for op:%s", node->GetName().c_str()); | |||
| return ge::FAILED; | |||
| } | |||
| } | |||
| @@ -1316,12 +1426,12 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node) const { | |||
| } | |||
| } else if (node->GetType() == DATA_TYPE) { | |||
| if (UpdateConstArgsOffset(node, input_list) != SUCCESS) { | |||
| GELOGE(FAILED, "Update data: %s args offset failed.", node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Update][Offset:Input:Const]fail for node:%s ", node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| } else { | |||
| if (UpdateOpInputOffset(node, input_list) != SUCCESS) { | |||
| GELOGE(FAILED, "Update node: %s input offset failed.", node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Update][Offset:Input]fail for node:%s", node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| } | |||
| @@ -1361,7 +1471,7 @@ Status GraphMemoryAssigner::SetIndependentAtomicAttr(const ge::NodePtr &node, in | |||
| peer_out_node_desc->GetName().c_str(), peer_out_node_desc->GetType().c_str()); | |||
| if (peer_out_node_desc->GetType() == ATOMICADDRCLEAN) { | |||
| if (SetAtomicCleanAttr(peer_out_node, memory_offset_start, memory_offset_size, memory_type) != SUCCESS) { | |||
| GELOGE(FAILED, "Set atomic clean attr failed."); | |||
| GELOGE(FAILED, "[Set][AtomicCleanAttr]fail for node:%s", peer_out_node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| } | |||
| @@ -1387,7 +1497,10 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve | |||
| (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector); | |||
| mem_start_vector.insert(mem_start_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end()); | |||
| GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector), | |||
| GELOGE(FAILED, "SetListInt failed."); | |||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s failed when SetAtomicCleanAttr, op_name:%s", | |||
| ATTR_NAME_AUTOMIC_ADD_START.c_str(), node_op_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Set][Attr:%s]fail for op_name:%s", | |||
| ATTR_NAME_AUTOMIC_ADD_START.c_str(), node_op_desc->GetName().c_str()); | |||
| return FAILED); | |||
| std::vector<int64_t> mem_size_vector; | |||
| @@ -1395,7 +1508,10 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve | |||
| (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector); | |||
| mem_size_vector.insert(mem_size_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end()); | |||
| GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector), | |||
| GELOGE(FAILED, "SetListInt failed."); | |||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s failed when SetAtomicCleanAttr, op_name:%s", | |||
| ATTR_NAME_AUTOMIC_ADD_MEM_SIZE.c_str(), node_op_desc->GetName().c_str()); | |||
| GELOGE(FAILED, "[Set][Attr:%s]fail for op_name:%s", | |||
| ATTR_NAME_AUTOMIC_ADD_MEM_SIZE.c_str(), node_op_desc->GetName().c_str()); | |||
| return FAILED); | |||
| std::stringstream ss; | |||
| @@ -1437,12 +1553,14 @@ ge::Status GraphMemoryAssigner::GetNodeListMemoryType(const vector<NodePtr> &nod | |||
| // In the dynamic batch scenario, the memory attributes of nodes are the same. | |||
| for (auto &n : nodes) { | |||
| if (mem_reuse_model == kVirtualInputNodeMemoryReuse) { | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), "Get node memory type failed.") | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), | |||
| "[Get][MemType:input]fail for node:%s", n->GetName().c_str()) | |||
| break; | |||
| } | |||
| if (mem_reuse_model == kVirtualOutputNodeMemoryReuse) { | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), "Get node memory type failed."); | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), | |||
| "[Get][MemType:output]fail for node:%s", n->GetName().c_str()) | |||
| break; | |||
| } | |||
| } | |||
| @@ -1478,7 +1596,7 @@ ge::Status GraphMemoryAssigner::GetNodeMemoryType(const NodePtr &node, int64_t & | |||
| } | |||
| if (!CheckContinuousMemType(mem_type_list)) { | |||
| GELOGE(FAILED, "Check continuous memory type failed."); | |||
| GELOGE(FAILED, "[Check][MemType:Continuous]fail for node:%s", node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| // It is continuous memory and memory type is the same, so use the first memory. | |||
| @@ -1526,7 +1644,11 @@ ge::Status GraphMemoryAssigner::GetAllRef(const NodePtr &node, map<int32_t, int3 | |||
| if (node->GetInDataAnchor(reuse_in_index) != nullptr) { | |||
| out2ins.emplace(out_data_anchor->GetIdx(), reuse_in_index); | |||
| } else { | |||
| GELOGE(FAILED, "Invalid reuse_input value %d on output %d of node %s, please check attr reuse_input", | |||
| REPORT_INNER_ERROR("E19999", "Invalid reuse_input value %d on output %d of node %s, " | |||
| "please check attr reuse_input", | |||
| reuse_in_index, out_data_anchor->GetIdx(), node->GetName().c_str()); | |||
| GELOGE(FAILED, "[Check][Attr]Invalid reuse_input value %d on output %d of node %s, " | |||
| "please check attr reuse_input", | |||
| reuse_in_index, out_data_anchor->GetIdx(), node->GetName().c_str()); | |||
| return FAILED; | |||
| } | |||
| @@ -1549,7 +1671,7 @@ bool GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcessDirectly( | |||
| auto continuous_type = iter->second; | |||
| bool continuous_input = ((continuous_type & kTypeInput) != 0) || ((continuous_type & kTypeInputNoPadding) != 0); | |||
| if (continuous_input) { | |||
| GELOGI("Node %s 's precursor node %s need assign continuous input memory, store node firstly.", | |||
| GELOGI("Node %s 's precursor node %s need assign continuous input memory, store node firstly", | |||
| input_continuous_node->GetName().c_str(), in_node->GetName().c_str()); | |||
| return false; | |||
| } | |||
| @@ -1559,7 +1681,7 @@ bool GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcessDirectly( | |||
| node_2_continuous_type.emplace(out_node, continuous_type); | |||
| bool continuous_input = ((continuous_type & kTypeInput) != 0) || ((continuous_type & kTypeInputNoPadding) != 0); | |||
| if (continuous_input) { | |||
| GELOGI("Node %s 's succeed node %s need assign continuous input memory, store node firstly.", | |||
| GELOGI("Node %s 's succeed node %s need assign continuous input memory, store node firstly", | |||
| input_continuous_node->GetName().c_str(), out_node->GetName().c_str()); | |||
| return false; | |||
| } | |||
| @@ -1575,11 +1697,12 @@ ge::Status GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcess(con | |||
| int64_t mem_clean_size = 0; | |||
| int64_t memory_type = RT_MEMORY_HBM; | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(input_continuous_node, memory_type, "input"), "Get node memory type failed."); | |||
| GE_CHK_STATUS_RET(GetNodeMemoryType(input_continuous_node, memory_type, "input"), | |||
| "[Get][MemType]fail for node:%s", input_continuous_node->GetName().c_str()); | |||
| auto ret = AssignContinuousInputMemory(input_continuous_node, mem_clean_start, mem_clean_size, memory_type, | |||
| continuous_type, reverse_refresh); | |||
| if (ret != ge::SUCCESS) { | |||
| GELOGE(ret, "Assign continuous input memory failed!"); | |||
| GELOGE(ret, "[Assign][Memory:Input:continuous]fail for node:%s", input_continuous_node->GetName().c_str()); | |||
| return ret; | |||
| } | |||
| @@ -1590,7 +1713,6 @@ ge::Status GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcess(con | |||
| if (!input_indexes.empty() && input_indexes[0] == kAllInputAddrIsAtomic) { | |||
| // check whether there is an atomic conflict between the current node and the peer out node | |||
| if (!CheckInputIsSupportAtomic(input_continuous_node)) { | |||
| GELOGE(ge::FAILED, "There is an atomic conflict between the current node and the peer out node, not supported!"); | |||
| return ge::FAILED; | |||
| } | |||
| @@ -1602,7 +1724,7 @@ ge::Status GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcess(con | |||
| if (peer_out_node->GetType() == ATOMICADDRCLEAN) { | |||
| ret = SetAtomicCleanAttr(peer_out_node, {mem_clean_start}, {mem_clean_size}, memory_type); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(ret, "Failed to set attr for atomic addr clean node %s.", peer_out_node->GetName().c_str()); | |||
| GELOGE(ret, "[Set][AtomicCleanAttr]fail for node:%s", peer_out_node->GetName().c_str()); | |||
| return ret; | |||
| } | |||
| } | |||
| @@ -31,6 +31,7 @@ | |||
| #include "common/scope_guard.h" | |||
| #include "common/thread_pool.h" | |||
| #include "framework/common/debug/ge_log.h" | |||
| #include "framework/common/util.h" | |||
| #include "graph/common/ge_call_wrapper.h" | |||
| #include "graph/compute_graph.h" | |||
| #include "graph/debug/ge_attr_define.h" | |||
| @@ -297,6 +298,11 @@ void DavinciModel::ReleaseTask() { | |||
| GE_CHK_STATUS(task->Release(), "Release task failed."); | |||
| } | |||
| } | |||
| for (auto &item : label_goto_args_) { | |||
| GE_FREE_RT_LOG(item.second.first); | |||
| } | |||
| label_goto_args_.clear(); | |||
| } | |||
| Status DavinciModel::Assign(const GeModelPtr &ge_model) { | |||
| @@ -1334,6 +1340,39 @@ void DavinciModel::ParseDynamicOutShape(const std::vector<std::string> &str_info | |||
| } | |||
| } | |||
| Status DavinciModel::GetLabelGotoAddr(uint32_t label_index, rtMemType_t mem_type, void *&arg_addr, uint32_t &arg_size) { | |||
| std::lock_guard<std::mutex> lock(label_args_mutex_); | |||
| auto it = label_goto_args_.find(label_index); | |||
| if (it != label_goto_args_.end()) { | |||
| arg_addr = it->second.first; | |||
| arg_size = it->second.second; | |||
| return SUCCESS; | |||
| } | |||
| if (label_index >= label_list_.size()) { | |||
| GELOGE(INTERNAL_ERROR, "Invalid label id:%u, label size:%zu", label_index, label_list_.size()); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| GE_CHECK_NOTNULL(label_list_[label_index]); | |||
| vector<rtLabel_t> label_used = { label_list_[label_index] }; | |||
| arg_size = label_used.size() * sizeof(rtLabelDevInfo); | |||
| rtError_t rt_ret = rtMalloc(&arg_addr, arg_size, mem_type); | |||
| if (rt_ret != RT_ERROR_NONE) { | |||
| GELOGE(RT_FAILED, "Call rtMalloc failed, error: %#x", rt_ret); | |||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||
| } | |||
| label_goto_args_[label_index] = { arg_addr, arg_size }; | |||
| rt_ret = rtLabelListCpy(label_used.data(), label_used.size(), arg_addr, arg_size); | |||
| if (rt_ret != RT_ERROR_NONE) { | |||
| GELOGE(RT_FAILED, "Call rtLabelListCpy failed, error: %#x", rt_ret); | |||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||
| } | |||
| return SUCCESS; | |||
| } | |||
| /// @ingroup ge | |||
| /// @brief LabelSet Op Initialize. | |||
| /// @param [in] op_desc: LabelSet Op descriptor. | |||
| @@ -3835,7 +3874,7 @@ Status DavinciModel::TransAllVarData(ComputeGraphPtr &graph, uint32_t graph_id) | |||
| } | |||
| std::vector<NodePtr> variable_node_list; | |||
| for (ge::NodePtr &node : graph->GetDirectNode()) { | |||
| for (ge::NodePtr &node : graph->GetAllNodes()) { | |||
| if (node == nullptr) { | |||
| continue; | |||
| } | |||
| @@ -273,6 +273,8 @@ class DavinciModel { | |||
| const vector<rtLabel_t> &GetLabelList() const { return label_list_; } | |||
| Status GetLabelGotoAddr(uint32_t label_index, rtMemType_t memory_type, void *&addr, uint32_t &size); | |||
| Status DestroyThread(); | |||
| // get Op | |||
| @@ -930,6 +932,9 @@ class DavinciModel { | |||
| vector<rtLabel_t> label_list_; | |||
| set<uint32_t> label_id_indication_; | |||
| mutex label_args_mutex_; | |||
| map<uint32_t, pair<void *, uint32_t>> label_goto_args_; | |||
| mutex outside_addrs_mutex_; | |||
| vector<ZeroCopyTask> zero_copy_tasks_; // Task used Data or NetOutput addr. | |||
| set<const void *> copy_only_addrs_; // Address need copy to original place. | |||
| @@ -297,12 +297,11 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptr<ge::Ge | |||
| if (model_id == INVALID_MODEL_ID) { | |||
| GenModelId(&model_id); | |||
| } | |||
| bool is_shape_unknown = false; | |||
| auto name_to_model = ge_root_model->GetSubgraphInstanceNameToModel(); | |||
| string model_name = ""; | |||
| GE_CHK_STATUS_RET(ge_root_model->CheckIsUnknownShape(is_shape_unknown), "CheckIsUnknownShape failed, model id:%u", | |||
| model_id); | |||
| if (is_shape_unknown || GetContext().GetHostExecFlag()) { | |||
| bool is_shape_unknown = ge_root_model->GetRootGraph()->GetGraphUnknownFlag(); | |||
| // if multi subgraph is known, do hybrid load process | |||
| if (is_shape_unknown || GetContext().GetHostExecFlag() || (name_to_model.size() > 1)) { | |||
| return DoLoadHybridModelOnline(model_id, model_name, ge_root_model, listener); | |||
| } | |||
| @@ -324,7 +323,6 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptr<ge::Ge | |||
| auto root_graph = ge_root_model->GetRootGraph(); | |||
| GE_CHECK_NOTNULL(root_graph); | |||
| string root_model_name = root_graph->GetName(); | |||
| auto name_to_model = ge_root_model->GetSubgraphInstanceNameToModel(); | |||
| GeModelPtr ge_model = name_to_model[root_model_name]; | |||
| Status ret = SUCCESS; | |||
| do { | |||
| @@ -384,7 +384,8 @@ Status ModelUtils::GetVarAddr(const RuntimeParam &model_param, const ConstOpDesc | |||
| switch (mem_type) { | |||
| case RT_MEMORY_RDMA_HBM: | |||
| 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; | |||
| } | |||
| var_addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset)); | |||
| @@ -22,7 +22,7 @@ namespace ge { | |||
| constexpr uint8_t kGotoBranchMax = 1; | |||
| LabelGotoExTaskInfo::~LabelGotoExTaskInfo() { | |||
| GE_FREE_RT_LOG(args_); | |||
| args_ = nullptr; | |||
| GE_FREE_RT_LOG(index_value_); | |||
| } | |||
| @@ -49,30 +49,12 @@ Status LabelGotoExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da | |||
| return INTERNAL_ERROR; | |||
| } | |||
| const vector<rtLabel_t> &label_list = davinci_model->GetLabelList(); | |||
| if (label_index >= label_list.size()) { | |||
| GELOGE(PARAM_INVALID, "LabelGotoExTaskInfo: Invalid label id:%u, label size:%zu", label_index, label_list.size()); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| GE_CHECK_NOTNULL(label_list[label_index]); | |||
| vector<rtLabel_t> label_used = { label_list[label_index] }; | |||
| rtMemType_t memory_type = op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE) ? RT_MEMORY_TS_4G : RT_MEMORY_HBM; | |||
| GELOGI("memory_type: %u", memory_type); | |||
| args_size_ = kGotoBranchMax * sizeof(rtLabelDevInfo); | |||
| rtError_t rt_ret = rtMalloc(&args_, args_size_, memory_type); | |||
| if (rt_ret != RT_ERROR_NONE) { | |||
| GELOGE(RT_FAILED, "Call rtMalloc failed, error: %#x", rt_ret); | |||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||
| } | |||
| rt_ret = rtLabelListCpy(label_used.data(), label_used.size(), args_, args_size_); | |||
| if (rt_ret != RT_ERROR_NONE) { | |||
| GELOGE(RT_FAILED, "Call rtLabelListCpy failed, error: %#x", rt_ret); | |||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||
| } | |||
| GE_CHK_STATUS_RET_NOLOG(davinci_model->GetLabelGotoAddr(label_index, memory_type, args_, args_size_)); | |||
| rt_ret = rtMalloc(&index_value_, sizeof(uint64_t), memory_type); | |||
| rtError_t rt_ret = rtMalloc(&index_value_, sizeof(uint64_t), memory_type); | |||
| if (rt_ret != RT_ERROR_NONE) { | |||
| GELOGE(RT_FAILED, "Call rtMalloc failed, error: %#x", rt_ret); | |||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||
| @@ -85,7 +67,7 @@ Status LabelGotoExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da | |||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||
| } | |||
| GELOGI("LabelGotoExTaskInfo Init Success, label id:%u, label:%p.", label_index, label_list[label_index]); | |||
| GELOGI("LabelGotoExTaskInfo Init Success, label id:%u", label_index); | |||
| return SUCCESS; | |||
| } | |||
| @@ -40,7 +40,7 @@ static bool BlockComparator(const Block *left, const Block *right) { | |||
| } | |||
| bool CanMerge(Block *block) { | |||
| if (block == nullptr || block->allocated || !block->IsSplit()) { | |||
| if ((block == nullptr) || block->allocated || !block->IsSplit()) { | |||
| return false; | |||
| } | |||
| return true; | |||
| @@ -52,7 +52,7 @@ size_t GetBinIndex(size_t size) { | |||
| if (size <= range) { | |||
| break; | |||
| } | |||
| ++index; | |||
| index++; | |||
| } | |||
| if (index > kNumBins - 1) { | |||
| index = kNumBins - 1; | |||
| @@ -87,25 +87,25 @@ bool ShouldSplit(const Block *block, size_t size) { | |||
| void IncreaseCount(std::map<size_t, size_t> &count, size_t size) { | |||
| auto it = count.find(size); | |||
| if (it != count.end()) { | |||
| it->second++; | |||
| } else { | |||
| if (it == count.end()) { | |||
| count.emplace(size, 1); | |||
| } else { | |||
| it->second++; | |||
| } | |||
| } | |||
| CachingAllocator::CachingAllocator(rtMemType_t memory_type) : memory_type_(memory_type), memory_allocator_(nullptr) { | |||
| for (uint32_t i = 0; i < kNumBins; ++i) { | |||
| for (uint32_t i = 0; i < kNumBins; i++) { | |||
| free_block_bins_[i] = nullptr; | |||
| } | |||
| } | |||
| Status CachingAllocator::Initialize(uint32_t device_id) { | |||
| GELOGI("Device id %u.", device_id); | |||
| GELOGI("Device id %u", device_id); | |||
| // when redo Initialize free old memory | |||
| FreeBlocks(); | |||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||
| for (uint32_t i = 0; i < kNumBins; ++i) { | |||
| for (uint32_t i = 0; i < kNumBins; i++) { | |||
| if (free_block_bins_[i] != nullptr) { | |||
| continue; | |||
| } | |||
| @@ -124,26 +124,26 @@ Status CachingAllocator::Initialize(uint32_t device_id) { | |||
| } | |||
| void CachingAllocator::Finalize(uint32_t device_id) { | |||
| GELOGI("Device id %u.", device_id); | |||
| GELOGI("Device id %u", device_id); | |||
| PrintStatics(); | |||
| FreeBlocks(); | |||
| FreeBlockBins(); | |||
| } | |||
| uint8_t *CachingAllocator::Malloc(size_t size, uint8_t *org_ptr, uint32_t device_id) { | |||
| GELOGI("Start malloc pool memory, size = %zu, device id = %u.", size, device_id); | |||
| uint8_t *ptr = nullptr; | |||
| GELOGI("Start malloc pool memory, size = %zu, device id = %u", size, device_id); | |||
| size = GetBlockSize(size); | |||
| uint8_t *ptr = nullptr; | |||
| Block *block = FindFreeBlock(size, org_ptr, device_id); | |||
| if (block != nullptr) { | |||
| ptr = block->ptr; | |||
| } else { | |||
| if (block == nullptr) { | |||
| if (ge::SUCCESS == TryExtendCache(size, device_id)) { | |||
| block = FindFreeBlock(size, org_ptr, device_id); | |||
| if (block != nullptr) { | |||
| ptr = block->ptr; | |||
| } | |||
| } | |||
| } else { | |||
| ptr = block->ptr; | |||
| } | |||
| if (ptr == nullptr) { | |||
| GELOGE(FAILED, "Malloc failed device id = %u, size= %zu", device_id, size); | |||
| @@ -152,7 +152,7 @@ uint8_t *CachingAllocator::Malloc(size_t size, uint8_t *org_ptr, uint32_t device | |||
| } | |||
| Status CachingAllocator::Free(uint8_t *ptr, uint32_t device_id) { | |||
| GELOGI("Free device id = %u.", device_id); | |||
| GELOGI("Free device id = %u", device_id); | |||
| if (ptr == nullptr) { | |||
| GELOGE(PARAM_INVALID, "Invalid memory pointer"); | |||
| return ge::PARAM_INVALID; | |||
| @@ -171,10 +171,10 @@ Status CachingAllocator::Free(uint8_t *ptr, uint32_t device_id) { | |||
| } | |||
| void CachingAllocator::FreeBlock(Block *block) { | |||
| if (block == nullptr || !block->allocated) { | |||
| if ((block == nullptr) || !block->allocated) { | |||
| return; | |||
| } | |||
| GELOGI("Free block size = %zu.", block->size); | |||
| GELOGI("Free block size = %zu", block->size); | |||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||
| block->allocated = false; | |||
| @@ -187,7 +187,7 @@ void CachingAllocator::FreeBlock(Block *block) { | |||
| } | |||
| void CachingAllocator::MergeBlocks(Block *dst, Block *src, BlockBin &bin) { | |||
| if (!CanMerge(dst) || !CanMerge(src)) { | |||
| if (!CanMerge(src) || !CanMerge(dst)) { | |||
| return; | |||
| } | |||
| @@ -227,7 +227,7 @@ Block *CachingAllocator::FindFreeBlock(size_t size, uint8_t *org_ptr, uint32_t d | |||
| Block *block = *it; | |||
| bin->erase(it); | |||
| if (block != nullptr) { | |||
| GELOGI("Find block size = %zu.", block->size); | |||
| GELOGI("Find block size = %zu", block->size); | |||
| if (ShouldSplit(block, size)) { | |||
| block = SplitBlock(block, size, *bin, device_id); | |||
| } | |||
| @@ -235,7 +235,7 @@ Block *CachingAllocator::FindFreeBlock(size_t size, uint8_t *org_ptr, uint32_t d | |||
| if (block->ptr != nullptr) { | |||
| block->allocated = true; | |||
| allocated_blocks_[block->ptr] = block; | |||
| GELOGI("Malloc device id = %u, size= %zu.", device_id, size); | |||
| GELOGI("Malloc device id = %u, size= %zu", device_id, size); | |||
| } | |||
| } | |||
| @@ -265,7 +265,7 @@ Block *CachingAllocator::SplitBlock(Block *block, size_t size, BlockBin &bin, ui | |||
| } | |||
| Status CachingAllocator::TryExtendCache(size_t size, uint32_t device_id) { | |||
| GELOGI("Try to extend cache. size = %zu, device id = %u.", size, device_id); | |||
| GELOGI("Try to extend cache. size = %zu, device id = %u", size, device_id); | |||
| auto memory_size = GetAllocationSize(size); | |||
| const std::string purpose = "Memory for caching."; | |||
| auto memory_addr = memory_allocator_->MallocMemory(purpose, memory_size, device_id); | |||
| @@ -302,7 +302,7 @@ Status CachingAllocator::AddToBlockBin(uint8_t *ptr, size_t size, uint32_t devic | |||
| return ge::FAILED; | |||
| } | |||
| GELOGI("Block size = %zu.", size); | |||
| GELOGI("Block size = %zu", size); | |||
| block->ptr = ptr; | |||
| block->size = size; | |||
| @@ -313,10 +313,10 @@ Status CachingAllocator::AddToBlockBin(uint8_t *ptr, size_t size, uint32_t devic | |||
| } | |||
| size_t CachingAllocator::FreeCachedBlocks() { | |||
| GELOGI("Free cached blocks."); | |||
| GELOGI("Free cached blocks"); | |||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||
| size_t free_cached_memory_size = 0; | |||
| for (uint32_t i = 0; i < kNumBins; ++i) { | |||
| for (uint32_t i = 0; i < kNumBins; i++) { | |||
| auto pool = free_block_bins_[i]; | |||
| if (pool == nullptr) { | |||
| continue; | |||
| @@ -324,7 +324,8 @@ size_t CachingAllocator::FreeCachedBlocks() { | |||
| for (auto it = pool->begin(); it != pool->end();) { | |||
| Block *block = *it; | |||
| // free block memory that has not been split | |||
| if ((block != nullptr) && (block->ptr != nullptr) && (block->prev == nullptr) && (block->next == nullptr) && | |||
| if ((block != nullptr) && (block->ptr != nullptr) && | |||
| (block->prev == nullptr) && (block->next == nullptr) && | |||
| (memory_allocator_->FreeMemory(block->ptr) == ge::SUCCESS)) { | |||
| auto itcount = malloced_memory_.find(block->size); | |||
| free_cached_memory_size += block->size; | |||
| @@ -345,7 +346,7 @@ size_t CachingAllocator::FreeCachedBlocks() { | |||
| } | |||
| void CachingAllocator::FreeBlocks() { | |||
| GELOGI("Free blocks"); | |||
| GELOGI("Free blocks."); | |||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||
| // free allocated blocks and put to cache | |||
| for (auto &it : allocated_blocks_) { | |||
| @@ -356,9 +357,9 @@ void CachingAllocator::FreeBlocks() { | |||
| } | |||
| void CachingAllocator::FreeBlockBins() { | |||
| GELOGI("Free block bins"); | |||
| GELOGI("Free block bins."); | |||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||
| for (uint32_t i = 0; i < kNumBins; ++i) { | |||
| for (uint32_t i = 0; i < kNumBins; i++) { | |||
| if (free_block_bins_[i] != nullptr) { | |||
| delete free_block_bins_[i]; | |||
| free_block_bins_[i] = nullptr; | |||
| @@ -367,9 +368,9 @@ void CachingAllocator::FreeBlockBins() { | |||
| } | |||
| void PrintCount(std::map<size_t, size_t> &count, const std::string &name, size_t total_size, size_t total_count) { | |||
| GELOGI("%6s total[size:%10zu count:%10zu]", name.c_str(), total_size, total_count); | |||
| GELOGI("%6s total[size:%10zu count:%10zu].", name.c_str(), total_size, total_count); | |||
| for (auto &it : count) { | |||
| GELOGI(" |- block[size:%10zu count:%10zu]", it.first, it.second); | |||
| GELOGI(" |- block[size:%10zu count:%10zu].", it.first, it.second); | |||
| } | |||
| } | |||
| @@ -383,20 +384,20 @@ void CachingAllocator::PrintStatics() { | |||
| size_t total_free_count = 0; | |||
| size_t total_malloc_size = 0; | |||
| size_t total_malloc_count = 0; | |||
| std::map<size_t, size_t> using_block; | |||
| std::map<size_t, size_t> free_block; | |||
| std::map<size_t, size_t> malloc_block; | |||
| std::map<size_t, size_t> using_block_stat; | |||
| std::map<size_t, size_t> free_block_stat; | |||
| std::map<size_t, size_t> malloc_block_stat; | |||
| do { | |||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||
| for (uint32_t i = 0; i < kNumBins; ++i) { | |||
| for (uint32_t i = 0; i < kNumBins; i++) { | |||
| auto pool = free_block_bins_[i]; | |||
| if (pool == nullptr) { | |||
| continue; | |||
| } | |||
| for (auto it = pool->begin(); it != pool->end(); ++it) { | |||
| for (auto it = pool->begin(); it != pool->end(); it++) { | |||
| if ((*it) != nullptr) { | |||
| total_free_size += (*it)->size; | |||
| IncreaseCount(free_block, (*it)->size); | |||
| IncreaseCount(free_block_stat, (*it)->size); | |||
| total_free_count++; | |||
| } | |||
| } | |||
| @@ -405,7 +406,7 @@ void CachingAllocator::PrintStatics() { | |||
| for (auto &it : allocated_blocks_) { | |||
| if (it.second != nullptr) { | |||
| total_using_size += it.second->size; | |||
| IncreaseCount(using_block, it.second->size); | |||
| IncreaseCount(using_block_stat, it.second->size); | |||
| total_using_count++; | |||
| } | |||
| } | |||
| @@ -413,12 +414,12 @@ void CachingAllocator::PrintStatics() { | |||
| for (auto &it : malloced_memory_) { | |||
| total_malloc_size += it.first * it.second; | |||
| total_malloc_count += it.second; | |||
| malloc_block[it.first] = it.second; | |||
| malloc_block_stat[it.first] = it.second; | |||
| } | |||
| } while (0); | |||
| PrintCount(malloc_block, "Malloc", total_malloc_size, total_malloc_count); | |||
| PrintCount(using_block, "Using", total_using_size, total_using_count); | |||
| PrintCount(free_block, "Free", total_free_size, total_free_count); | |||
| PrintCount(malloc_block_stat, "Malloc", total_malloc_size, total_malloc_count); | |||
| PrintCount(using_block_stat, "Using", total_using_size, total_using_count); | |||
| PrintCount(free_block_stat, "Free", total_free_size, total_free_count); | |||
| } | |||
| } // namespace ge | |||
| @@ -359,7 +359,10 @@ Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, | |||
| std::shared_ptr<Graph> graph_ptr = MakeShared<ge::Graph>(graph); | |||
| GE_IF_BOOL_EXEC(graph_ptr == nullptr, GELOGE(FAILED, "GraphPtr make shared failed"); | |||
| return FAILED); | |||
| // update option about tuning graph | |||
| ParseOption(options, BUILD_MODE, options_.build_mode); | |||
| ParseOption(options, BUILD_STEP, options_.build_step); | |||
| ParseOption(options, TUNING_PATH, options_.tuning_path); | |||
| graph_node->SetGraph(graph_ptr); | |||
| graph_node->SetOptions(options); | |||
| AddGraphNode(graph_id, graph_node); | |||
| @@ -433,6 +436,10 @@ Status GraphManager::AddGraphWithCopy(const GraphId &graph_id, const Graph &grap | |||
| GELOGE(FAILED, "GraphPtr make shared failed"); | |||
| return FAILED; | |||
| } | |||
| // update option about tuning graph | |||
| ParseOption(options, BUILD_MODE, options_.build_mode); | |||
| ParseOption(options, BUILD_STEP, options_.build_step); | |||
| ParseOption(options, TUNING_PATH, options_.tuning_path); | |||
| graph_node->SetGraph(graph_ptr); | |||
| graph_node->SetOptions(options); | |||
| @@ -1466,6 +1473,10 @@ Status GraphManager::ParseOptions(const std::map<std::string, std::string> &opti | |||
| GE_IF_BOOL_EXEC(ret != SUCCESS, | |||
| GELOGE(GE_GRAPH_OPTIONS_INVALID, "Key:ge.compressFlag value is invalid, must be 0 or 1."); | |||
| return GE_GRAPH_OPTIONS_INVALID); | |||
| // Set Build model and step | |||
| ParseOption(options, BUILD_MODE, options_.build_mode); | |||
| ParseOption(options, BUILD_STEP, options_.build_step); | |||
| ParseOption(options, BUILD_STEP, options_.tuning_path); | |||
| // ge.graphType. | |||
| options_.run_graph_flag = true; | |||
| @@ -1514,10 +1525,6 @@ Status GraphManager::ParseOptions(const std::map<std::string, std::string> &opti | |||
| GELOGD("Dynamic dims params: input shape is %s, dynamic dims is %s, dynamic node type is %d", | |||
| options_.input_shape.c_str(), options_.dynamic_dims.c_str(), options_.dynamic_node_type); | |||
| // Set Build model and step | |||
| ParseOption(options, BUILD_MODE, options_.build_mode); | |||
| ParseOption(options, BUILD_STEP, options_.build_step); | |||
| return SUCCESS; | |||
| } | |||
| @@ -1549,6 +1556,7 @@ void GraphManager::ParseOption(const std::map<std::string, std::string> &options | |||
| std::string &option) { | |||
| auto iter = options.find(key); | |||
| if (iter != options.end()) { | |||
| GELOGD("Set option %s from value %s to value%s", key.c_str(), option.c_str(), iter->second.c_str()); | |||
| option = iter->second; | |||
| } | |||
| } | |||
| @@ -3132,6 +3140,21 @@ Status GraphManager::ConvertGraphToFile(ComputeGraphPtr &compute_graph, GraphPar | |||
| non_tuning_subgraphs.push_back(sub_graph_tmp); | |||
| } | |||
| } | |||
| // for function graphs to tune | |||
| for (auto &function_graph : compute_graph->GetAllSubgraphs()) { | |||
| auto subgraph_list = sub_graph_map[function_graph]; | |||
| for (const auto &sub_graph_info_ptr : subgraph_list) { | |||
| GE_CHECK_NOTNULL(sub_graph_info_ptr); | |||
| ComputeGraphPtr sub_graph_tmp = sub_graph_info_ptr->GetSubGraph(); | |||
| // need to tuning | |||
| if (sub_graph_info_ptr->GetEngineName() == kVectorEngine || | |||
| sub_graph_info_ptr->GetEngineName() == kAIcoreEngine) { | |||
| tuning_subgraphs.push_back(sub_graph_tmp); | |||
| } else { | |||
| non_tuning_subgraphs.push_back(sub_graph_tmp); | |||
| } | |||
| } | |||
| } | |||
| return TuningUtils::ConvertGraphToFile(tuning_subgraphs, non_tuning_subgraphs, exe_flag, path); | |||
| } | |||
| @@ -249,6 +249,7 @@ struct GraphManagerOptions { | |||
| std::string save_original_model; | |||
| std::string build_mode; | |||
| std::string build_step; | |||
| std::string tuning_path; | |||
| std::string input_shape; | |||
| std::string dynamic_dims; | |||
| int32_t dynamic_node_type = -1; | |||
| @@ -275,7 +276,8 @@ struct GraphManagerOptions { | |||
| is_single_op(false), | |||
| save_original_model("false"), | |||
| build_mode(""), | |||
| build_step("") {} | |||
| build_step(""), | |||
| tuning_path(""){} | |||
| }; | |||
| } // namespace ge | |||
| @@ -347,14 +347,18 @@ ge::Status VarManager::Init(const uint32_t &version, const uint64_t &session_id, | |||
| const uint64_t &job_id) { | |||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||
| GELOGI("VarManager::Init, session id = %lu.", session_id); | |||
| version_ = version; | |||
| device_id_ = device_id; | |||
| session_id_ = session_id; | |||
| job_id_ = job_id; | |||
| var_resource_ = std::unique_ptr<VarResource>(new (std::nothrow) VarResource(session_id_)); | |||
| if (var_resource_ == nullptr) { | |||
| GELOGW("VarManager has not been init."); | |||
| return ge::INTERNAL_ERROR; | |||
| version_ = version; | |||
| device_id_ = device_id; | |||
| session_id_ = session_id; | |||
| job_id_ = job_id; | |||
| var_resource_ = std::unique_ptr<VarResource>(new (std::nothrow) VarResource(session_id_)); | |||
| if (var_resource_ == nullptr) { | |||
| GELOGW("VarManager init failed session id = %lu.", session_id); | |||
| return ge::INTERNAL_ERROR; | |||
| } | |||
| } else { | |||
| GELOGW("VarManager::has been inited, session id = %lu.", session_id); | |||
| } | |||
| return SUCCESS; | |||
| } | |||
| @@ -30,8 +30,15 @@ constexpr int kMaxRePassTimes = 10000; | |||
| constexpr size_t kMaxOneInNodes = 1000; | |||
| // Each iteration, we take about 0.3k memory on the stack, we should change the recursion to loop later | |||
| constexpr int kMaxRecursiveDepth = 20; | |||
| struct DuringPassNodeSets { | |||
| std::unordered_set<Node *> nodes_seen; | |||
| std::unordered_set<NodePtr> nodes_deleted; | |||
| std::unordered_set<NodePtr> nodes_re_pass; | |||
| std::unordered_set<NodePtr> nodes_re_pass_immediately; | |||
| std::unordered_set<NodePtr> nodes_last; | |||
| }; | |||
| void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::queue<NodePtr> &input_edge_nodes, | |||
| void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::deque<NodePtr> &input_edge_nodes, | |||
| std::unordered_set<Node *> &nodes_seen, std::unordered_set<NodePtr> &nodes_last) { | |||
| nodes_last.clear(); | |||
| for (auto &node : graph->GetDirectNode()) { | |||
| @@ -40,7 +47,7 @@ void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::queue<NodePtr> &i | |||
| } | |||
| size_t in_nums = node->GetInNodes().size(); | |||
| if (in_nums == 0) { | |||
| input_edge_nodes.push(node); | |||
| input_edge_nodes.push_back(node); | |||
| nodes_seen.insert(node.get()); | |||
| } else if (in_nums > kMaxOneInNodes) { | |||
| nodes_last.insert(node); | |||
| @@ -48,7 +55,7 @@ void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::queue<NodePtr> &i | |||
| } | |||
| } | |||
| void AddNextIterNodes(const Node::Vistor<NodePtr> &nodes, std::queue<NodePtr> &nodes_to_pass, | |||
| void AddNextIterNodes(const Node::Vistor<NodePtr> &nodes, std::deque<NodePtr> &nodes_to_pass, | |||
| std::unordered_set<Node *> &nodes_seen, std::unordered_set<NodePtr> &nodes_last) { | |||
| for (auto &node : nodes) { | |||
| if (node == nullptr) { | |||
| @@ -60,13 +67,30 @@ void AddNextIterNodes(const Node::Vistor<NodePtr> &nodes, std::queue<NodePtr> &n | |||
| bool all_in_nodes_seen = node->IsAllInNodesSeen(nodes_seen); | |||
| if (all_in_nodes_seen && nodes_seen.insert(node.get()).second) { | |||
| nodes_to_pass.push(node); | |||
| nodes_to_pass.push_back(node); | |||
| } | |||
| } | |||
| } | |||
| Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, std::unordered_set<NodePtr> &nodes_re_pass, | |||
| std::unordered_set<NodePtr> &nodes_deleted, std::unordered_set<Node *> &nodes_seen) { | |||
| void PushToRePassIfSeen(NodePtr &node, const std::pair<std::string, BaseNodePass *> &name_to_pass, | |||
| std::unordered_set<Node *> &nodes_seen, std::unordered_set<NodePtr> &nodes_to_re_pass, | |||
| std::unordered_set<NodePtr> &nodes_re_pass) { | |||
| for (const auto &node_to_re_pass : nodes_to_re_pass) { | |||
| if (node_to_re_pass == nullptr) { | |||
| GELOGW("Found null re-pass node when executing %s on node %s type %s", name_to_pass.first.c_str(), | |||
| node->GetName().c_str(), node->GetType().c_str()); | |||
| continue; | |||
| } | |||
| if (nodes_seen.count(node_to_re_pass.get()) > 0 || node_to_re_pass->IsAllInNodesSeen(nodes_seen)) { | |||
| GELOGD("The node %s will be re-pass.", node_to_re_pass->GetName().c_str()); | |||
| nodes_re_pass.insert(node_to_re_pass); | |||
| } else { | |||
| GELOGD("The node %s are not all seen, don't set repass this time", node_to_re_pass->GetName().c_str()); | |||
| } | |||
| } | |||
| } | |||
| Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, DuringPassNodeSets &during_pass_node_set) { | |||
| if (node == nullptr) { | |||
| GELOGE(FAILED, "parameter is null."); | |||
| return FAILED; | |||
| @@ -90,22 +114,15 @@ Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, std::unorder | |||
| } | |||
| auto nodes_to_re_pass = name_to_pass.second->GetNodesNeedRePass(); | |||
| for (const auto &node_to_re_pass : nodes_to_re_pass) { | |||
| if (node_to_re_pass == nullptr) { | |||
| GELOGW("Found null re-pass node when executing %s on node %s type %s", name_to_pass.first.c_str(), | |||
| node->GetName().c_str(), node->GetType().c_str()); | |||
| continue; | |||
| } | |||
| if (nodes_seen.count(node_to_re_pass.get()) > 0 || node_to_re_pass->IsAllInNodesSeen(nodes_seen)) { | |||
| GELOGD("The node %s will be re-pass later", node_to_re_pass->GetName().c_str()); | |||
| nodes_re_pass.insert(node_to_re_pass); | |||
| } else { | |||
| GELOGD("The node %s are not all seen, don't set repass this time", node_to_re_pass->GetName().c_str()); | |||
| } | |||
| } | |||
| PushToRePassIfSeen(node, name_to_pass, during_pass_node_set.nodes_seen, nodes_to_re_pass, | |||
| during_pass_node_set.nodes_re_pass); | |||
| auto nodes_to_re_pass_immediately = name_to_pass.second->GetNodesNeedRePassImmediately(); | |||
| PushToRePassIfSeen(node, name_to_pass, during_pass_node_set.nodes_seen, nodes_to_re_pass_immediately, | |||
| during_pass_node_set.nodes_re_pass_immediately); | |||
| auto nodes_deleted_by_pass = name_to_pass.second->GetNodesDeleted(); | |||
| nodes_deleted.insert(nodes_deleted_by_pass.begin(), nodes_deleted_by_pass.end()); | |||
| during_pass_node_set.nodes_deleted.insert(nodes_deleted_by_pass.begin(), nodes_deleted_by_pass.end()); | |||
| if (nodes_deleted_by_pass.count(node) > 0) { | |||
| GELOGD("The node %s was deleted by pass %s, stop the remain passes", node->GetName().c_str(), | |||
| name_to_pass.first.c_str()); | |||
| @@ -181,36 +198,33 @@ Status GEPass::Run(const NamesToPass &names_to_passes) { | |||
| Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { | |||
| GELOGD("Begin to run pass on graph, passes count %zu", names_to_passes.size()); | |||
| std::queue<NodePtr> nodes; | |||
| std::unordered_set<Node *> nodes_seen; | |||
| std::unordered_set<NodePtr> nodes_deleted; | |||
| std::unordered_set<NodePtr> nodes_re_pass; | |||
| std::unordered_set<NodePtr> nodes_last; | |||
| GetAllNodesNoInputEdge(graph_, nodes, nodes_seen, nodes_last); | |||
| std::deque<NodePtr> nodes; | |||
| DuringPassNodeSets during_pass_node_set; | |||
| GetAllNodesNoInputEdge(graph_, nodes, during_pass_node_set.nodes_seen, during_pass_node_set.nodes_last); | |||
| GELOGD("Start points count %zu", nodes.size()); | |||
| int re_pass_times = 0; | |||
| do { | |||
| for (auto &node : nodes_re_pass) { | |||
| nodes.push(node); | |||
| nodes_seen.insert(node.get()); | |||
| for (auto &node : during_pass_node_set.nodes_re_pass) { | |||
| nodes.push_back(node); | |||
| during_pass_node_set.nodes_seen.insert(node.get()); | |||
| } | |||
| nodes_re_pass.clear(); | |||
| during_pass_node_set.nodes_re_pass.clear(); | |||
| while (!nodes.empty()) { | |||
| NodePtr node = nodes.front(); | |||
| nodes.pop(); | |||
| nodes.pop_front(); | |||
| (void)nodes_re_pass.erase(node); | |||
| (void)during_pass_node_set.nodes_re_pass.erase(node); | |||
| GE_IF_BOOL_EXEC(node == nullptr, GELOGW("node is null"); continue); | |||
| if (nodes_deleted.count(node) > 0) { | |||
| if (during_pass_node_set.nodes_deleted.count(node) > 0) { | |||
| GELOGD("The node %s was deleted before, skip it.", node->GetName().c_str()); | |||
| continue; | |||
| } | |||
| AddNextIterNodes(node->GetOutNodes(), nodes, nodes_seen, nodes_last); | |||
| AddNextIterNodes(node->GetOutNodes(), nodes, during_pass_node_set.nodes_seen, during_pass_node_set.nodes_last); | |||
| auto ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); | |||
| auto ret = RunPasses(node, names_to_passes, during_pass_node_set); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", | |||
| node->GetName().c_str(), node->GetType().c_str(), ret); | |||
| @@ -227,7 +241,7 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { | |||
| if (has_sub_graph) { | |||
| GELOGD("There are subgraphs on node %s, run passes for for the second time", node->GetName().c_str()); | |||
| SetFlagOption(kOptimizeAfterSubGraph, names_to_passes); | |||
| ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); | |||
| ret = RunPasses(node, names_to_passes, during_pass_node_set); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", | |||
| node->GetName().c_str(), node->GetType().c_str(), ret); | |||
| @@ -239,16 +253,21 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { | |||
| // should be called each time at the begin of the iteration | |||
| ClearOption(names_to_passes); | |||
| } | |||
| for (const auto &node : during_pass_node_set.nodes_re_pass_immediately) { | |||
| GELOGD("The node %s will be re-pass immediately.", node->GetName().c_str()); | |||
| nodes.push_front(node); | |||
| } | |||
| during_pass_node_set.nodes_re_pass_immediately.clear(); | |||
| } | |||
| for (auto &node : nodes_last) { | |||
| bool all_in_nodes_seen = node->IsAllInNodesSeen(nodes_seen); | |||
| if (all_in_nodes_seen && nodes_seen.insert(node.get()).second) { | |||
| nodes.push(node); | |||
| for (auto &node : during_pass_node_set.nodes_last) { | |||
| bool all_in_nodes_seen = node->IsAllInNodesSeen(during_pass_node_set.nodes_seen); | |||
| if (all_in_nodes_seen && during_pass_node_set.nodes_seen.insert(node.get()).second) { | |||
| nodes.push_back(node); | |||
| } | |||
| } | |||
| nodes_last.clear(); | |||
| } while ((!nodes_re_pass.empty() || !nodes.empty()) && ++re_pass_times < kMaxRePassTimes); | |||
| during_pass_node_set.nodes_last.clear(); | |||
| } while ((!during_pass_node_set.nodes_re_pass.empty() || !nodes.empty()) && ++re_pass_times < kMaxRePassTimes); | |||
| if (re_pass_times == kMaxRePassTimes) { | |||
| GELOGW("re_pass_times should not come to %d", kMaxRePassTimes); | |||
| @@ -53,6 +53,8 @@ class BaseNodePass { | |||
| std::unordered_set<NodePtr> GetNodesNeedRePass() { return nodes_need_re_pass_; } | |||
| std::unordered_set<NodePtr> GetNodesNeedRePassImmediately() { return nodes_need_re_pass_immediately_; } | |||
| std::unordered_set<NodePtr> GetNodesDeleted() { return nodes_deleted_; } | |||
| void SetOption(NodePassOption option, const std::string &value) { options_[option] = value; } | |||
| @@ -62,6 +64,7 @@ class BaseNodePass { | |||
| void init() { | |||
| nodes_need_re_pass_.clear(); | |||
| nodes_deleted_.clear(); | |||
| nodes_need_re_pass_immediately_.clear(); | |||
| } | |||
| protected: | |||
| @@ -79,6 +82,14 @@ class BaseNodePass { | |||
| /// | |||
| void AddRePassNode(NodePtr &node) { nodes_need_re_pass_.insert(node); } | |||
| /// | |||
| /// Add a node to be optimized immediately again. If you add a new node to the graph, or | |||
| /// change a node connections, and you want to make sure the node will be | |||
| /// optimized by other passes, call this function. | |||
| /// @param node | |||
| /// | |||
| void AddImmediateRePassNode(NodePtr &node) { nodes_need_re_pass_immediately_.insert(node); } | |||
| /// | |||
| /// Add a node and it's input/output data nodes to be optimized again. | |||
| /// @param node | |||
| @@ -109,6 +120,7 @@ class BaseNodePass { | |||
| private: | |||
| std::unordered_set<NodePtr> nodes_need_re_pass_; | |||
| std::unordered_set<NodePtr> nodes_need_re_pass_immediately_; | |||
| std::unordered_set<NodePtr> nodes_deleted_; | |||
| std::map<NodePassOption, std::string> options_; | |||
| }; | |||
| @@ -25,6 +25,7 @@ | |||
| namespace ge { | |||
| Status InferShapePass::Run(NodePtr &node) { | |||
| // kOptimizeAfterSubGraph exist means after subgraph | |||
| auto ret = ShapeRefiner::InferShapeAndType(node, !OptionExists(kOptimizeAfterSubGraph)); | |||
| if (ret != GRAPH_SUCCESS) { | |||
| // select INFERSHAPE failed info | |||
| @@ -41,6 +42,20 @@ Status InferShapePass::Run(NodePtr &node) { | |||
| GELOGE(GE_GRAPH_INFERSHAPE_FAILED, "infershape failed. node: %s", node->GetName().c_str()); | |||
| return GE_GRAPH_INFERSHAPE_FAILED; | |||
| } | |||
| bool need_repass = false; | |||
| auto has_attr = AttrUtils::GetBool(node->GetOpDesc(), "need_infer_again_", need_repass); | |||
| if (has_attr) { | |||
| if (!OptionExists(kOptimizeAfterSubGraph)) { | |||
| return SUCCESS; | |||
| } | |||
| if (need_repass) { | |||
| AddImmediateRePassNode(node); | |||
| GELOGD("Node %s need repass immediately.", node->GetName().c_str()); | |||
| } else { | |||
| // clear attr on while | |||
| node->GetOpDesc()->DelAttr("need_infer_again_"); | |||
| } | |||
| } | |||
| return SUCCESS; | |||
| } | |||
| } // namespace ge | |||
| @@ -555,6 +555,8 @@ void NetOutputPass::AddInOutForNetOutputOp(const ComputeGraphPtr &graph, OpDescP | |||
| return; | |||
| } | |||
| ge::GeTensorDesc out_desc = src_node->GetOpDesc()->GetOutputDesc(src_index); | |||
| out_desc.SetFormat(FORMAT_ND); | |||
| out_desc.SetOriginFormat(FORMAT_ND); | |||
| GE_IF_BOOL_EXEC(net_output_desc->AddInputDesc(out_desc) != SUCCESS, GELOGW("add input desc failed"); return ); | |||
| is_input_const.push_back(PassUtils::IsConstant(src_node)); | |||
| ++iter; | |||
| @@ -119,8 +119,9 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { | |||
| return INTERNAL_ERROR; | |||
| } | |||
| auto graph_id = GraphUtils::FindRootGraph(graph)->GetGraphID(); | |||
| GELOGD("Begin to run variable op pass on graph %s, session %lu, graph id %u", graph->GetName().c_str(), | |||
| GetContext().SessionId(), graph->GetGraphID()); | |||
| GetContext().SessionId(), graph_id); | |||
| if (var_accelerate_ctrl_ == nullptr) { | |||
| GELOGE(INTERNAL_ERROR, "Failed to run var op pass, the variable accelerate control is null"); | |||
| @@ -176,7 +177,7 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { | |||
| GELOGE(INTERNAL_ERROR, "Failed to update the format fusion road for var %s", node->GetName().c_str()); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph->GetGraphID()); | |||
| ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph_id); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(INTERNAL_ERROR, "Failed to update the graph id for var %s", node->GetName().c_str()); | |||
| return INTERNAL_ERROR; | |||
| @@ -23,6 +23,7 @@ | |||
| #include "common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h" | |||
| #include "common/formats/format_transfers/format_transfer_transpose.h" | |||
| #include "common/formats/utils/formats_trans_utils.h" | |||
| #include "common/util/error_manager/error_manager.h" | |||
| #include "common/helper/model_helper.h" | |||
| #include "common/math/math_util.h" | |||
| #include "common/op/ge_op_utils.h" | |||
| @@ -1304,7 +1305,8 @@ Status GraphPrepare::UpdateInput(const std::vector<GeTensor> &user_input, | |||
| auto format = desc.GetFormat(); | |||
| auto origin_format = desc.GetOriginFormat(); | |||
| // data maybe internal format [FRACTAL_NZ] at singleop process such as GEMM. | |||
| bool need_check_internal_format = (!IsTansDataOpData(input_node)) && (!options_.is_single_op); | |||
| auto tune_flag = (options_.build_mode == BUILD_MODE_TUNING) && (options_.build_step == BUILD_STEP_AFTER_BUILDER); | |||
| bool need_check_internal_format = (!IsTansDataOpData(input_node)) && (!options_.is_single_op) && (!tune_flag); | |||
| if (need_check_internal_format) { | |||
| bool is_internal = TypeUtils::IsInternalFormat(format) || TypeUtils::IsInternalFormat(origin_format); | |||
| if (is_internal) { | |||
| @@ -1346,19 +1348,22 @@ Status GraphPrepare::UpdateInput(const std::vector<GeTensor> &user_input, | |||
| return FAILED; | |||
| } | |||
| ge::TensorUtils::SetSize(desc, shape_size); | |||
| graphStatus graph_ret = op->UpdateInputDesc(0, desc); | |||
| if (graph_ret != GRAPH_SUCCESS) { | |||
| GELOGE(graph_ret, "UpdateInputDesc fail, graph_ret:%u", graph_ret); | |||
| return graph_ret; | |||
| } | |||
| // Size will be recalculated in the build stage | |||
| ge::TensorUtils::SetSize(desc, 0); | |||
| graph_ret = op->UpdateOutputDesc(0, desc); | |||
| if (graph_ret != GRAPH_SUCCESS) { | |||
| GELOGE(graph_ret, "UpdateOutputDesc fail, graph_ret:%u", graph_ret); | |||
| return graph_ret; | |||
| if (!tune_flag) { | |||
| graphStatus graph_ret = op->UpdateInputDesc(0, desc); | |||
| if (graph_ret != GRAPH_SUCCESS) { | |||
| GELOGE(graph_ret, "UpdateInputDesc fail, graph_ret:%u", graph_ret); | |||
| return graph_ret; | |||
| } | |||
| // Size will be recalculated in the build stage | |||
| ge::TensorUtils::SetSize(desc, 0); | |||
| graph_ret = op->UpdateOutputDesc(0, desc); | |||
| if (graph_ret != GRAPH_SUCCESS) { | |||
| GELOGE(graph_ret, "UpdateOutputDesc fail, graph_ret:%u", graph_ret); | |||
| return graph_ret; | |||
| } | |||
| } else { | |||
| GELOGI("data %s skip update info in tune mode", op->GetName().c_str()); | |||
| } | |||
| if (!dynamic_shape_range_vec.empty()) { | |||
| ret = UpdateDynamicInputShapeRange(index, dynamic_shape_range_vec, op, desc); | |||
| GE_CHK_STATUS_RET(ret, "Fail to update dynamic input shape range on %s.", op->GetName().c_str()); | |||
| @@ -1763,13 +1768,13 @@ Status GraphPrepare::CheckUserInput(const std::vector<GeTensor> &user_input) { | |||
| GeTensorDesc desc(user_input[index].GetTensorDesc()); | |||
| for (size_t i = 0; i < desc.GetShape().GetDimNum(); ++i) { | |||
| if (desc.GetShape().GetDim(i) < 0) { | |||
| std::string situation = "data dim[" + std::to_string(i) + "][" + | |||
| std::to_string(desc.GetShape().GetDim(i)) + "]" ; | |||
| std::string reason = "it need >= 0"; | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, {situation, reason}); | |||
| GELOGE(GE_GRAPH_INIT_FAILED, "data dim %zu is not supported, need >= 0, real:%ld.", i, | |||
| desc.GetShape().GetDim(i)); | |||
| int64_t dim = desc.GetShape().GetDim(i); | |||
| if (dim < UNKNOWN_DIM_NUM) { | |||
| std::string situation = "data dim[" + std::to_string(i) + "][" + std::to_string(dim) + "]" ; | |||
| std::string reason = "it need >= -2"; | |||
| REPORT_INPUT_ERROR( | |||
| "E19025", 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); | |||
| return GE_GRAPH_INIT_FAILED; | |||
| } | |||
| } | |||
| @@ -33,7 +33,7 @@ const int kNumOne = 1; | |||
| } // namespace | |||
| Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector<ConstGeTensorPtr> &input, | |||
| vector<GeTensorPtr> &v_output) { | |||
| GELOGI("ConcatOffsetKernel in."); | |||
| GELOGD("ConcatOffsetKernel in"); | |||
| if (op_desc_ptr == nullptr) { | |||
| GELOGE(PARAM_INVALID, "input opdesc is nullptr."); | |||
| return PARAM_INVALID; | |||
| @@ -41,7 +41,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector<Con | |||
| // validate attrs | |||
| int N = 0; | |||
| if (!(AttrUtils::GetInt(op_desc_ptr, "N", N))) { | |||
| GELOGW("Attr %s does not exist.", "N"); | |||
| GELOGW("Attr %s does not exist", "N"); | |||
| return NOT_CHANGED; | |||
| } | |||
| // follow IR def, the first input is concat_dim | |||
| @@ -50,7 +50,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector<Con | |||
| int32_t concat_dim = *(const_cast<int32_t *>(reinterpret_cast<const int32_t *>(input_0->GetData().data()))); | |||
| // validate inputs | |||
| if ((static_cast<int>(input.size()) != (N + kNumOne)) || (input.size() <= kConcatOffsetInputIndexOne)) { | |||
| GELOGW("The number of input for concat offset must be equal to %d, and must be more than one.", (N + kNumOne)); | |||
| GELOGW("The number of input for concat offset must be equal to %d, and must be more than one", (N + kNumOne)); | |||
| return NOT_CHANGED; | |||
| } | |||
| @@ -61,7 +61,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector<Con | |||
| GELOGW("Concat dim is bigger than the size of output_shape."); | |||
| return NOT_CHANGED; | |||
| } | |||
| GELOGI("Output shape size is %ld", output_size); | |||
| GELOGI("Output shape size is %ld.", output_size); | |||
| int32_t offset = 0; | |||
| if (output_size < 0) { | |||
| GELOGE(FAILED, "Index is negative."); | |||
| @@ -86,7 +86,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector<Con | |||
| output_ptr->MutableTensorDesc().SetShape(output_shape); | |||
| GE_IF_BOOL_EXEC(output_ptr->SetData(reinterpret_cast<uint8_t *>(buf.get()), | |||
| static_cast<size_t>(sizeof(DT_INT32) * output_size)) != GRAPH_SUCCESS, | |||
| GELOGW("set data failed"); | |||
| GELOGW("set data failed."); | |||
| return NOT_CHANGED); | |||
| v_output.push_back(output_ptr); | |||
| // caculate offset | |||
| @@ -99,7 +99,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector<Con | |||
| } | |||
| offset += input_dim; | |||
| } | |||
| GELOGI("ConcatOffsetKernel success."); | |||
| GELOGD("ConcatOffsetKernel success"); | |||
| return SUCCESS; | |||
| } | |||
| REGISTER_KERNEL(CONCATOFFSET, ConcatOffsetKernel); | |||
| @@ -278,7 +278,7 @@ Status GatherV2Kernel::SaveIndicesByDataType(ConstGeTensorPtr indices_tensor_ptr | |||
| auto indices_ptr = const_cast<int32_t *>(reinterpret_cast<const int32_t *>(indices_tensor_ptr->GetData().data())); | |||
| for (int64_t i = 0; i < indices_shape.GetShapeSize(); i++) { | |||
| if (*(indices_ptr + i) < 0 || *(indices_ptr + i) >= x_shape.GetDim(axis)) { | |||
| GELOGW("indices %ld value is not in range [0, %ld)", i, x_shape.GetDim(axis)); | |||
| GELOGW("indices %ld value is not in range [0, %ld).", i, x_shape.GetDim(axis)); | |||
| return NOT_CHANGED; | |||
| } | |||
| indicates_.push_back(*(indices_ptr + i)); | |||
| @@ -288,7 +288,7 @@ Status GatherV2Kernel::SaveIndicesByDataType(ConstGeTensorPtr indices_tensor_ptr | |||
| auto indices_ptr = const_cast<int64_t *>(reinterpret_cast<const int64_t *>(indices_tensor_ptr->GetData().data())); | |||
| for (int64_t i = 0; i < indices_shape.GetShapeSize(); i++) { | |||
| if (*(indices_ptr + i) < 0 || *(indices_ptr + i) >= x_shape.GetDim(axis)) { | |||
| GELOGW("indices %ld value is not in range [0, %ld)", i, x_shape.GetDim(axis)); | |||
| GELOGW("indices %ld value is not in range [0, %ld).", i, x_shape.GetDim(axis)); | |||
| return NOT_CHANGED; | |||
| } | |||
| indicates_.push_back(*(indices_ptr + i)); | |||
| @@ -344,42 +344,42 @@ Status GatherV2Kernel::Check(const OpDescPtr &op_desc_ptr, const vector<ConstGeT | |||
| auto indices_data_type = tensor1->GetTensorDesc().GetDataType(); | |||
| bool is_valid_indices_data_type = indices_data_type == DT_INT32 || indices_data_type == DT_INT64; | |||
| if (!is_valid_indices_data_type) { | |||
| GELOGW("indices datatype must be DT_INT32 or DT_INT64"); | |||
| GELOGW("indices datatype must be DT_INT32 or DT_INT64."); | |||
| return NOT_CHANGED; | |||
| } | |||
| if (indices_shape.GetDimNum() > kMaxIndicatesDims) { | |||
| GELOGW("indices input only support 0 or 1 dims"); | |||
| GELOGW("indices input only support 0 or 1 dims."); | |||
| return NOT_CHANGED; | |||
| } | |||
| return SUCCESS; | |||
| } | |||
| void GatherV2Kernel::DebugPrint(int64_t axis, const GeShape &x_shape, const GeShape &indices_shape, | |||
| const std::vector<int64_t> &y_shape) { | |||
| GELOGD("GatherV2Kernel axis:%ld x_shape:%zu indices_shape:%zu y_shape:%zu", axis, x_shape.GetDimNum(), | |||
| GELOGD("GatherV2Kernel axis:%ld x_shape:%zu indices_shape:%zu y_shape:%zu.", axis, x_shape.GetDimNum(), | |||
| indices_shape.GetDimNum(), y_shape.size()); | |||
| for (size_t i = 0; i < x_shape.GetDimNum(); i++) { | |||
| GELOGD("GatherV2Kernel x_shape[%zu]: %ld", i, x_shape.GetDim(i)); | |||
| GELOGD("GatherV2Kernel x_shape[%zu]: %ld.", i, x_shape.GetDim(i)); | |||
| } | |||
| for (size_t i = 0; i < indices_shape.GetDimNum(); i++) { | |||
| GELOGD("GatherV2Kernel indices_shape[%zu]: %ld", i, indices_shape.GetDim(i)); | |||
| GELOGD("GatherV2Kernel indices_shape[%zu]: %ld.", i, indices_shape.GetDim(i)); | |||
| } | |||
| for (size_t i = 0; i < y_shape.size(); i++) { | |||
| GELOGD("GatherV2Kernel y_shape[%zu]: %ld", i, y_shape[i]); | |||
| GELOGD("GatherV2Kernel y_shape[%zu]: %ld.", i, y_shape[i]); | |||
| } | |||
| for (auto ele : indicates_) { | |||
| GELOGD("GatherV2Kernel indices:%ld", ele); | |||
| GELOGD("GatherV2Kernel indices:%ld.", ele); | |||
| } | |||
| } | |||
| Status GatherV2Kernel::Compute(const OpDescPtr op_desc_ptr, const vector<ConstGeTensorPtr> &input, | |||
| vector<GeTensorPtr> &v_output) { | |||
| GELOGI("Enter GatherV2Kernel Process."); | |||
| GELOGI("Enter GatherV2Kernel Process"); | |||
| Status ret = Check(op_desc_ptr, input, v_output); | |||
| if (ret != SUCCESS) { | |||
| GELOGW("param check failed."); | |||
| GELOGW("param check failed"); | |||
| return NOT_CHANGED; | |||
| } | |||
| GELOGI("GatherV2Kernel[%s] start Process.", op_desc_ptr->GetName().c_str()); | |||
| GELOGI("GatherV2Kernel[%s] start Process", op_desc_ptr->GetName().c_str()); | |||
| ConstGeTensorPtr tensor0 = input.at(kGatherV2InputIndexZero); | |||
| ConstGeTensorPtr tensor1 = input.at(kGatherV2InputIndexOne); | |||
| ConstGeTensorPtr tensor2 = input.at(kGatherV2InputIndexTwo); | |||
| @@ -394,7 +394,7 @@ Status GatherV2Kernel::Compute(const OpDescPtr op_desc_ptr, const vector<ConstGe | |||
| axis = axis >= 0 ? axis : axis + x_shape.GetDimNum(); | |||
| // check axis value | |||
| if (axis < 0 || (axis + 1) > static_cast<int64_t>(x_shape.GetDimNum())) { | |||
| GELOGW("axis is invalid"); | |||
| GELOGW("axis is invalid!"); | |||
| return NOT_CHANGED; | |||
| } | |||
| auto indices_data_type = tensor1->GetTensorDesc().GetDataType(); | |||
| @@ -407,7 +407,7 @@ Status GatherV2Kernel::Compute(const OpDescPtr op_desc_ptr, const vector<ConstGe | |||
| // check input data type | |||
| auto x_data_type = tensor0->GetTensorDesc().GetDataType(); | |||
| 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; | |||
| } | |||
| // calc output shape | |||
| @@ -61,4 +61,5 @@ Status IdentityKernel::Compute(const ge::OpDescPtr op_desc, const std::vector<ge | |||
| return SUCCESS; | |||
| } | |||
| REGISTER_KERNEL(IDENTITY, IdentityKernel); | |||
| REGISTER_KERNEL(PLACEHOLDERWITHDEFAULT, IdentityKernel); | |||
| } // namespace ge | |||
| @@ -84,14 +84,14 @@ void GetOriginStrideVec(const std::vector<ge::ConstGeTensorPtr> &input, vector<i | |||
| } // namespace | |||
| Status StridedSliceKernel::Compute(const ge::OpDescPtr attr, const std::vector<ge::ConstGeTensorPtr> &input, | |||
| vector<ge::GeTensorPtr> &v_output) { | |||
| GELOGD("StridedSliceKernel in."); | |||
| GELOGD("StridedSliceKernel in"); | |||
| // 1.Check input and attrs | |||
| if (CheckAndGetAttr(attr) != SUCCESS) { | |||
| GELOGW("Check and get attrs failed.Ignore kernel."); | |||
| GELOGW("Check and get attrs failed.Ignore kernel"); | |||
| return NOT_CHANGED; | |||
| } | |||
| if (CheckInputParam(input) != SUCCESS) { | |||
| GELOGW("Check input params failed.Ignore kernel."); | |||
| GELOGW("Check input params failed.Ignore kernel"); | |||
| return NOT_CHANGED; | |||
| } | |||
| // 2.Init param with mask attrs. | |||
| @@ -120,7 +120,7 @@ Status StridedSliceKernel::Compute(const ge::OpDescPtr attr, const std::vector<g | |||
| auto ret = OpUtils::SetOutputSliceData(data, static_cast<int64_t>(data_size), data_type, input_dims, begin_vec, | |||
| output_dims, output_ptr.get(), stride_vec); | |||
| if (ret != SUCCESS) { | |||
| GELOGE(INTERNAL_ERROR, "SetOutputSliceData failed."); | |||
| GELOGE(INTERNAL_ERROR, "SetOutputSliceData failed"); | |||
| return NOT_CHANGED; | |||
| } | |||
| @@ -133,7 +133,7 @@ Status StridedSliceKernel::Compute(const ge::OpDescPtr attr, const std::vector<g | |||
| GetOutputDims(final_dim_size, output_dims, v_dims); | |||
| t_d.SetShape(GeShape(v_dims)); | |||
| v_output.push_back(output_ptr); | |||
| GELOGI("StridedSliceKernel success."); | |||
| GELOGI("StridedSliceKernel success"); | |||
| return SUCCESS; | |||
| } | |||
| Status StridedSliceKernel::CheckAndGetAttr(const OpDescPtr &attr) { | |||
| @@ -144,7 +144,7 @@ Status StridedSliceKernel::CheckAndGetAttr(const OpDescPtr &attr) { | |||
| // Get all op attr value of strided_slice | |||
| for (auto &attr_2_value : attr_value_map_) { | |||
| if (!AttrUtils::GetInt(attr, attr_2_value.first, attr_2_value.second)) { | |||
| GELOGE(PARAM_INVALID, "Get %s attr failed.", attr_2_value.first.c_str()); | |||
| GELOGE(PARAM_INVALID, "Get %s attr failed", attr_2_value.first.c_str()); | |||
| return PARAM_INVALID; | |||
| } | |||
| } | |||
| @@ -182,7 +182,7 @@ Status StridedSliceKernel::CheckInputParam(const std::vector<ConstGeTensorPtr> & | |||
| return PARAM_INVALID; | |||
| } | |||
| if (kIndexNumberType.find(begin_tensor_desc.GetDataType()) == kIndexNumberType.end()) { | |||
| GELOGW("Data type of StridedSlice OP(begin,end,strides) must be int32 or int64."); | |||
| GELOGW("Data type of StridedSlice OP(begin,end,strides) must be int32 or int64"); | |||
| return PARAM_INVALID; | |||
| } | |||
| @@ -250,7 +250,7 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector<ConstGeTensorPtr | |||
| end_i = x_dims.at(i); | |||
| stride_i = 1; | |||
| } | |||
| GELOGD("Before mask calculate. Begin is : %ld\t,end is : %ld\t stride is : %ld\t x_dim_i is : %ld.", | |||
| GELOGD("Before mask calculate. Begin is : %ld\t,end is : %ld\t stride is : %ld\t x_dim_i is : %ld", | |||
| begin_i, end_i, stride_i, x_dims.at(i)); | |||
| auto ret = MaskCal(i, begin_i, end_i, x_dims.at(i)); | |||
| if (ret != SUCCESS) { | |||
| @@ -258,7 +258,7 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector<ConstGeTensorPtr | |||
| return NOT_CHANGED; | |||
| } | |||
| int64_t dim_final; | |||
| GELOGD("Before stride calculate. Begin is : %ld\t,end is : %ld\t stride is : %ld\t x_dim_i is : %ld.", | |||
| GELOGD("Before stride calculate. Begin is : %ld\t,end is : %ld\t stride is : %ld\t x_dim_i is : %ld", | |||
| begin_i, end_i, stride_i, x_dims.at(i)); | |||
| (void) StrideCal(x_dims.at(i), begin_i, end_i, stride_i, dim_final); | |||
| output_dims.push_back(dim_final); | |||
| @@ -154,6 +154,7 @@ class HybridModel { | |||
| uint32_t model_id_ = 0; | |||
| uint8_t *var_mem_base_ = nullptr; | |||
| std::unique_ptr<TensorBuffer> weight_buffer_; | |||
| std::map<string, std::unique_ptr<TensorBuffer>> weight_buffer_map_; | |||
| RuntimeParam root_runtime_param_; | |||
| string om_name_; | |||
| }; | |||
| @@ -273,8 +273,8 @@ Status HybridModelBuilder::ParseForceInfershapeNodes(const NodePtr &node, NodeIt | |||
| // not care result, if no this attr, stand for the op does not need force infershape | |||
| (void)AttrUtils::GetBool(op_desc, kForceInfershape, node_item.is_need_force_infershape); | |||
| GELOGD("node [%s] is need do infershape , flag is %d", | |||
| op_desc->GetName().c_str(), | |||
| node_item.is_need_force_infershape); | |||
| op_desc->GetName().c_str(), | |||
| node_item.is_need_force_infershape); | |||
| return SUCCESS; | |||
| } | |||
| @@ -1012,70 +1012,65 @@ Status HybridModelBuilder::InitVariableTensors() { | |||
| Status HybridModelBuilder::InitWeights() { | |||
| // For constant in root graph | |||
| const auto &root_graph = ge_root_model_->GetRootGraph(); | |||
| const auto &subgraph_models = ge_root_model_->GetSubgraphInstanceNameToModel(); | |||
| auto iter = subgraph_models.find(root_graph->GetName()); | |||
| if (iter == subgraph_models.end()) { | |||
| GELOGD("Root graph model not found"); | |||
| return SUCCESS; | |||
| } | |||
| for (const auto &subgraph_model : ge_root_model_->GetSubgraphInstanceNameToModel()) { | |||
| const auto &weight_buffer = subgraph_model.second->GetWeight(); | |||
| if (weight_buffer.GetSize() == 0) { | |||
| GELOGD("weight is empty"); | |||
| return SUCCESS; | |||
| } | |||
| auto &root_model = iter->second; | |||
| const auto &weight_buffer = root_model->GetWeight(); | |||
| if (weight_buffer.GetSize() == 0) { | |||
| GELOGD("weight is empty"); | |||
| return SUCCESS; | |||
| } | |||
| auto allocator = NpuMemoryAllocator::GetAllocator(); | |||
| GE_CHECK_NOTNULL(allocator); | |||
| auto sub_weight_buffer = TensorBuffer::Create(allocator, weight_buffer.size()); | |||
| GE_CHECK_NOTNULL(sub_weight_buffer); | |||
| auto weight_base = reinterpret_cast<uint8_t *>(sub_weight_buffer->GetData()); | |||
| GE_CHK_RT_RET(rtMemcpy(weight_base, | |||
| sub_weight_buffer->GetSize(), | |||
| weight_buffer.GetData(), | |||
| weight_buffer.GetSize(), | |||
| RT_MEMCPY_HOST_TO_DEVICE)); | |||
| GELOGI("Init weight mem successfully, weight base %p, weight size = %zu", | |||
| weight_base, | |||
| sub_weight_buffer->GetSize()); | |||
| auto root_graph = GraphUtils::GetComputeGraph(subgraph_model.second->GetGraph()); | |||
| hybrid_model_.weight_buffer_map_.emplace(root_graph->GetName(),std::move(sub_weight_buffer)); | |||
| for (auto &node : root_graph->GetDirectNode()) { | |||
| if (node->GetType() != CONSTANT) { | |||
| continue; | |||
| } | |||
| auto allocator = NpuMemoryAllocator::GetAllocator(); | |||
| GE_CHECK_NOTNULL(allocator); | |||
| hybrid_model_.weight_buffer_ = TensorBuffer::Create(allocator, weight_buffer.size()); | |||
| GE_CHECK_NOTNULL(hybrid_model_.weight_buffer_); | |||
| auto weight_base = reinterpret_cast<uint8_t *>(hybrid_model_.weight_buffer_->GetData()); | |||
| GE_CHK_RT_RET(rtMemcpy(weight_base, | |||
| hybrid_model_.weight_buffer_->GetSize(), | |||
| weight_buffer.GetData(), | |||
| weight_buffer.GetSize(), | |||
| RT_MEMCPY_HOST_TO_DEVICE)); | |||
| GELOGI("Init weight mem successfully, weight base %p, weight size = %zu", | |||
| weight_base, | |||
| hybrid_model_.weight_buffer_->GetSize()); | |||
| for (auto &node : root_graph->GetDirectNode()) { | |||
| if (node->GetType() != CONSTANT) { | |||
| continue; | |||
| } | |||
| auto op_desc = node->GetOpDesc(); | |||
| auto v_weights = ModelUtils::GetWeights(op_desc); | |||
| if (v_weights.empty()) { | |||
| GELOGE(INTERNAL_ERROR, "[%s] Constant has no value", node->GetName().c_str()); | |||
| return INTERNAL_ERROR; | |||
| } | |||
| auto *ge_tensor = const_cast<GeTensor *>(v_weights[0].get()); | |||
| GE_CHECK_NOTNULL(ge_tensor); | |||
| const GeTensorDesc &tensor_desc = ge_tensor->GetTensorDesc(); | |||
| int64_t tensor_size = 0; | |||
| GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*op_desc->MutableOutputDesc(0), tensor_size), | |||
| "[%s] Failed to get tensor size", | |||
| node->GetName().c_str()); | |||
| int64_t data_offset = 0; | |||
| GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetDataOffset(tensor_desc, data_offset), | |||
| "[%s] Failed to get data offset", | |||
| node->GetName().c_str()); | |||
| GELOGD("[%s] Start to init Constant node [%s], size = %ld, offset = %ld", | |||
| GetGraphName(), | |||
| node->GetName().c_str(), | |||
| tensor_size, | |||
| data_offset); | |||
| auto op_desc = node->GetOpDesc(); | |||
| auto v_weights = ModelUtils::GetWeights(op_desc); | |||
| if (v_weights.empty()) { | |||
| GELOGE(INTERNAL_ERROR, "[%s] Constant has no value", node->GetName().c_str()); | |||
| return INTERNAL_ERROR; | |||
| auto tensor_buffer = TensorBuffer::Create(weight_base + data_offset, tensor_size); | |||
| GE_CHECK_NOTNULL(tensor_buffer); | |||
| std::unique_ptr<TensorValue> constant_tensor(new (std::nothrow)TensorValue(std::move(tensor_buffer))); | |||
| GE_CHECK_NOTNULL(constant_tensor); | |||
| constant_tensor->SetName("Constant_" + op_desc->GetName()); | |||
| hybrid_model_.constant_tensors_.emplace(node, std::move(constant_tensor)); | |||
| GELOGD("[%s] Constant node [%s] added, size = %ld", GetGraphName(), node->GetName().c_str(), tensor_size); | |||
| } | |||
| auto *ge_tensor = const_cast<GeTensor *>(v_weights[0].get()); | |||
| GE_CHECK_NOTNULL(ge_tensor); | |||
| const GeTensorDesc &tensor_desc = ge_tensor->GetTensorDesc(); | |||
| int64_t tensor_size = 0; | |||
| GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*op_desc->MutableOutputDesc(0), tensor_size), | |||
| "[%s] Failed to get tensor size", | |||
| node->GetName().c_str()); | |||
| int64_t data_offset = 0; | |||
| GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetDataOffset(tensor_desc, data_offset), | |||
| "[%s] Failed to get data offset", | |||
| node->GetName().c_str()); | |||
| GELOGD("[%s] Start to init Constant node [%s], size = %ld, offset = %ld", | |||
| GetGraphName(), | |||
| node->GetName().c_str(), | |||
| tensor_size, | |||
| data_offset); | |||
| auto tensor_buffer = TensorBuffer::Create(weight_base + data_offset, tensor_size); | |||
| GE_CHECK_NOTNULL(tensor_buffer); | |||
| std::unique_ptr<TensorValue> constant_tensor(new (std::nothrow)TensorValue(std::move(tensor_buffer))); | |||
| GE_CHECK_NOTNULL(constant_tensor); | |||
| constant_tensor->SetName("Constant_" + op_desc->GetName()); | |||
| hybrid_model_.constant_tensors_.emplace(node, std::move(constant_tensor)); | |||
| GELOGD("[%s] Constant node [%s] added, size = %ld", GetGraphName(), node->GetName().c_str(), tensor_size); | |||
| } | |||
| return SUCCESS; | |||
| } | |||
| @@ -149,14 +149,16 @@ Status NodeItem::InitInputsAndOutputs() { | |||
| if (AttrUtils::GetInt(op_desc, ::ge::ATTR_STAGE_LEVEL, group)) { | |||
| GELOGD("[%s] Got stage level from op_desc = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| if (AttrUtils::GetInt(node->GetOwnerComputeGraph(), ::ge::ATTR_STAGE_LEVEL, group)) { | |||
| GELOGD("[%s] Got stage level from parent graph = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| auto parent_node = node->GetOwnerComputeGraph()->GetParentNode(); | |||
| if ((parent_node != nullptr) && (AttrUtils::GetInt(parent_node->GetOpDesc(), ::ge::ATTR_STAGE_LEVEL, group))) { | |||
| GELOGD("[%s] Got stage level from parent node = %d", op_desc->GetName().c_str(), group); | |||
| if (node->GetOwnerComputeGraph() != nullptr) { | |||
| if (AttrUtils::GetInt(node->GetOwnerComputeGraph(), ::ge::ATTR_STAGE_LEVEL, group)) { | |||
| GELOGD("[%s] Got stage level from parent graph = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| GELOGD("[%s] Node do not set stage level", op_desc->GetName().c_str()); | |||
| auto parent_node = node->GetOwnerComputeGraph()->GetParentNode(); | |||
| if ((parent_node != nullptr) && (AttrUtils::GetInt(parent_node->GetOpDesc(), ::ge::ATTR_STAGE_LEVEL, group))) { | |||
| GELOGD("[%s] Got stage level from parent node = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| GELOGD("[%s] Node do not set stage level", op_desc->GetName().c_str()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -236,7 +236,7 @@ Status TaskContext::AllocateOutput(int index, | |||
| ref_node->GetName().c_str(), | |||
| ref_node->GetType().c_str()); | |||
| TensorValue *ref_tensor = execution_context_->model->GetVariable(ref_node->GetName()); | |||
| TensorValue *ref_tensor = execution_context_->model->GetTensor(ref_node); | |||
| GE_CHECK_NOTNULL(ref_tensor); | |||
| outputs_start_[index] = *ref_tensor; | |||
| } else { | |||
| @@ -34,6 +34,8 @@ const int64_t kDynamicImageSizeNum = 2; | |||
| const size_t kMaxDynamicDimNum = 100; | |||
| const size_t kMaxNDDimNum = 4; | |||
| 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 | |||
| const std::map<std::string, ge::DataType> kOutputTypeSupportDatatype = { | |||
| {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; | |||
| @@ -294,8 +296,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) { | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, | |||
| {shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample2}); | |||
| @@ -322,7 +324,7 @@ bool ParseSingleShapeRange(std::string &shape_range, vector<pair<int64_t, int64_ | |||
| } else { | |||
| 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. | |||
| long range_left = 0; | |||
| if (!StringToLongNoThrow(range_pair_set.at(0), range_left)) { | |||
| @@ -335,8 +337,10 @@ bool ParseSingleShapeRange(std::string &shape_range, vector<pair<int64_t, int64_ | |||
| if (range_left < 0 || (range_right < 0)) { | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, | |||
| {shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample3}); | |||
| GELOGE(PARAM_INVALID, "[Parse][Parameter]shape_range:%s invalid, reason: %s, correct sample is %s.", | |||
| shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample3); | |||
| GELOGE(PARAM_INVALID, | |||
| "Parse input parameter [--input_shape_range]'s shape range[%s] failed," | |||
| "reason: %s, correct sample is %s.", | |||
| shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample3); | |||
| return false; | |||
| } | |||
| range_pair = std::make_pair(range_left, range_right); | |||
| @@ -403,8 +407,8 @@ Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_i | |||
| if (param_size == 0) { | |||
| if (!input_shape_range.empty()) { | |||
| std::map<string, std::vector<std::pair<int64_t, int64_t>>> shape_range_map; | |||
| if(!ParseInputShapeRange(input_shape_range, shape_range_map)) { | |||
| GELOGE(ge::PARAM_INVALID, "[Parse][Param]input_shape_range: %s invalid.", input_shape_range.c_str()); | |||
| if (!ParseInputShapeRange(input_shape_range, shape_range_map)) { | |||
| GELOGE(ge::PARAM_INVALID, "Failed to parse input shape range: %s", input_shape_range.c_str()); | |||
| return ge::PARAM_INVALID; | |||
| } | |||
| } | |||
| @@ -31,7 +31,7 @@ | |||
| namespace ge { | |||
| static std::set<std::string> caffe_support_input_format = {"NCHW", "ND"}; | |||
| static std::set<std::string> tf_support_input_format = {"NCHW", "NHWC", "ND", "NCDHW", "NDHWC"}; | |||
| static std::set<std::string> onnx_support_input_format = {"NCHW", "ND"}; | |||
| static std::set<std::string> onnx_support_input_format = {"NCHW", "ND", "NCDHW"}; | |||
| static std::map<std::string, domiTensorFormat_t> input_format_str_to_geformat = { | |||
| {"ND", domi::DOMI_TENSOR_ND}, | |||
| @@ -70,7 +70,7 @@ const char *const kModeSupport = "only support 0(model to framework model), " | |||
| const char *const kModelToJsonSupport = "only support 0(Caffe) 3(TensorFlow) 5(Onnx)"; | |||
| const char *const kCaffeFormatSupport = "only support NCHW, ND in Caffe model"; | |||
| const char *const kTFFormatSupport = "only support NCHW, NHWC, ND, NCDHW, NDHWC in TF model"; | |||
| const char *const kONNXFormatSupport = "only support NCHW, ND in ONNX model"; | |||
| const char *const kONNXFormatSupport = "only support NCHW, ND, NCDHW in ONNX model"; | |||
| // limit available mem size 2G | |||
| const long kMinAvailableMem = 2097152; // 2 * 1024 * 1024 | |||
| } // namespace | |||
| @@ -793,7 +793,7 @@ FMK_FUNC_HOST_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::map<stri | |||
| std::string input_shape_range; | |||
| ParseAtcParms(atc_params, INPUT_SHAPE_RANGE, input_shape_range); | |||
| GE_RETURN_WITH_LOG_IF_ERROR(UpdateDynamicInputShapeRange(compute_graph, input_shape_range), | |||
| "Update input shape range failed"); | |||
| "Update input shape range failed"); | |||
| GELOGI("ATC parser success."); | |||
| @@ -56,9 +56,10 @@ inline bool IsLogEnable(int module_name, int log_level) { | |||
| return (enable == 1); | |||
| } | |||
| #define GELOGE(ERROR_CODE, fmt, ...) \ | |||
| dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ | |||
| ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) | |||
| #define GELOGE(ERROR_CODE, fmt, ...) \ | |||
| dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) %s" fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ | |||
| ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \ | |||
| ##__VA_ARGS__) | |||
| #define GELOGW(fmt, ...) \ | |||
| if (IsLogEnable(GE_MODULE_NAME, DLOG_WARN)) \ | |||
| dlog_warn(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) | |||
| @@ -255,10 +255,10 @@ | |||
| exec_expr1; \ | |||
| } | |||
| #define GE_ERRORLOG_AND_ERRORMSG(_status, errormsg) \ | |||
| { \ | |||
| GELOGE(_status, "%s", errormsg); \ | |||
| ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {errormsg}); \ | |||
| #define GE_ERRORLOG_AND_ERRORMSG(_status, errormsg) \ | |||
| { \ | |||
| GELOGE(_status, "[Check][InnerData]%s", errormsg); \ | |||
| REPORT_INNER_ERROR("E19999", "%s", errormsg); \ | |||
| } | |||
| #define GE_WARNINGLOG_AND_ERRORMSG(errormsg) \ | |||
| @@ -113,12 +113,12 @@ | |||
| } while (0) | |||
| // Check if the parameter is null. If yes, return PARAM_INVALID and record the error | |||
| #define GE_CHECK_NOTNULL(val) \ | |||
| do { \ | |||
| if (val == nullptr) { \ | |||
| DOMI_LOGE("param[%s] must not be null.", #val); \ | |||
| return ge::PARAM_INVALID; \ | |||
| } \ | |||
| #define GE_CHECK_NOTNULL(val) \ | |||
| do { \ | |||
| if (val == nullptr) { \ | |||
| DOMI_LOGE("[Check][Param:%s]null is invalid when %s.", #val, __FUNCTION__); \ | |||
| return ge::PARAM_INVALID; \ | |||
| } \ | |||
| } while (0) | |||
| // Check if the parameter is null. If yes, just return and record the error | |||
| @@ -31,6 +31,7 @@ | |||
| #include "omg/omg_inner_types.h" | |||
| namespace ge { | |||
| class GeRootModel; | |||
| class GE_FUNC_VISIBILITY GeGenerator { | |||
| public: | |||
| static GeGenerator &GetInstance() { | |||
| @@ -99,6 +100,9 @@ class GE_FUNC_VISIBILITY GeGenerator { | |||
| bool is_offline = true); | |||
| Status CheckForSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs); | |||
| using GeRootModelPtr = std::shared_ptr<ge::GeRootModel>; | |||
| Status SetModelNameForDump(const GeRootModelPtr &ge_root_model); | |||
| class Impl; | |||
| std::shared_ptr<Impl> impl_; | |||
| @@ -1 +1 @@ | |||
| Subproject commit deebd59d7ea015d7907db525596213492fe021b0 | |||
| Subproject commit eef990b3d8669065a969dfa6b1097eac09d601d4 | |||
| @@ -1 +1 @@ | |||
| Subproject commit eb4d9f3aa4cd0b567e3af6149e48ca2b15a3339e | |||
| Subproject commit 34464de38871aa46b0c7043798f96d340684a8cf | |||
| @@ -38,6 +38,7 @@ include_directories(${GE_CODE_DIR}/metadef/inc) | |||
| include_directories(${GE_CODE_DIR}/metadef/inc/graph) | |||
| include_directories(${GE_CODE_DIR}/metadef/inc/common) | |||
| include_directories(${GE_CODE_DIR}/metadef/third_party) | |||
| include_directories(${GE_CODE_DIR}/metadef/third_party/transformer/inc) | |||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc) | |||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/ops) | |||
| include_directories(${CMAKE_BINARY_DIR}) | |||
| @@ -98,8 +99,8 @@ set(SRC_FILES | |||
| "${GE_CODE_DIR}/metadef/graph/utils/transformer_utils.cc" | |||
| "${GE_CODE_DIR}/metadef/graph/runtime_inference_context.cc" | |||
| "${GE_CODE_DIR}/metadef/graph/ref_relation.cc" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cpp" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cpp" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cc" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cc" | |||
| ) | |||
| #add_executable(ut_libgraph ${UT_FILES} ${SRC_FILES} ${PROTO_SRCS} ${PROTO_HDRS}) | |||
| @@ -55,6 +55,7 @@ include_directories(${GE_CODE_DIR}/metadef/inc/graph) | |||
| include_directories(${GE_CODE_DIR}/inc/framework) | |||
| include_directories(${GE_CODE_DIR}/metadef/inc/common) | |||
| include_directories(${GE_CODE_DIR}/metadef/third_party) | |||
| include_directories(${GE_CODE_DIR}/metadef/third_party/transformer/inc) | |||
| include_directories(${GE_CODE_DIR}/parser) | |||
| include_directories(${GE_CODE_DIR}/parser/parser) | |||
| include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc) | |||
| @@ -87,8 +88,8 @@ set(GRAPH_SRC_FILES | |||
| "${GE_CODE_DIR}/metadef/graph/node.cc" | |||
| "${GE_CODE_DIR}/metadef/graph/runtime_inference_context.cc" | |||
| "${GE_CODE_DIR}/metadef/graph/op_desc.cc" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cpp" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cpp" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cc" | |||
| "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cc" | |||
| "${GE_CODE_DIR}/metadef/graph/operator.cc" | |||
| "${GE_CODE_DIR}/metadef/graph/operator_factory.cc" | |||
| "${GE_CODE_DIR}/metadef/graph/operator_factory_impl.cc" | |||
| @@ -569,7 +569,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape1) { | |||
| TransResult result; | |||
| 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) { | |||
| @@ -579,7 +579,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape2) { | |||
| TransResult result; | |||
| 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) { | |||
| @@ -588,7 +588,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape1) { | |||
| TransResult result; | |||
| 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) { | |||
| @@ -598,7 +598,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape2) { | |||
| TransResult result; | |||
| 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) { | |||
| @@ -608,7 +608,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_dst_shape_relation) { | |||
| TransResult result; | |||
| 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) { | |||
| @@ -618,10 +618,10 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_format) { | |||
| TransResult result; | |||
| FormatTransferNc1hwc0Nchw transfer; | |||
| EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); | |||
| EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); | |||
| Status status = | |||
| 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) { | |||
| @@ -631,7 +631,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_format) { | |||
| TransResult result; | |||
| 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) { | |||
| @@ -642,7 +642,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_data_type) { | |||
| TransResult result; | |||
| FormatTransferNc1hwc0Nchw transfer; | |||
| EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); | |||
| EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); | |||
| } | |||
| } // namespace formats | |||
| } // namespace ge | |||
| @@ -9148,7 +9148,7 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type3) { | |||
| 4, | |||
| 4, | |||
| }, | |||
| DT_VARIANT}; | |||
| DT_STRING}; | |||
| TransResult result; | |||
| FormatTransferFractalNzND transfer; | |||
| EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); | |||
| @@ -39,7 +39,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_data_type) { | |||
| TransResult result; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -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}; | |||
| 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) { | |||
| @@ -301,7 +301,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_eq_cube) { | |||
| } | |||
| Status status = | |||
| 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) { | |||
| @@ -5357,7 +5357,7 @@ TEST_F(UtestFormatTransferNhwcFz, build_transfer_uint8) { | |||
| TEST_F(UtestFormatTransferNhwcFz, invalid_data_type) { | |||
| uint16_t data[1 * 4 * 4 * 1] = {0}; | |||
| TransArgs args{ | |||
| reinterpret_cast<uint8_t *>(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_VARIANT}; | |||
| reinterpret_cast<uint8_t *>(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_STRING}; | |||
| FormatTransferFractalZ transfer; | |||
| EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), | |||
| ACL_ERROR_GE_DATATYPE_INVALID); | |||
| @@ -75,11 +75,11 @@ TEST_F(UtestFormatTransfer, get_size_by_data_type) { | |||
| EXPECT_EQ(GetSizeByDataType(DT_QINT32), 4); | |||
| EXPECT_EQ(GetSizeByDataType(DT_QUINT8), 1); | |||
| EXPECT_EQ(GetSizeByDataType(DT_QUINT16), 2); | |||
| EXPECT_EQ(GetSizeByDataType(DT_RESOURCE), -1); | |||
| EXPECT_EQ(GetSizeByDataType(DT_RESOURCE), 8); | |||
| EXPECT_EQ(GetSizeByDataType(DT_STRING_REF), -1); | |||
| EXPECT_EQ(GetSizeByDataType(DT_DUAL), 5); | |||
| EXPECT_EQ(GetSizeByDataType(DT_UNDEFINED), -1); | |||
| EXPECT_EQ(DT_UNDEFINED, 27); | |||
| EXPECT_EQ(DT_UNDEFINED, 28); | |||
| } | |||
| } // namespace formats | |||
| } // namespace ge | |||
| @@ -39,4 +39,10 @@ TEST_F(UtestGeExecutor, test_single_op_exec) { | |||
| EXPECT_EQ(exeutor.LoadSingleOp(model_name, model_data, nullptr, nullptr), ACL_ERROR_GE_INTERNAL_ERROR); | |||
| EXPECT_EQ(exeutor.LoadDynamicSingleOp(model_name, model_data, nullptr, nullptr), PARAM_INVALID); | |||
| } | |||
| TEST_F(UtestGeExecutor, test_ge_initialize) { | |||
| GeExecutor executor; | |||
| EXPECT_EQ(executor.Initialize(), SUCCESS); | |||
| EXPECT_EQ(executor.Initialize(), SUCCESS); | |||
| } | |||
| } // namespace ge | |||
| @@ -20,6 +20,12 @@ | |||
| #define protected public | |||
| #include "generator/ge_generator.h" | |||
| #include "graph/utils/tensor_utils.h" | |||
| #include "graph/attr_value.h" | |||
| #include "graph/debug/ge_attr_define.h" | |||
| #include "graph/utils/graph_utils.h" | |||
| #include "../graph/passes/graph_builder_utils.h" | |||
| #include "../graph/manager/graph_manager.h" | |||
| #include "all_ops.h" | |||
| using namespace std; | |||
| @@ -31,6 +37,16 @@ class UtestGeGenerator : public testing::Test { | |||
| void TearDown() {} | |||
| }; | |||
| namespace { | |||
| ComputeGraphPtr MakeGraph() { | |||
| ge::ut::GraphBuilder builder("graph"); | |||
| auto data = builder.AddNode("data", "Data", 1, 1); | |||
| auto addn1 = builder.AddNode("addn1", "AddN", 1, 1); | |||
| builder.AddDataEdge(data, 0, addn1, 0); | |||
| return builder.GetGraph(); | |||
| } | |||
| } // namespace | |||
| /* | |||
| TEST_F(UtestGeGenerator, test_build_single_op_offline) { | |||
| GeTensorDesc tensor_desc(GeShape(), FORMAT_NCHW, DT_FLOAT); | |||
| @@ -71,4 +87,38 @@ TEST_F(UtestGeGenerator, test_build_single_op_online) { | |||
| ModelBufferData model_buffer; | |||
| EXPECT_EQ(generator.BuildSingleOpModel(op_desc, inputs, outputs, ENGINE_AIVECTOR, model_buffer), FAILED); | |||
| } | |||
| TEST_F(UtestGeGenerator, test_graph_manager) { | |||
| GraphManager graph_manager; | |||
| GraphPartitioner graph_partitioner; | |||
| auto root_graph = MakeGraph(); | |||
| auto sub_graph = MakeGraph(); | |||
| root_graph->AddSubGraph(sub_graph); | |||
| auto sgi = MakeShared<SubGraphInfo>(); | |||
| // set engine name | |||
| sgi->SetEngineName("AIcoreEngine"); | |||
| sgi->SetSubGraph(sub_graph); | |||
| auto sgi_gelocal = MakeShared<SubGraphInfo>(); | |||
| // set engine name | |||
| sgi_gelocal->SetEngineName("GELOCAL"); | |||
| sgi_gelocal->SetSubGraph(sub_graph); | |||
| graph_partitioner.graph_2_input_subgraph_[root_graph] = sgi_gelocal; | |||
| graph_partitioner.graph_2_subgraph_list_.insert({root_graph, {sgi, sgi_gelocal}}); | |||
| graph_partitioner.graph_2_subgraph_list_.insert({sub_graph, {sgi, sgi_gelocal}}); | |||
| EXPECT_EQ(graph_manager.ConvertGraphToFile(root_graph, graph_partitioner, "./"), GRAPH_SUCCESS); | |||
| } | |||
| TEST_F(UtestGeGenerator, test_set_model_name) { | |||
| GeGenerator generator; | |||
| generator.Initialize({}); | |||
| GeRootModelPtr ge_root_model = make_shared<GeRootModel>(GeRootModel()); | |||
| ComputeGraphPtr graph = make_shared<ComputeGraph>(ComputeGraph("graph")); | |||
| (void)AttrUtils::SetBool(graph, "_dynamic_shape_partitioned", true); | |||
| ge_root_model->root_graph_ = std::move(graph); | |||
| EXPECT_EQ(generator.SetModelNameForDump(ge_root_model), SUCCESS); | |||
| } | |||
| } // namespace ge | |||
| @@ -36,13 +36,6 @@ class UtestModelHelper : public testing::Test { | |||
| void TearDown() override {} | |||
| }; | |||
| TEST_F(UtestModelHelper, save_size_to_modeldef_failed) | |||
| { | |||
| GeModelPtr ge_model = ge::MakeShared<ge::GeModel>(); | |||
| ModelHelper model_helper; | |||
| EXPECT_EQ(ACL_ERROR_GE_MEMORY_ALLOCATION, model_helper.SaveSizeToModelDef(ge_model)); | |||
| } | |||
| TEST_F(UtestModelHelper, save_size_to_modeldef) | |||
| { | |||
| GeModelPtr ge_model = ge::MakeShared<ge::GeModel>(); | |||
| @@ -67,4 +67,22 @@ TEST_F(UtestModelUtils, get_var_addr_rdma_hbm) { | |||
| EXPECT_EQ(reinterpret_cast<uint8_t *>(offset), var_addr); | |||
| 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 | |||
| @@ -67,6 +67,22 @@ class UtestTestPass : public BaseNodePass { | |||
| names_to_add_repass_.erase(iter); | |||
| } | |||
| } | |||
| // simulate infershape pass | |||
| if(node->GetType() == WHILE){ | |||
| bool need_repass = false; | |||
| AttrUtils::GetBool(node->GetOpDesc(),"need_infer_again_", need_repass); | |||
| if(!OptionExists(kOptimizeAfterSubGraph)){ | |||
| return SUCCESS; | |||
| } | |||
| if(need_repass){ | |||
| AttrUtils::SetBool(node->GetOpDesc(),"need_infer_again_", false); | |||
| AddImmediateRePassNode(node); | |||
| } | |||
| else{ | |||
| // clear attr on while | |||
| node->GetOpDesc()->DelAttr("need_infer_again_"); | |||
| } | |||
| } | |||
| return SUCCESS; | |||
| } | |||
| void clear() { iter_nodes_.clear(); } | |||
| @@ -429,6 +445,7 @@ TEST_F(UTESTGraphPassesBasePass, dead_loop) { | |||
| EXPECT_EQ(test_pass.GetRunTimes(), 1007); | |||
| } | |||
| */ | |||
| TEST_F(UTESTGraphPassesBasePass, while_loop) { | |||
| NamesToPass names_to_pass; | |||
| auto test_pass = UtestTestPass(true); | |||
| @@ -438,4 +455,69 @@ TEST_F(UTESTGraphPassesBasePass, while_loop) { | |||
| auto ge_pass = GEPass(graph); | |||
| EXPECT_EQ(ge_pass.Run(names_to_pass), SUCCESS); | |||
| } | |||
| /// data1 const | |||
| /// \ / | |||
| /// while | |||
| /// / \ | |||
| /// | | | |||
| /// cast1 cast2 | |||
| ComputeGraphPtr BuildWhileGraph1() { | |||
| // build sub graph | |||
| auto builder_sub = ut::GraphBuilder("sub"); | |||
| auto data_1 = builder_sub.AddNode("data_1", DATA, 0, 1); | |||
| auto data_2 = builder_sub.AddNode("data_2", DATA, 0, 1); | |||
| auto add = builder_sub.AddNode("add", ADD, 2, 1); | |||
| builder_sub.AddDataEdge(data_1, 0, add, 0); | |||
| builder_sub.AddDataEdge(data_2, 0, add, 1); | |||
| auto sub_graph = builder_sub.GetGraph(); | |||
| sub_graph->SetName("while_sub"); | |||
| // build root graph | |||
| auto builder = ut::GraphBuilder("g1"); | |||
| auto data = builder.AddNode("data1", DATA, 0, 1); | |||
| auto const_op = builder.AddNode("const_op", CONSTANT, 0, 1); | |||
| auto c1 = builder.AddNode("cast1", CAST, 1, 1); | |||
| auto c2 = builder.AddNode("cast2", CAST, 1, 1); | |||
| // add while op | |||
| auto tensor_desc = std::make_shared<GeTensorDesc>(); | |||
| tensor_desc->SetShape(GeShape({1,1,1,1})); | |||
| tensor_desc->SetFormat(FORMAT_ND); | |||
| tensor_desc->SetDataType(DT_INT32); | |||
| auto op_desc = std::make_shared<OpDesc>("while", WHILE); | |||
| for (int i = 0; i < 2; ++i) { | |||
| op_desc->AddInputDesc(tensor_desc->Clone()); | |||
| } | |||
| for (int i = 0; i < 2; ++i) { | |||
| op_desc->AddOutputDesc(tensor_desc->Clone()); | |||
| } | |||
| AttrUtils::SetBool(op_desc,"need_infer_again_", true); | |||
| op_desc->AddSubgraphName(sub_graph->GetName()); | |||
| op_desc->SetSubgraphInstanceName(0,sub_graph->GetName()); | |||
| auto root_graph = builder.GetGraph(); | |||
| auto while_op = root_graph->AddNode(op_desc); | |||
| builder.AddDataEdge(data, 0, while_op, 0); | |||
| builder.AddDataEdge(const_op, 0, while_op, 1); | |||
| builder.AddDataEdge(while_op, 0, c1, 0); | |||
| builder.AddDataEdge(while_op, 1, c2, 0); | |||
| sub_graph->SetParentGraph(root_graph); | |||
| sub_graph->SetParentNode(while_op); | |||
| root_graph->AddSubgraph(sub_graph); | |||
| return root_graph; | |||
| } | |||
| TEST_F(UTESTGraphPassesBasePass, while_infershape) { | |||
| NamesToPass names_to_pass; | |||
| auto test_pass = UtestTestPass(); | |||
| names_to_pass.push_back(std::make_pair("test", &test_pass)); | |||
| auto graph = BuildWhileGraph1(); | |||
| auto ge_pass = GEPass(graph); | |||
| auto while_node = graph->FindNode("while"); | |||
| EXPECT_EQ(while_node->GetOpDesc()->GetSubgraphInstanceNames().size(),1); | |||
| EXPECT_EQ(ge_pass.Run(names_to_pass), SUCCESS); | |||
| } | |||
| } // namespace ge | |||
| @@ -74,4 +74,18 @@ TEST_F(UtestGraphPreproces, test_dynamic_input_shape_parse) { | |||
| EXPECT_EQ(result_shape.GetDim(i), expect_shape.at(i)); | |||
| } | |||
| } | |||
| TEST_F(UtestGraphPreproces, test_check_user_input) { | |||
| ge::GraphPrepare graph_prepare; | |||
| graph_prepare.compute_graph_ = BuildGraph1(); | |||
| vector<int64_t> dim = {2, -3}; | |||
| GeTensor tensor; | |||
| tensor.SetTensorDesc(GeTensorDesc(GeShape(dim))); | |||
| std::vector<GeTensor> user_input; | |||
| user_input.emplace_back(tensor); | |||
| Status ret = graph_prepare.CheckUserInput(user_input); | |||
| EXPECT_EQ(ret, GE_GRAPH_INIT_FAILED); | |||
| } | |||
| } | |||
| @@ -15,8 +15,8 @@ | |||
| */ | |||
| #include <gtest/gtest.h> | |||
| #include <gmock/gmock.h> | |||
| #include <vector> | |||
| #include "runtime/rt.h" | |||
| #define protected public | |||
| @@ -25,7 +25,6 @@ | |||
| #include "hybrid/model/hybrid_model.h" | |||
| #include "model/ge_model.h" | |||
| #include "model/ge_root_model.h" | |||
| #include "hybrid/node_executor/aicore/aicore_op_task.h" | |||
| #include "framework/common/taskdown_common.h" | |||
| #include "framework/common/debug/log.h" | |||
| @@ -33,7 +32,10 @@ | |||
| #include "hybrid/executor/hybrid_execution_context.h" | |||
| #include "hybrid/node_executor/aicore/aicore_task_builder.h" | |||
| #include "graph/load/model_manager/tbe_handle_store.h" | |||
| #include "graph/manager/graph_mem_allocator.h" | |||
| #include "hybrid/common/npu_memory_allocator.h" | |||
| #include "graph/types.h" | |||
| #include "graph/utils/tensor_utils.h" | |||
| #undef private | |||
| #undef protected | |||
| @@ -43,6 +45,7 @@ using namespace testing; | |||
| using namespace ge; | |||
| using namespace hybrid; | |||
| class UtestGeHybrid : public testing::Test { | |||
| protected: | |||
| void SetUp() {} | |||
| @@ -204,4 +207,39 @@ TEST_F(UtestGeHybrid, index_taskdefs_success) { | |||
| HybridModelBuilder hybrid_model_builder(hybrid_model); | |||
| ASSERT_EQ(hybrid_model_builder.IndexTaskDefs(graph, ge_model), SUCCESS); | |||
| } | |||
| TEST_F(UtestGeHybrid, init_weight_success) { | |||
| NpuMemoryAllocator::allocators_.emplace(make_pair(0, nullptr)); | |||
| // make graph with sub_graph | |||
| ComputeGraphPtr graph = std::make_shared<ComputeGraph>("root_graph"); | |||
| OpDescPtr op_desc = CreateOpDesc("if", IF); | |||
| NodePtr node = graph->AddNode(op_desc); | |||
| // make sub graph | |||
| ComputeGraphPtr sub_graph = std::make_shared<ComputeGraph>("if_sub_graph"); | |||
| OpDescPtr const_op_desc = CreateOpDesc("const", CONSTANT); | |||
| vector<int64_t> dims_vec_0 = {2, 1, 4, 1, 2}; | |||
| vector<int32_t> data_vec_0 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; | |||
| GeTensorDesc tensor_desc_0(GeShape(dims_vec_0), FORMAT_NCHW, DT_INT32); | |||
| (void)TensorUtils::SetRealDimCnt(tensor_desc_0, dims_vec_0.size()); | |||
| ConstGeTensorPtr constTensor_0 = | |||
| std::make_shared<GeTensor>(tensor_desc_0, (uint8_t *)&data_vec_0[0], data_vec_0.size() * sizeof(int32_t)); | |||
| AttrUtils::SetTensor(const_op_desc, ge::ATTR_NAME_WEIGHTS, constTensor_0); | |||
| const_op_desc->AddOutputDesc(tensor_desc_0); | |||
| NodePtr const_node = sub_graph->AddNode(const_op_desc); | |||
| graph->AddSubgraph("sub", sub_graph); | |||
| GeRootModelPtr ge_root_model = make_shared<GeRootModel>(graph); | |||
| GeModelPtr ge_sub_model = make_shared<GeModel>(); | |||
| //Buffer weight_buffer = Buffer(128,0); | |||
| //ge_sub_model->SetWeight(weight_buffer); | |||
| ge_root_model->SetSubgraphInstanceNameToModel("sub",ge_sub_model); | |||
| HybridModel hybrid_model(ge_root_model); | |||
| HybridModelBuilder hybrid_model_builder(hybrid_model); | |||
| auto ret = hybrid_model_builder.InitWeights(); | |||
| ASSERT_EQ(ret,SUCCESS); | |||
| Buffer weight_buffer = Buffer(128,0); | |||
| ge_sub_model->SetWeight(weight_buffer); | |||
| ret = hybrid_model_builder.InitWeights(); | |||
| ASSERT_EQ(ret,PARAM_INVALID); | |||
| } | |||