@@ -37,7 +37,10 @@ bool KernelStore::Build() { | |||||
try { | try { | ||||
buffer_.resize(total_len); | buffer_.resize(total_len); | ||||
} catch (std::bad_alloc &e) { | } catch (std::bad_alloc &e) { | ||||
GELOGE(ge::MEMALLOC_FAILED, "All build memory failed, memory size %zu", total_len); | |||||
GELOGE(ge::MEMALLOC_FAILED, "[Malloc][Memmory]Resize buffer failed, memory size %zu, " | |||||
"exception %s", total_len, e.what()); | |||||
REPORT_CALL_ERROR("E19999", "Resize buffer failed, memory size %zu, exception %s", | |||||
total_len, e.what()); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -31,18 +31,24 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro | |||||
ge::ModelData &model_data) { | ge::ModelData &model_data) { | ||||
std::string real_path = RealPath(model_path); | std::string real_path = RealPath(model_path); | ||||
if (real_path.empty()) { | if (real_path.empty()) { | ||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Model file path '%s' is invalid", model_path); | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param]Model file path %s is invalid", | |||||
model_path); | |||||
REPORT_INNER_ERROR("E19999", "Model file path %s is invalid", model_path); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | ||||
} | } | ||||
if (GetFileLength(model_path) == -1) { | if (GetFileLength(model_path) == -1) { | ||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "File size not valid, file: %s.", model_path); | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param]File size not valid, file %s", | |||||
model_path); | |||||
REPORT_INNER_ERROR("E19999", "File size not valid, file %s", model_path); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | ||||
} | } | ||||
std::ifstream fs(real_path.c_str(), std::ifstream::binary); | std::ifstream fs(real_path.c_str(), std::ifstream::binary); | ||||
if (!fs.is_open()) { | if (!fs.is_open()) { | ||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Open file: %s failed, error: %s", model_path, strerror(errno)); | |||||
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Open][File]Failed, file %s, error %s", | |||||
model_path, strerror(errno)); | |||||
REPORT_CALL_ERROR("E19999", "Open file %s failed, error %s", model_path, strerror(errno)); | |||||
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; | ||||
} | } | ||||
@@ -56,7 +62,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro | |||||
char *data = new (std::nothrow) char[len]; | char *data = new (std::nothrow) char[len]; | ||||
if (data == nullptr) { | if (data == nullptr) { | ||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Load model From file failed, bad memory allocation occur. (need:%u)", len); | |||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Load][ModelFromFile]Failed, " | |||||
"bad memory allocation occur(need %u), file %s", len, model_path); | |||||
REPORT_CALL_ERROR("E19999", "Load model from file %s failed, " | |||||
"bad memory allocation occur(need %u)", model_path, len); | |||||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | return ACL_ERROR_GE_MEMORY_ALLOCATION; | ||||
} | } | ||||
@@ -105,7 +114,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo | |||||
model_len = file_header->length; | model_len = file_header->length; | ||||
GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader)); | GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader)); | ||||
} else { | } else { | ||||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid model. ModelEncryptType not supported."); | |||||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Param]Invalid, model encrypt type not supported"); | |||||
REPORT_CALL_ERROR("E19999","Invalid model ,encrypt type not supported"); | |||||
res = ACL_ERROR_GE_PARAM_INVALID; | res = ACL_ERROR_GE_PARAM_INVALID; | ||||
} | } | ||||
@@ -33,7 +33,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi | |||||
const Json &model) { | const Json &model) { | ||||
Status ret = SUCCESS; | Status ret = SUCCESS; | ||||
if (file_path == nullptr || SUCCESS != CheckPath(file_path)) { | if (file_path == nullptr || SUCCESS != CheckPath(file_path)) { | ||||
GELOGE(FAILED, "Check output file failed."); | |||||
GELOGE(FAILED, "[Check][OutputFile]Failed, file %s", file_path); | |||||
REPORT_CALL_ERROR("E19999", "Output file %s check invalid", file_path); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
std::string model_str; | std::string model_str; | ||||
@@ -41,11 +42,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi | |||||
model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore); | model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore); | ||||
} catch (std::exception &e) { | } catch (std::exception &e) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19007", {"exception"}, {e.what()}); | ErrorManager::GetInstance().ATCReportErrMessage("E19007", {"exception"}, {e.what()}); | ||||
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what()); | |||||
GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s, reason %s", | |||||
file_path, e.what()); | |||||
return FAILED; | return FAILED; | ||||
} catch (...) { | } catch (...) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19008"); | ErrorManager::GetInstance().ATCReportErrMessage("E19008"); | ||||
GELOGE(FAILED, "Failed to convert JSON to string."); | |||||
GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s", file_path); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
@@ -59,7 +61,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi | |||||
int32_t fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); | int32_t fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); | ||||
if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { | if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)}); | ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)}); | ||||
GELOGE(FAILED, "Open file[%s] failed. errmsg:%s", file_path, strerror(errno)); | |||||
GELOGE(FAILED, "[Open][File]Failed, file %s, errmsg %s", file_path, strerror(errno)); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
const char *model_char = model_str.c_str(); | const char *model_char = model_str.c_str(); | ||||
@@ -70,12 +72,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | ErrorManager::GetInstance().ATCReportErrMessage( | ||||
"E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); | "E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); | ||||
// Need to both print the error info of mmWrite and mmClose, so return ret after mmClose | // Need to both print the error info of mmWrite and mmClose, so return ret after mmClose | ||||
GELOGE(FAILED, "Write to file failed. errno:%ld, errmsg:%s", mmpa_ret, strerror(errno)); | |||||
GELOGE(FAILED, "[Write][Data]To file %s failed. errno %ld, errmsg %s", file_path, mmpa_ret, strerror(errno)); | |||||
ret = FAILED; | ret = FAILED; | ||||
} | } | ||||
// Close file | // Close file | ||||
if (mmClose(fd) != EN_OK) { | if (mmClose(fd) != EN_OK) { | ||||
GELOGE(FAILED, "Close file failed. errmsg:%s", strerror(errno)); | |||||
REPORT_CALL_ERROR("E19999", "Close file %s failed, errmsg %s", file_path, strerror(errno)); | |||||
GELOGE(FAILED, "[Close][File]Failed, file %s, errmsg %s", file_path, strerror(errno)); | |||||
ret = FAILED; | ret = FAILED; | ||||
} | } | ||||
return ret; | return ret; | ||||
@@ -239,7 +239,8 @@ Status OpUtils::SetDataByDataType(size_t out_size, const std::vector<char *> &ch | |||||
const std::vector<char *> &chunk_output, GeTensor *output) { | const std::vector<char *> &chunk_output, GeTensor *output) { | ||||
unique_ptr<T[]> output_data(new (std::nothrow) T[out_size]()); | unique_ptr<T[]> output_data(new (std::nothrow) T[out_size]()); | ||||
if (output_data == nullptr) { | if (output_data == nullptr) { | ||||
GELOGE(MEMALLOC_FAILED, "New buf failed"); | |||||
GELOGE(MEMALLOC_FAILED, "[Malloc][Data]New buf failed"); | |||||
REPORT_CALL_ERROR("E19999", "New buf failed"); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
@@ -275,7 +276,10 @@ Status OpUtils::SetOutputSliceDataByDataType(void *data, int64_t data_size, cons | |||||
int64_t dim_i = input_dims[i]; | int64_t dim_i = input_dims[i]; | ||||
int64_t stride_i = stride[i]; | int64_t stride_i = stride[i]; | ||||
if (dim_i == 0) { | if (dim_i == 0) { | ||||
GELOGE(PARAM_INVALID, "Dim_i of size tensor can't be 0."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Invalid, Dim_i $%s of size tensor is 0", | |||||
ShapeToString(input_dims[i]).c_str()); | |||||
REPORT_INNER_ERROR("E19999", "Dim_i %s of size tensor is 0, invalid", | |||||
ShapeToString(input_dims[i]).c_str()); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
chunk_size = chunk_size / dim_i; | chunk_size = chunk_size / dim_i; | ||||
@@ -299,7 +303,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetOutputSliceD | |||||
void *data, int64_t data_size, int32_t data_type, std::vector<int64_t> &input_dims, std::vector<int64_t> &begin, | void *data, int64_t data_size, int32_t data_type, std::vector<int64_t> &input_dims, std::vector<int64_t> &begin, | ||||
std::vector<int64_t> &output_dims, GeTensor *output, std::vector<int64_t> &stride) { | std::vector<int64_t> &output_dims, GeTensor *output, std::vector<int64_t> &stride) { | ||||
if (data == nullptr || output == nullptr) { | if (data == nullptr || output == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Input param is nullptr."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Input param is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "Input param is nullptr"); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
@@ -436,14 +441,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetWeights(ge:: | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | ||||
OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims) { | OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims) { | ||||
if (tensor == nullptr) { | if (tensor == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Input tensor is nullptr"); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Input tensor is nullptr"); | |||||
REPORT_INNER_ERROR("E19999","Input tensor is nullptr"); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
// If the tensor data is a vector, the shape dimension must be 1 | // If the tensor data is a vector, the shape dimension must be 1 | ||||
if (tensor->GetTensorDesc().GetShape().GetDims().size() > 1) { | if (tensor->GetTensorDesc().GetShape().GetDims().size() > 1) { | ||||
GELOGE(PARAM_INVALID, "The dimension of the input tensor shape cannot be more than 1, it is %zu", | |||||
GELOGE(PARAM_INVALID, "[Check][Param]The dimension of the input tensor shape " | |||||
"cannot be more than 1, it is %zu", | |||||
tensor->GetTensorDesc().GetShape().GetDims().size()); | tensor->GetTensorDesc().GetShape().GetDims().size()); | ||||
REPORT_CALL_ERROR("E19999", "The dimension of the input tensor shape %zu invalid, " | |||||
"more than 1", tensor->GetTensorDesc().GetShape().GetDims().size()); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
@@ -462,8 +471,10 @@ OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType ty | |||||
dims.push_back(shape_data[i]); | dims.push_back(shape_data[i]); | ||||
} | } | ||||
} else { | } else { | ||||
GELOGE(PARAM_INVALID, "Data type only can be DT_INT32 or DT_INT64. type is %s", | |||||
TypeUtils::DataTypeToSerialString(type).c_str()); | |||||
GELOGE(PARAM_INVALID, "[Check][DataType]Invalid, type only can be DT_INT32 or DT_INT64, " | |||||
"type is %s", TypeUtils::DataTypeToSerialString(type).c_str()); | |||||
REPORT_INNER_ERROR("E19999", "Data type %s check invalid, only can be DT_INT32 or DT_INT64", | |||||
TypeUtils::DataTypeToSerialString(type).c_str()); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
@@ -67,11 +67,13 @@ bool TransProfConfigToParam(const ProfCommandHandleData &profCommand, vector<str | |||||
bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { | bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { | ||||
if (deviceid_list == nullptr) { | if (deviceid_list == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "deviceIdList is nullptr"); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DeviceIDList]Invalid, it is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "Device id list is nullptr"); | |||||
return false; | return false; | ||||
} | } | ||||
if (device_nums == 0 || device_nums > MAX_DEV_NUM) { | if (device_nums == 0 || device_nums > MAX_DEV_NUM) { | ||||
GELOGE(ge::PARAM_INVALID, "The device nums: %u is invalid.", device_nums); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DeviceNums]Invalid, device nums: %u", device_nums); | |||||
REPORT_INNER_ERROR("E19999", "DeviceNums %u check invalid", device_nums); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -79,12 +81,16 @@ bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { | |||||
int32_t dev_count = 0; | int32_t dev_count = 0; | ||||
rtError_t rt_err = rtGetDeviceCount(&dev_count); | rtError_t rt_err = rtGetDeviceCount(&dev_count); | ||||
if (rt_err != RT_ERROR_NONE) { | if (rt_err != RT_ERROR_NONE) { | ||||
GELOGE(ge::INTERNAL_ERROR, "Get the Device count fail."); | |||||
GELOGE(ge::INTERNAL_ERROR, "[Get][DeviceCount]Failed, error_code %d", rt_err); | |||||
REPORT_CALL_ERROR("E19999", "Get device count failed, error_code %d", rt_err); | |||||
return false; | return false; | ||||
} | } | ||||
if (device_nums > static_cast<uint32_t>(dev_count)) { | if (device_nums > static_cast<uint32_t>(dev_count)) { | ||||
GELOGE(ge::PARAM_INVALID, "Device num(%u) is not in range 1 ~ %d.", device_nums, dev_count); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]Device num %u is not in range [1,%d]", | |||||
device_nums, dev_count); | |||||
REPORT_INNER_ERROR("E19999", "Device num %u check invalid, it is not in range [1,%d]", | |||||
device_nums, dev_count); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -92,11 +98,14 @@ bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { | |||||
for (size_t i = 0; i < device_nums; ++i) { | for (size_t i = 0; i < device_nums; ++i) { | ||||
uint32_t dev_id = deviceid_list[i]; | uint32_t dev_id = deviceid_list[i]; | ||||
if (dev_id >= static_cast<uint32_t>(dev_count)) { | if (dev_id >= static_cast<uint32_t>(dev_count)) { | ||||
GELOGE(ge::PARAM_INVALID, "Device id %u is not in range 0 ~ %d(exclude %d)", dev_id, dev_count, dev_count); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DeviceId]Device id %u is not in range [0,%d)", | |||||
dev_id, dev_count); | |||||
REPORT_CALL_ERROR("E19999", "Device id %u is not in range [0,%d)", dev_id, dev_count); | |||||
return false; | return false; | ||||
} | } | ||||
if (record.count(dev_id) > 0) { | if (record.count(dev_id) > 0) { | ||||
GELOGE(ge::PARAM_INVALID, "Device id %u is duplicatedly set", dev_id); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DeviceId]Device id %u is duplicatedly set", dev_id); | |||||
REPORT_CALL_ERROR("E19999", "Device id %u is not unique, duplicatedly set", dev_id); | |||||
return false; | return false; | ||||
} | } | ||||
record.insert(dev_id); | record.insert(dev_id); | ||||
@@ -106,7 +115,8 @@ bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { | |||||
ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) { | ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) { | ||||
if (func == nullptr) { | if (func == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "Msprof ctrl callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]Msprof ctrl callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "Msprof ctrl callback is nullptr"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) { | if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) { | ||||
@@ -119,13 +129,15 @@ ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) { | |||||
ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) { | ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) { | ||||
if (func == nullptr) { | if (func == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "MsprofSetDeviceCallback callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofSetDeviceCallback callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "MsprofSetDeviceCallback callback is nullptr"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
// Pass MsprofSetDeviceCallback to runtime | // Pass MsprofSetDeviceCallback to runtime | ||||
ge::Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName.c_str(), static_cast<rtDeviceStateCallback>(func)); | ge::Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName.c_str(), static_cast<rtDeviceStateCallback>(func)); | ||||
if (rt_ret != ge::SUCCESS) { | if (rt_ret != ge::SUCCESS) { | ||||
GELOGE(rt_ret, "Pass MsprofSetDeviceCallback to runtime failed!"); | |||||
GELOGE(rt_ret, "[Pass][MsprofSetDeviceCallback]To runtime failed!"); | |||||
REPORT_CALL_ERROR("E19999", "Pass MsprofSetDeviceCallback to runtime failed, ret 0x%X", rt_ret); | |||||
return rt_ret; | return rt_ret; | ||||
} | } | ||||
return ge::SUCCESS; | return ge::SUCCESS; | ||||
@@ -133,7 +145,8 @@ ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) { | |||||
ge::Status RegProfReporterCallback(MsprofReporterCallback func) { | ge::Status RegProfReporterCallback(MsprofReporterCallback func) { | ||||
if (func == nullptr) { | if (func == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofReporterCallback != nullptr) { | if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofReporterCallback != nullptr) { | ||||
@@ -144,7 +157,10 @@ ge::Status RegProfReporterCallback(MsprofReporterCallback func) { | |||||
// Pass MsprofReporterCallback to runtime | // Pass MsprofReporterCallback to runtime | ||||
ge::Status rt_ret = rtSetMsprofReporterCallback(func); | ge::Status rt_ret = rtSetMsprofReporterCallback(func); | ||||
if (rt_ret != ge::SUCCESS) { | if (rt_ret != ge::SUCCESS) { | ||||
GELOGE(rt_ret, "Pass MsprofReporterCallback to runtime failed!!"); | |||||
GELOGE(rt_ret, "[Pass][Param]Pass MsprofReporterCallback to runtime failed, error_code %u", | |||||
rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Pass MsprofReporterCallback to runtime failed, error_code %u", | |||||
rt_ret); | |||||
return rt_ret; | return rt_ret; | ||||
} | } | ||||
// Pass MsprofReporterCallback to hccl | // Pass MsprofReporterCallback to hccl | ||||
@@ -167,9 +183,10 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le | |||||
if (!isProfConfigValid(prof_config_param->devIdList, prof_config_param->devNums)) { | if (!isProfConfigValid(prof_config_param->devIdList, prof_config_param->devNums)) { | ||||
return ge::FAILED; | return ge::FAILED; | ||||
} | } | ||||
if (!TransProfConfigToParam(*prof_config_param, prof_params)) { | if (!TransProfConfigToParam(*prof_config_param, prof_params)) { | ||||
GELOGE(ge::PARAM_INVALID, "Transfer profilerConfig to string vector failed"); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]Transfer profilerConfig to string vector failed"); | |||||
REPORT_CALL_ERROR("E19999", "Transfer profilerConfig to string vector failed"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
} | } | ||||
@@ -188,7 +205,10 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le | |||||
} | } | ||||
ge::Status ret = graph_loader.CommandHandle(command); | ge::Status ret = graph_loader.CommandHandle(command); | ||||
if (ret != ge::SUCCESS) { | if (ret != ge::SUCCESS) { | ||||
GELOGE(ret, "Handle profiling command failed"); | |||||
GELOGE(ret, "[Handle][Command]Handle profiling command failed, command type %s, error_code %u", | |||||
iter->second.c_str(), ret); | |||||
REPORT_CALL_ERROR("E19999", "Handle profiling command failed, command type %s, error_code %u", | |||||
iter->second.c_str(), ret); | |||||
return ge::FAILED; | return ge::FAILED; | ||||
} | } | ||||
@@ -87,21 +87,26 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In | |||||
struct MsprofGeOptions prof_conf = {{ 0 }}; | struct MsprofGeOptions prof_conf = {{ 0 }}; | ||||
Status ret = InitFromOptions(options, prof_conf); | Status ret = InitFromOptions(options, prof_conf); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "Failed to init profiling."); | |||||
GELOGE(ret, "[Init][Profiling]Failed, error_code %u", ret); | |||||
REPORT_CALL_ERROR("E19999", "Init profiling failed, error_code %u", ret); | |||||
return ret; | return ret; | ||||
} | } | ||||
if (is_execute_profiling_) { | if (is_execute_profiling_) { | ||||
if (prof_cb_.msprofCtrlCallback == nullptr) { | if (prof_cb_.msprofCtrlCallback == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "MsprofCtrlCallback callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofCtrlCallback callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "MsprofCtrlCallback callback is nullptr"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
int32_t cb_ret = prof_cb_.msprofCtrlCallback( | int32_t cb_ret = prof_cb_.msprofCtrlCallback( | ||||
static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), | static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), | ||||
static_cast<void *>(&prof_conf), sizeof(MsprofGeOptions)); | static_cast<void *>(&prof_conf), sizeof(MsprofGeOptions)); | ||||
if (cb_ret != 0) { | if (cb_ret != 0) { | ||||
GELOGE(FAILED, "Call msprofCtrlCallback failed, type:%u, return:%d", | |||||
GELOGE(FAILED, "[Call][msprofCtrlCallback]Failed, type %u, return %d", | |||||
static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), cb_ret); | static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), cb_ret); | ||||
REPORT_CALL_ERROR("E19999", "Call msprofCtrlCallback failed, type %u, return %d", | |||||
static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_INIT_GE_OPTIONS), | |||||
cb_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
GELOGI("Profiling init success"); | GELOGI("Profiling init success"); | ||||
@@ -122,7 +127,10 @@ ge::Status ProfilingManager::InitFromOptions(const Options &options, MsprofGeOpt | |||||
// enable profiling by ge option | // enable profiling by ge option | ||||
if (strncpy_s(prof_conf.options, MSPROF_OPTIONS_DEF_LEN_MAX, options.profiling_options.c_str(), | if (strncpy_s(prof_conf.options, MSPROF_OPTIONS_DEF_LEN_MAX, options.profiling_options.c_str(), | ||||
MSPROF_OPTIONS_DEF_LEN_MAX - 1) != EOK) { | MSPROF_OPTIONS_DEF_LEN_MAX - 1) != EOK) { | ||||
GELOGE(INTERNAL_ERROR, "copy profiling_options failed."); | |||||
GELOGE(INTERNAL_ERROR, "[copy][ProfilingOptions]Failed, options %s", | |||||
options.profiling_options.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Copy profiling_options %s failed", | |||||
options.profiling_options.c_str()); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
is_execute_profiling_ = true; | is_execute_profiling_ = true; | ||||
@@ -147,13 +155,17 @@ ge::Status ProfilingManager::InitFromOptions(const Options &options, MsprofGeOpt | |||||
// Parse json str for bp fp | // Parse json str for bp fp | ||||
Status ret = ParseOptions(prof_conf.options); | Status ret = ParseOptions(prof_conf.options); | ||||
if (ret != ge::SUCCESS) { | if (ret != ge::SUCCESS) { | ||||
GELOGE(ge::PARAM_INVALID, "Parse training trace param failed."); | |||||
GELOGE(ge::PARAM_INVALID, "[Parse][Options]Parse training trace param %s failed, error_code %u", | |||||
prof_conf.options, ret); | |||||
REPORT_CALL_ERROR("E19999", "Parse training trace param %s failed, error_code %u", | |||||
prof_conf.options, ret); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
if (strncpy_s(prof_conf.jobId, MSPROF_OPTIONS_DEF_LEN_MAX, options.job_id.c_str(), MSPROF_OPTIONS_DEF_LEN_MAX - 1) != | if (strncpy_s(prof_conf.jobId, MSPROF_OPTIONS_DEF_LEN_MAX, options.job_id.c_str(), MSPROF_OPTIONS_DEF_LEN_MAX - 1) != | ||||
EOK) { | EOK) { | ||||
GELOGE(INTERNAL_ERROR, "copy job_id failed."); | |||||
GELOGE(INTERNAL_ERROR, "[Copy][JobId]Failed, original job_id %s", options.job_id.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Copy job_id %s failed", options.job_id.c_str()); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
GELOGI("Job id: %s, original job id: %s.", prof_conf.jobId, options.job_id.c_str()); | GELOGI("Job id: %s, original job id: %s.", prof_conf.jobId, options.job_id.c_str()); | ||||
@@ -163,7 +175,8 @@ ge::Status ProfilingManager::InitFromOptions(const Options &options, MsprofGeOpt | |||||
ge::Status ProfilingManager::ParseOptions(const std::string &options) { | ge::Status ProfilingManager::ParseOptions(const std::string &options) { | ||||
if (options.empty()) { | if (options.empty()) { | ||||
GELOGE(ge::PARAM_INVALID, "Profiling options is empty."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]Profiling options is empty"); | |||||
REPORT_INNER_ERROR("E19999", "Profiling options is empty"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
try { | try { | ||||
@@ -178,7 +191,9 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) { | |||||
} | } | ||||
GELOGI("GE profiling training trace:%s", training_trace.c_str()); | GELOGI("GE profiling training trace:%s", training_trace.c_str()); | ||||
if (training_trace != "on") { | if (training_trace != "on") { | ||||
GELOGE(ge::PARAM_INVALID, "Training trace param:%s is invalid.", training_trace.c_str()); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]Training trace param:%s is invalid.", | |||||
training_trace.c_str()); | |||||
REPORT_INNER_ERROR("E19999", "Training trace param:%s is invalid.", training_trace.c_str()); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
fp_point_ = prof_options[kFpPoint]; | fp_point_ = prof_options[kFpPoint]; | ||||
@@ -188,7 +203,8 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) { | |||||
} | } | ||||
is_training_trace_ = true; | is_training_trace_ = true; | ||||
} catch (...) { | } catch (...) { | ||||
GELOGE(FAILED, "Json prof_conf options is invalid."); | |||||
GELOGE(FAILED, "[Check][Param]Json prof_conf options is invalid"); | |||||
REPORT_INNER_ERROR("E19999", "Json prof_conf options is invalid"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
return ge::SUCCESS; | return ge::SUCCESS; | ||||
@@ -202,7 +218,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf | |||||
if (device_num != 0) { | if (device_num != 0) { | ||||
auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | ||||
if (device_id_ptr == nullptr) { | if (device_id_ptr == nullptr) { | ||||
GELOGE(FAILED, "Stop profiling: device id ptr is null."); | |||||
GELOGE(FAILED, "[Stop][Profiling]Device id ptr is null."); | |||||
REPORT_INNER_ERROR("E19999", "Stop profiling, device id ptr is null"); | |||||
return; | return; | ||||
} | } | ||||
for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
@@ -216,7 +233,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf | |||||
// stop profiling | // stop profiling | ||||
if (prof_cb_.msprofCtrlCallback == nullptr) { | if (prof_cb_.msprofCtrlCallback == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "MsprofCtrlCallback callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofCtrlCallback callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "MsprofCtrlCallback callback is nullptr"); | |||||
return; | return; | ||||
} | } | ||||
int32_t cb_ret = prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE), | int32_t cb_ret = prof_cb_.msprofCtrlCallback(static_cast<uint32_t>(MsprofCtrlCallbackType::MSPROF_CTRL_FINALIZE), | ||||
@@ -278,10 +296,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
try { | try { | ||||
reported_data = task_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore); | reported_data = task_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore); | ||||
} catch (std::exception &e) { | } catch (std::exception &e) { | ||||
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what()); | |||||
GELOGE(FAILED, "[Convert][ReportData]Failed to convert json to string, reason %s.", | |||||
e.what()); | |||||
REPORT_CALL_ERROR("E19999", "Failed to convert reported_data from json to string, reason %s", | |||||
e.what()); | |||||
return ; | return ; | ||||
} catch (...) { | } catch (...) { | ||||
GELOGE(FAILED, "Failed to convert JSON to string."); | |||||
GELOGE(FAILED, "[Convert][ReportedData]Failed to convert JSON to string"); | |||||
REPORT_CALL_ERROR("E19999", "Failed to convert reported data from json to string"); | |||||
return; | return; | ||||
} | } | ||||
reported_data.append(",") | reported_data.append(",") | ||||
@@ -300,7 +322,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil | |||||
index_id, model_id, tag_id); | index_id, model_id, tag_id); | ||||
rt_ret = rtProfilerTraceEx(index_id, model_id, tag_id, stream); | rt_ret = rtProfilerTraceEx(index_id, model_id, tag_id, stream); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(RT_FAILED, "[Call][rtProfilerTraceEx] failed, ret: 0x%X", rt_ret); | |||||
GELOGE(RT_FAILED, "[Call][rtProfilerTraceEx]Failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Call rtProfilerTraceEx failed, ret 0x%X", rt_ret); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
GELOGD("Profiling Step Info TraceTask execute async success, index_id = %lu, model_id = %lu, tag_id = %u", | GELOGD("Profiling Step Info TraceTask execute async success, index_id = %lu, model_id = %lu, tag_id = %u", | ||||
@@ -314,7 +337,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil | |||||
uint32_t stream_id = 0; | uint32_t stream_id = 0; | ||||
rt_ret = rtGetTaskIdAndStreamID(&task_id, &stream_id); | rt_ret = rtGetTaskIdAndStreamID(&task_id, &stream_id); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(RT_FAILED, "[Get][RtsInfo] task_id and stream_id failed, ret: 0x%X.", rt_ret); | |||||
GELOGE(RT_FAILED, "[Get][RtsInfo]Task_id and stream_id failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Get task_id and stream_id failed, ret 0x%X", rt_ret); | |||||
return RT_ERROR_TO_GE_STATUS(rt_ret); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
GELOGD("Get profiling args, task_id[%u], stream_id[%u]", task_id, stream_id); | GELOGD("Get profiling args, task_id[%u], stream_id[%u]", task_id, stream_id); | ||||
@@ -332,9 +356,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil | |||||
try { | try { | ||||
reported_data = step_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore); | reported_data = step_info.dump(kInteval, ' ', false, Json::error_handler_t::ignore); | ||||
} catch (std::exception &e) { | } catch (std::exception &e) { | ||||
GELOGE(FAILED, "Failed to convert JSON to string, reason: %s.", e.what()); | |||||
GELOGE(FAILED, "[Convert][ReportedData]Failed to convert from json to string, reason: %s", | |||||
e.what()); | |||||
REPORT_CALL_ERROR("E19999", "Failed to convert reported data from json to string, reason: %s", | |||||
e.what()); | |||||
} catch (...) { | } catch (...) { | ||||
GELOGE(FAILED, "Failed to convert JSON to string."); | |||||
GELOGE(FAILED, "[Convert][ReportedData]Failed to convert from json to string"); | |||||
REPORT_CALL_ERROR("E19999", "Failed to convert reported data from json to string"); | |||||
} | } | ||||
reported_data.append(",") | reported_data.append(",") | ||||
.append("\n"); | .append("\n"); | ||||
@@ -390,7 +418,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr | |||||
int32_t logic_device_id = 0; | int32_t logic_device_id = 0; | ||||
rtError_t rt_ret = rtGetDevice(&logic_device_id); | rtError_t rt_ret = rtGetDevice(&logic_device_id); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(rt_ret, "runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id); | |||||
GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); | |||||
return; | return; | ||||
} | } | ||||
GELOGD("current logic_device_id:%d", logic_device_id); | GELOGD("current logic_device_id:%d", logic_device_id); | ||||
@@ -452,7 +481,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo | |||||
// register Framework to profiling | // register Framework to profiling | ||||
int32_t cb_ret = PluginInit(); | int32_t cb_ret = PluginInit(); | ||||
if (cb_ret != 0) { | if (cb_ret != 0) { | ||||
GELOGE(cb_ret, "profiling plugin init failed, ret:%d", cb_ret); | |||||
GELOGE(cb_ret, "[Init][ProfilingPlugin]Failed, ret %d", cb_ret); | |||||
REPORT_CALL_ERROR("E19999", "Init profiling plugin failed, ret %d", cb_ret); | |||||
return cb_ret; | return cb_ret; | ||||
} | } | ||||
GELOGI("Prof subscribe: model load profiling on."); | GELOGI("Prof subscribe: model load profiling on."); | ||||
@@ -465,7 +495,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo | |||||
device[0] = davinci_model->GetDeviceId(); | device[0] = davinci_model->GetDeviceId(); | ||||
rtError_t rt_ret = rtProfilerStart(module, device_num, device); | rtError_t rt_ret = rtProfilerStart(module, device_num, device); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Runtime profiler start failed."); | |||||
GELOGE(FAILED, "[Start][Profiler]Failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Start runtime profiler failed, ret 0x%X", rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
UpdateSubscribeDeviceModuleMap(kProfModelSubscribe, device[0], module); | UpdateSubscribeDeviceModuleMap(kProfModelSubscribe, device[0], module); | ||||
@@ -473,7 +504,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo | |||||
// Report profiling data | // Report profiling data | ||||
Status p_ret = davinci_model->ReportProfilingData(); | Status p_ret = davinci_model->ReportProfilingData(); | ||||
if (p_ret != SUCCESS) { | if (p_ret != SUCCESS) { | ||||
GELOGE(p_ret, "Report profiling data failed."); | |||||
GELOGE(p_ret, "[Report][ProfilingData]Failed, ret %u", p_ret); | |||||
REPORT_CALL_ERROR("E19999", "Report profiling data failed, ret %u", p_ret); | |||||
return p_ret; | return p_ret; | ||||
} | } | ||||
#endif | #endif | ||||
@@ -499,13 +531,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo | |||||
// The same device_id, only stop at last time | // The same device_id, only stop at last time | ||||
rtError_t rt_ret = rtProfilerStop(subs_dev_module_[device[0]].module, dev_num, device); | rtError_t rt_ret = rtProfilerStop(subs_dev_module_[device[0]].module, dev_num, device); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Runtime profiler stop failed."); | |||||
GELOGE(FAILED, "[Stop][Profiler]Failed, ret %d", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Stop profiler failed, ret %d", rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
} | } | ||||
UpdateSubscribeDeviceModuleMap(kProfModelUnsubscribe, device[0], subs_dev_module_[device[0]].module); | UpdateSubscribeDeviceModuleMap(kProfModelUnsubscribe, device[0], subs_dev_module_[device[0]].module); | ||||
} else { | } else { | ||||
GELOGE(FAILED, "The device_id:%u has not been subscribed, do not need to cancel.", device[0]); | |||||
GELOGE(FAILED, "[Cancel][DeviceId]The device_id %u has not been subscribed, " | |||||
"do not need to cancel", device[0]); | |||||
REPORT_CALL_ERROR("E19999", "The device_id %u has not been subscribed, do not need to cancel", | |||||
device[0]); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
@@ -527,14 +563,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfIn | |||||
// register Framework to profiling | // register Framework to profiling | ||||
int32_t cb_ret = PluginInit(); | int32_t cb_ret = PluginInit(); | ||||
if (cb_ret != 0) { | if (cb_ret != 0) { | ||||
GELOGE(cb_ret, "profiling plugin init failed, ret:%d", cb_ret); | |||||
GELOGE(cb_ret, "[Init][ProfilingPlugin]Failed, ret %d", cb_ret); | |||||
REPORT_CALL_ERROR("E19999", "Init profiling plugin failed, ret %d", cb_ret); | |||||
return cb_ret; | return cb_ret; | ||||
} | } | ||||
int32_t device_num = -1; | int32_t device_num = -1; | ||||
rtError_t rt_ret = rtProfilerStart(model_load_mask, device_num, nullptr); | rtError_t rt_ret = rtProfilerStart(model_load_mask, device_num, nullptr); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Runtime profiler start failed."); | |||||
GELOGE(FAILED, "[Start][Profiler]Failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Start rumtime profiler failed, ret 0x%X", rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
is_load_profiling_ = true; | is_load_profiling_ = true; | ||||
@@ -563,7 +601,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfFi | |||||
int32_t dev_num = -1; | int32_t dev_num = -1; | ||||
rtError_t rt_ret = rtProfilerStop(PROF_MODEL_LOAD_MASK, dev_num, nullptr); | rtError_t rt_ret = rtProfilerStop(PROF_MODEL_LOAD_MASK, dev_num, nullptr); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Runtime profiler stop failed."); | |||||
GELOGE(FAILED, "[Stop][Profiler]Failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Stop rumtime profiler faield, ret 0x%X", rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
for (auto device_id_module : device_id_module_map_) { | for (auto device_id_module : device_id_module_map_) { | ||||
@@ -572,7 +611,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfFi | |||||
GELOGI("Prof finalize: device_id: %u, module: 0x%lx.", device_id, device_id_module.second); | GELOGI("Prof finalize: device_id: %u, module: 0x%lx.", device_id, device_id_module.second); | ||||
rt_ret = rtProfilerStop(device_id_module.second, 1, &device_id); | rt_ret = rtProfilerStop(device_id_module.second, 1, &device_id); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Runtime profiler stop failed."); | |||||
GELOGE(FAILED, "[Stop][Profiler]Failed, device_id %d, ret 0x%X", device_id, rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Stop runtime profiler failed, device_id %d, ret 0x%X", | |||||
device_id,rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
} | } | ||||
@@ -611,18 +652,26 @@ Status ProfilingManager::ProfParseDeviceId(const std::map<std::string, std::stri | |||||
int32_t dev_id = std::stoi(decvice_id[i]); | int32_t dev_id = std::stoi(decvice_id[i]); | ||||
device_list.push_back(dev_id); | device_list.push_back(dev_id); | ||||
} catch (std::invalid_argument &) { | } catch (std::invalid_argument &) { | ||||
GELOGE(FAILED, "Device id: %s is invalid.", decvice_id[i].c_str()); | |||||
GELOGE(FAILED, "[Parse][DeviceId]Failed, it is invalid, %s", decvice_id[i].c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse device id %s failed, it is invalid", | |||||
decvice_id[i].c_str()); | |||||
return FAILED; | return FAILED; | ||||
} catch (std::out_of_range &) { | } catch (std::out_of_range &) { | ||||
GELOGE(FAILED, "Device id: %s is out of range.", decvice_id[i].c_str()); | |||||
GELOGE(FAILED, "[Parse][DeviceId]Failed, it is out of range, %s", decvice_id[i].c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse device id %s failed, it is out of range", | |||||
decvice_id[i].c_str()); | |||||
return FAILED; | return FAILED; | ||||
} catch (...) { | } catch (...) { | ||||
GELOGE(FAILED, "Device id: %s cannot change to int.", decvice_id[i].c_str()); | |||||
GELOGE(FAILED, "[Parse][DeviceId]Faield, it cannot change to int, %s", | |||||
decvice_id[i].c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse device id %s failed, it cannot change to int", | |||||
decvice_id[i].c_str()); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
GELOGE(FAILED, "Config para not contain device id list."); | |||||
GELOGE(FAILED, "[Parse][DeviceId]Config para not contain device id list"); | |||||
REPORT_CALL_ERROR("E19999", "Parse device id failed, config para not contain device id list"); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
#endif | #endif | ||||
@@ -638,27 +687,40 @@ Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string> | |||||
try { | try { | ||||
device_num = std::stoi(iter->second); | device_num = std::stoi(iter->second); | ||||
} catch (std::invalid_argument &) { | } catch (std::invalid_argument &) { | ||||
GELOGE(FAILED, "Device nun: %s is invalid.", iter->second.c_str()); | |||||
GELOGE(FAILED, "[Parse][Param]Failed, device num %s is invalid", iter->second.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse param failed, device num %s is invalid", | |||||
iter->second.c_str()); | |||||
return FAILED; | return FAILED; | ||||
} catch (std::out_of_range &) { | } catch (std::out_of_range &) { | ||||
GELOGE(FAILED, "Device num: %s is out of range.", iter->second.c_str()); | |||||
GELOGE(FAILED, "[Parse][Param]Failed, device num %s is out of range", iter->second.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse param failed, device num %s is out of range", | |||||
iter->second.c_str()); | |||||
return FAILED; | return FAILED; | ||||
} catch (...) { | } catch (...) { | ||||
GELOGE(FAILED, "Device num: %s cannot change to int.", iter->second.c_str()); | |||||
GELOGE(FAILED, "[Parse][Param]Failed, device num %s cannot change to int", | |||||
iter->second.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse param failed, device num %s cannot change to int", | |||||
iter->second.c_str()); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
} else { | } else { | ||||
GELOGE(FAILED, "Config para not contain device num."); | |||||
GELOGE(FAILED, "[Parse][Param]Config para not contain device num %s", iter->second.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse param failed, config para not contain device num %s", | |||||
iter->second.c_str()); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
// device id | // device id | ||||
if (ProfParseDeviceId(config_para, device_list) != SUCCESS) { | if (ProfParseDeviceId(config_para, device_list) != SUCCESS) { | ||||
GELOGE(FAILED, "Parse config para device id failed."); | |||||
GELOGE(FAILED, "[Parse][DeviceId]Failed"); | |||||
REPORT_CALL_ERROR("E19999", "Parse device id failed"); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
if (device_num == 0 || device_num > kMaxDeviceNum || device_num != static_cast<int32_t>(device_list.size())) { | if (device_num == 0 || device_num > kMaxDeviceNum || device_num != static_cast<int32_t>(device_list.size())) { | ||||
GELOGE(FAILED, "Config para device num: %d not equal to device list size: %zu.", device_num, device_list.size()); | |||||
GELOGE(FAILED, "[Parse][Param]Failed, config para device num %d not equal to " | |||||
"device list size %zu", device_num, device_list.size()); | |||||
REPORT_INNER_ERROR("E19999", "[Parse][Param]Failed, config para device num %d " | |||||
"not equal to device list size %zu", device_num, device_list.size()); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
#endif | #endif | ||||
@@ -676,13 +738,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
int32_t device_num = 0; | int32_t device_num = 0; | ||||
vector<int32_t> device_list; | vector<int32_t> device_list; | ||||
if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) { | if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) { | ||||
GELOGE(FAILED, "Prof start parse param failed."); | |||||
GELOGE(FAILED, "[Start][Profiling]Prof start parse param failed, device num %d, " | |||||
"device list size %zu", device_num, device_list.size()); | |||||
REPORT_CALL_ERROR("E19999", "Prof start parse param failed, device num %d, " | |||||
"device list size %zu", device_num, device_list.size()); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | ||||
if (device_id_ptr == nullptr) { | if (device_id_ptr == nullptr) { | ||||
GELOGE(FAILED, "Prof start: device id ptr is null."); | |||||
GELOGE(FAILED, "[Start][Profiling]Malloc buffer failed when start profiling, device num %d", device_num); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when start profiling, device num %d", | |||||
device_num); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
@@ -692,7 +759,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get()); | rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get()); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Runtime profiler config proc failed."); | |||||
GELOGE(FAILED, "[Start][Profiler]Runtime profiler config proc failed, config param 0x%lx, " | |||||
"device num %d, ret 0x%X", module, device_num, rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Runtime profiler config proc failed, config param 0x%lx, " | |||||
"device num %d, ret 0x%X", module, device_num, rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) { | if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) { | ||||
@@ -719,12 +789,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
int32_t device_num = 0; | int32_t device_num = 0; | ||||
vector<int32_t> device_list; | vector<int32_t> device_list; | ||||
if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) { | if (ProfParseParam(config_para, device_num, device_list) != SUCCESS) { | ||||
GELOGE(FAILED, "Prof stop parse param failed."); | |||||
GELOGE(FAILED, "[Stop][Profiling]Prof stop parse param failed, device num %d, " | |||||
"device list size %zu", device_num, device_list.size()); | |||||
REPORT_CALL_ERROR("E19999", "Prof stop parse param failed, device num %d, device list size %zu", | |||||
device_num, device_list.size()); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]); | ||||
if (device_id_ptr == nullptr) { | if (device_id_ptr == nullptr) { | ||||
GELOGE(FAILED, "Prof stop: device id ptr is null."); | |||||
GELOGE(FAILED, "[Stop][Profiling]Malloc buffer failed when stop profiling, device num %d", device_num); | |||||
REPORT_CALL_ERROR("E19999", "Malloc buffer failed when stop profiling, device num %d", | |||||
device_num); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
for (int32_t i = 0; i < device_num; i++) { | for (int32_t i = 0; i < device_num; i++) { | ||||
@@ -733,7 +808,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
GELOGI("Prof stop: runtime config param: 0x%lx, device num: %d", module, device_num); | GELOGI("Prof stop: runtime config param: 0x%lx, device num: %d", module, device_num); | ||||
rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); | rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(FAILED, "Prof stop: runtime profiler config proc failed."); | |||||
GELOGE(FAILED, "[Stop][Profiler]Runtime profiler config proc failed, config param 0x%lx, " | |||||
"device num: %d, ret 0x%X", module, device_num, rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Runtime profiler config proc failed, config param 0x%lx, " | |||||
"device num %d, ret 0x%X", module, device_num, rt_ret); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK; | uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK; | ||||
@@ -790,7 +868,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin | |||||
int32_t logic_device_id = 0; | int32_t logic_device_id = 0; | ||||
rtError_t rt_ret = rtGetDevice(&logic_device_id); | rtError_t rt_ret = rtGetDevice(&logic_device_id); | ||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGE(rt_ret, "Runtime get logic_device_id failed, current logic_device_id:%d", logic_device_id); | |||||
GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, ret 0x%X", rt_ret); | |||||
REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); | |||||
} | } | ||||
GELOGI("Current logic_device_id:%d", logic_device_id); | GELOGI("Current logic_device_id:%d", logic_device_id); | ||||
@@ -805,7 +884,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::PluginInit() { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::PluginInit() { | ||||
if (prof_cb_.msprofReporterCallback == nullptr) { | if (prof_cb_.msprofReporterCallback == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
int32_t cb_ret = prof_cb_.msprofReporterCallback( | int32_t cb_ret = prof_cb_.msprofReporterCallback( | ||||
@@ -813,8 +893,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin | |||||
static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_INIT), | static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_INIT), | ||||
nullptr, 0); | nullptr, 0); | ||||
if (cb_ret != MSPROF_ERROR_NONE) { | if (cb_ret != MSPROF_ERROR_NONE) { | ||||
REPORT_CALL_ERROR("E19999", "Profiling reporter init failed, ret = %d.", cb_ret); | |||||
GELOGE(INTERNAL_ERROR, "[Init][ProfilingReporter] profiling init failed, ret = %d.", cb_ret); | |||||
REPORT_CALL_ERROR("E19999", "Profiling reporter init failed, ret 0x%X", cb_ret); | |||||
GELOGE(INTERNAL_ERROR, "[Init][ProfilingReporter]Failed, ret 0x%X", cb_ret); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
@@ -823,8 +903,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin | |||||
static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_DATA_MAX_LEN), | static_cast<uint32_t>(MsprofReporterCallbackType::MSPROF_REPORTER_DATA_MAX_LEN), | ||||
&reporter_max_len_, sizeof(uint32_t)); | &reporter_max_len_, sizeof(uint32_t)); | ||||
if (cb_ret != MSPROF_ERROR_NONE) { | if (cb_ret != MSPROF_ERROR_NONE) { | ||||
REPORT_CALL_ERROR("E19999", "Get profiling reporter data max len failed, ret = %d.", cb_ret); | |||||
GELOGE(INTERNAL_ERROR, "[Init][ProfilingReporter] Get profiling reporter data max len failed, ret = %d.", cb_ret); | |||||
REPORT_CALL_ERROR("E19999", "Get profiling reporter data max len failed, ret 0x%X", cb_ret); | |||||
GELOGE(INTERNAL_ERROR, "[Get][ProfilingDataMaxLen]Failed, ret 0x%X", cb_ret); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
@@ -834,7 +914,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUnInit() const { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUnInit() const { | ||||
#ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
if (prof_cb_.msprofReporterCallback == nullptr) { | if (prof_cb_.msprofReporterCallback == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | |||||
return; | return; | ||||
} | } | ||||
int32_t cb_ret = prof_cb_.msprofReporterCallback( | int32_t cb_ret = prof_cb_.msprofReporterCallback( | ||||
@@ -850,7 +931,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUn | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMsprofReport( | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMsprofReport( | ||||
ReporterData &reporter_data) const { | ReporterData &reporter_data) const { | ||||
if (prof_cb_.msprofReporterCallback == nullptr) { | if (prof_cb_.msprofReporterCallback == nullptr) { | ||||
GELOGE(ge::PARAM_INVALID, "MsprofReporterCallback callback is nullptr."); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | |||||
REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | |||||
return ge::PARAM_INVALID; | return ge::PARAM_INVALID; | ||||
} | } | ||||
return prof_cb_.msprofReporterCallback( | return prof_cb_.msprofReporterCallback( | ||||
@@ -69,7 +69,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) { | |||||
std::ifstream fs(resolved_file_path, std::ifstream::in); | std::ifstream fs(resolved_file_path, std::ifstream::in); | ||||
if (!fs.is_open()) { | if (!fs.is_open()) { | ||||
GELOGE(PARAM_INVALID, "Open %s failed.", file_path.c_str()); | |||||
GELOGE(PARAM_INVALID, "[Open][File]Failed, file path %s invalid", file_path.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Open file failed, path %s invalid", file_path.c_str()); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -77,7 +78,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) { | |||||
while (getline(fs, line)) { // line not with \n | while (getline(fs, line)) { // line not with \n | ||||
if (!ParseLine(line)) { | if (!ParseLine(line)) { | ||||
GELOGE(PARAM_INVALID, "Parse line failed. content is [%s].", line.c_str()); | |||||
GELOGE(PARAM_INVALID, "[Parse][Line]Failed, content is %s", line.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Parse line failed, content is %s", line.c_str()); | |||||
fs.close(); | fs.close(); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -100,15 +102,18 @@ bool PropertiesManager::ParseLine(const std::string &line) { | |||||
if (!temp.empty()) { | if (!temp.empty()) { | ||||
std::string::size_type pos = temp.find_first_of(delimiter); | std::string::size_type pos = temp.find_first_of(delimiter); | ||||
if (pos == std::string::npos) { | if (pos == std::string::npos) { | ||||
GELOGE(PARAM_INVALID, "Incorrect line [%s], it must include [%s].Perhaps you use illegal chinese symbol", | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Incorrect line %s, it must include %s", | |||||
line.c_str(), delimiter.c_str()); | line.c_str(), delimiter.c_str()); | ||||
REPORT_CALL_ERROR("E19999", "Incorrect line %s, it must include %s", | |||||
line.c_str(), delimiter.c_str()); | |||||
return false; | return false; | ||||
} | } | ||||
std::string map_key = Trim(temp.substr(0, pos)); | std::string map_key = Trim(temp.substr(0, pos)); | ||||
std::string value = Trim(temp.substr(pos + 1)); | std::string value = Trim(temp.substr(pos + 1)); | ||||
if (map_key.empty() || value.empty()) { | if (map_key.empty() || value.empty()) { | ||||
GELOGE(PARAM_INVALID, "Map_key or value empty. %s", line.c_str()); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Map_key or value empty, line %s", line.c_str()); | |||||
REPORT_CALL_ERROR("E19999", "Map_key or value empty, line %s", line.c_str()); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -1,75 +0,0 @@ | |||||
syntax = "proto3"; | |||||
package toolkit.aicpu.dump; | |||||
message Shape { | |||||
repeated uint64 dim = 1; | |||||
} | |||||
message Output { | |||||
int32 data_type = 1; | |||||
int32 format = 2; | |||||
Shape shape = 3; | |||||
uint64 address = 4; | |||||
string original_name = 5; | |||||
int32 original_output_index = 6; | |||||
int32 original_output_data_type = 7; | |||||
int32 original_output_format = 8; | |||||
uint64 size = 9; | |||||
Shape origin_shape = 10; | |||||
} | |||||
message Input { | |||||
int32 data_type =1; | |||||
int32 format = 2; | |||||
Shape shape = 3; | |||||
uint64 address = 4; | |||||
uint64 size = 5; | |||||
Shape origin_shape = 6; | |||||
} | |||||
enum BufferType { | |||||
L1 = 0; | |||||
} | |||||
message OpBuffer { | |||||
BufferType buffer_type = 1; | |||||
uint64 address = 2; | |||||
uint64 size = 3; | |||||
} | |||||
message Op { | |||||
string op_name = 1; | |||||
string op_type = 2; | |||||
} | |||||
message Task { | |||||
uint32 task_id = 1; | |||||
uint32 stream_id = 2; | |||||
Op op = 3; | |||||
repeated Output output = 4; | |||||
bool end_graph = 5; | |||||
repeated Input input = 6; | |||||
repeated OpBuffer buffer = 7; | |||||
} | |||||
message OpMappingInfo { | |||||
string dump_path = 1; | |||||
oneof model_name_param { | |||||
string model_name = 2; | |||||
} | |||||
oneof model_id_param { | |||||
uint32 model_id = 3; | |||||
} | |||||
oneof step_id { | |||||
uint64 step_id_addr = 4; | |||||
} | |||||
oneof iterations_per_loop { | |||||
uint64 iterations_per_loop_addr = 5; | |||||
} | |||||
oneof loop_cond { | |||||
uint64 loop_cond_addr = 6; | |||||
} | |||||
uint32 flag = 7; // 0x01 load, 0x00 unload | |||||
repeated Task task = 8; | |||||
string dump_step = 9; | |||||
} |
@@ -83,11 +83,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co | |||||
std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary); | std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary); | ||||
if (!fs.is_open()) { | if (!fs.is_open()) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"}); | ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"}); | ||||
GELOGE(ge::FAILED, "Open real path[%s] failed.", file); | |||||
GELOGE(ge::FAILED, "[Open][File]Failed, file path %s", file); | |||||
return false; | return false; | ||||
} | } | ||||
google::protobuf::io::IstreamInputStream istream(&fs); | |||||
google::protobuf::io::CodedInputStream coded_stream(&istream); | google::protobuf::io::CodedInputStream coded_stream(&istream); | ||||
bool ret = ReadProtoFromCodedInputStream(coded_stream, proto); | bool ret = ReadProtoFromCodedInputStream(coded_stream, proto); | ||||
@@ -96,7 +95,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co | |||||
if (!ret) { | if (!ret) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file}); | ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file}); | ||||
GELOGE(ge::FAILED, "Parse file[%s] failed.", file); | |||||
GELOGE(ge::FAILED, "[Parse][File]Failed, file %s", file); | |||||
return ret; | return ret; | ||||
} | } | ||||
@@ -155,7 +154,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co | |||||
std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | ||||
if (!file.is_open()) { | if (!file.is_open()) { | ||||
GELOGE(ge::FAILED, "Read file %s failed.", file_name); | |||||
GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name); | |||||
REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -182,7 +182,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co | |||||
std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); | ||||
if (!file.is_open()) { | if (!file.is_open()) { | ||||
GELOGE(ge::FAILED, "Read file %s failed.", file_name); | |||||
GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name); | |||||
REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -250,7 +251,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string CurrentTimeInStr() | |||||
std::time_t now = std::time(nullptr); | std::time_t now = std::time(nullptr); | ||||
std::tm *ptm = std::localtime(&now); | std::tm *ptm = std::localtime(&now); | ||||
if (ptm == nullptr) { | if (ptm == nullptr) { | ||||
GELOGE(ge::FAILED, "Localtime failed."); | |||||
GELOGE(ge::FAILED, "[Check][Param]Localtime incorrect"); | |||||
REPORT_CALL_ERROR("E19999", "Localtime incorrect"); | |||||
return ""; | return ""; | ||||
} | } | ||||
@@ -277,17 +279,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch | |||||
if (!fs.is_open()) { | if (!fs.is_open()) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage("E19017", {"realpth", "protofile"}, {real_path, file}); | ErrorManager::GetInstance().ATCReportErrMessage("E19017", {"realpth", "protofile"}, {real_path, file}); | ||||
GELOGE(ge::FAILED, "Fail to open proto file real path is '%s' when orginal file path is '%s'.", real_path.c_str(), | |||||
file); | |||||
GELOGE(ge::FAILED, "[Open][ProtoFile]Failed, real path %s, orginal file path %s", | |||||
real_path.c_str(), file); | |||||
return false; | return false; | ||||
} | } | ||||
google::protobuf::io::IstreamInputStream input(&fs); | google::protobuf::io::IstreamInputStream input(&fs); | ||||
bool ret = google::protobuf::TextFormat::Parse(&input, message); | bool ret = google::protobuf::TextFormat::Parse(&input, message); | ||||
GE_IF_BOOL_EXEC(!ret, ErrorManager::GetInstance().ATCReportErrMessage("E19018", {"protofile"}, {file}); | GE_IF_BOOL_EXEC(!ret, ErrorManager::GetInstance().ATCReportErrMessage("E19018", {"protofile"}, {file}); | ||||
GELOGE(ret, | |||||
"Parse file[%s] through [google::protobuf::TextFormat::Parse] failed, " | |||||
"please check whether the file is a valid protobuf format file.", | |||||
GELOGE(ret, "[Parse][File]Through [google::protobuf::TextFormat::Parse] failed, file %s", | |||||
file)); | file)); | ||||
fs.close(); | fs.close(); | ||||
@@ -490,7 +490,8 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str | |||||
ret = regexec(®, str.c_str(), 0, NULL, 0); | ret = regexec(®, str.c_str(), 0, NULL, 0); | ||||
if (ret) { | if (ret) { | ||||
regerror(ret, ®, ebuff, kMaxBuffSize); | regerror(ret, ®, ebuff, kMaxBuffSize); | ||||
GELOGE(ge::PARAM_INVALID, "regexec failed, reason: %s", ebuff); | |||||
GELOGE(ge::PARAM_INVALID, "[Rgexec][Param]Failed, reason %s", ebuff); | |||||
REPORT_CALL_ERROR("E19999", "Rgexec failed, reason %s", ebuff); | |||||
regfree(®); | regfree(®); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -518,35 +519,44 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str | |||||
FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | ||||
if (file_path == nullptr) { | if (file_path == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Config path is null."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config path is null"); | |||||
REPORT_INNER_ERROR("E19999", "Config path is null"); | |||||
return false; | return false; | ||||
} | } | ||||
if (!CheckInputPathValid(file_path)) { | if (!CheckInputPathValid(file_path)) { | ||||
GELOGE(PARAM_INVALID, "Config path is invalid: %s", file_path); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config path %s is invalid", file_path); | |||||
REPORT_CALL_ERROR("E19999", "Config path %s is invalid", file_path); | |||||
return false; | return false; | ||||
} | } | ||||
// Normalize the path | // Normalize the path | ||||
std::string resolved_file_path = RealPath(file_path); | std::string resolved_file_path = RealPath(file_path); | ||||
if (resolved_file_path.empty()) { | if (resolved_file_path.empty()) { | ||||
GELOGE(PARAM_INVALID, "Invalid input file path [%s], make sure that the file path is correct.", file_path); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Invalid input file path %s", file_path); | |||||
REPORT_CALL_ERROR("E19999", "Invalid input file path %s", file_path); | |||||
return false; | return false; | ||||
} | } | ||||
mmStat_t stat = {0}; | mmStat_t stat = {0}; | ||||
int32_t ret = mmStatGet(resolved_file_path.c_str(), &stat); | int32_t ret = mmStatGet(resolved_file_path.c_str(), &stat); | ||||
if (ret != EN_OK) { | if (ret != EN_OK) { | ||||
GELOGE(PARAM_INVALID, "cannot get config file status, which path is %s, maybe not exist, return %d, errcode %d", | |||||
resolved_file_path.c_str(), ret, mmGetErrorCode()); | |||||
GELOGE(PARAM_INVALID, "[Get][FileStatus]Failed, which path %s maybe not exist, " | |||||
"return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode()); | |||||
REPORT_CALL_ERROR("E19999", "Get config file status failed, which path %s maybe not exist, " | |||||
"return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode()); | |||||
return false; | return false; | ||||
} | } | ||||
if ((stat.st_mode & S_IFMT) != S_IFREG) { | if ((stat.st_mode & S_IFMT) != S_IFREG) { | ||||
GELOGE(PARAM_INVALID, "config file is not a common file, which path is %s, mode is %u", resolved_file_path.c_str(), | |||||
stat.st_mode); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config file is not a common file, which path is %s, " | |||||
"mode is %u", resolved_file_path.c_str(), stat.st_mode); | |||||
REPORT_CALL_ERROR("E19999", "Config file is not a common file, which path is %s, " | |||||
"mode is %u", resolved_file_path.c_str(), stat.st_mode); | |||||
return false; | return false; | ||||
} | } | ||||
if (stat.st_size > kMaxConfigFileByte) { | if (stat.st_size > kMaxConfigFileByte) { | ||||
GELOGE(PARAM_INVALID, "config file %s size[%ld] is larger than max config file Bytes[%u]", | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config file %s size %ld is larger than max config file Bytes %u", | |||||
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); | resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); | ||||
REPORT_CALL_ERROR("E19999", "Config file %s size %ld is larger than max config file Bytes %u", | |||||
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); | |||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
@@ -554,29 +564,35 @@ FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | |||||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) { | ||||
if (path == nullptr) { | if (path == nullptr) { | ||||
GELOGE(PARAM_INVALID, "Config path is invalid."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Config path is invalid"); | |||||
REPORT_CALL_ERROR("E19999", "Config path is invalid"); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
if (strlen(path) != length) { | if (strlen(path) != length) { | ||||
GELOGE(PARAM_INVALID, "Path is invalid or length of config path is not equal to given length."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Path %s is invalid or length %zu " | |||||
"not equal to given length %zu", path, strlen(path), length); | |||||
REPORT_CALL_ERROR("E19999", "Path %s is invalid or length %zu " | |||||
"not equal to given length %zu", path, strlen(path), length); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
if (length == 0 || length > MMPA_MAX_PATH) { | if (length == 0 || length > MMPA_MAX_PATH) { | ||||
GELOGE(PARAM_INVALID, "Length of config path is invalid."); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]Length of config path %zu is invalid", length); | |||||
REPORT_INNER_ERROR("E19999", "Length of config path %zu is invalid", length); | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
INT32 is_dir = mmIsDir(path); | INT32 is_dir = mmIsDir(path); | ||||
if (is_dir != EN_OK) { | if (is_dir != EN_OK) { | ||||
GELOGE(PATH_INVALID, "Open directory %s failed, maybe it is not exit or not a dir. errmsg:%s", | |||||
path, strerror(errno)); | |||||
GELOGE(PATH_INVALID, "[Open][Directory]Failed, directory path %s, errmsg %s", path, strerror(errno)); | |||||
REPORT_CALL_ERROR("E19999", "Open directory %s failed, errmsg %s", path, strerror(errno)); | |||||
return PATH_INVALID; | return PATH_INVALID; | ||||
} | } | ||||
if (mmAccess2(path, M_R_OK) != EN_OK) { | if (mmAccess2(path, M_R_OK) != EN_OK) { | ||||
GELOGE(PATH_INVALID, "Read path[%s] failed, errmsg[%s]", path, strerror(errno)); | |||||
GELOGE(PATH_INVALID, "[Read][Path]Failed, path %s, errmsg %s", path, strerror(errno)); | |||||
REPORT_CALL_ERROR("E19999", "Read path %s failed, errmsg %s", path, strerror(errno)); | |||||
return PATH_INVALID; | return PATH_INVALID; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -1,971 +0,0 @@ | |||||
/** | |||||
* Copyright 2020 Huawei Technologies Co., Ltd | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
*/ | |||||
#include "option_utils.h" | |||||
#include "common/util/error_manager/error_manager.h" | |||||
#include "external/ge/ge_api_types.h" | |||||
#include "framework/common/string_util.h" | |||||
#include "framework/common/types.h" | |||||
#include "framework/common/util.h" | |||||
#include "graph/compute_graph.h" | |||||
#include "graph/utils/type_utils.h" | |||||
#include "graph/utils/tensor_utils.h" | |||||
#include "graph/debug/ge_attr_define.h" | |||||
using std::pair; | |||||
using std::string; | |||||
using std::vector; | |||||
namespace ge { | |||||
namespace { | |||||
const int64_t kDynamicInputDim = -1; | |||||
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}}; | |||||
const char *const kOutputTypeSupport = "only support FP32, FP16, UINT8"; | |||||
const std::set<std::string> kBufferOptimizeSupportOption = {"l1_optimize", "l2_optimize", "off_optimize", | |||||
"l1_and_l2_optimize"}; | |||||
// The function is incomplete. Currently, only l2_optimize, off_optimize is supported. | |||||
const char *const kBufferOptimizeSupport = "only support l2_optimize, off_optimize"; | |||||
const char *const IR_OPTION_OP_SELECT_IMPLMODE_DEFAULT = "high_performance"; | |||||
const char *const IR_OPTION_OP_SELECT_IMPLMODE_PRECISON = "high_precision"; | |||||
const char *const kInputShapeSample1 = "\"input_name1:n1,c1,h1,w1\""; | |||||
const char *const kInputShapeSample2 = "\"input_name1:1,3,224,224\""; | |||||
const char *const kSplitError1 = "size not equal to 2 split by \":\""; | |||||
const char *const kEmptyError = "can not be empty"; | |||||
const char *const kFloatNumError = "exist float number"; | |||||
const char *const kDigitError = "is not digit"; | |||||
const char *const kCompressWeightError = "it must be appointed when appoint parameter[--optypelist_for_implmode]"; | |||||
const char *const kSelectImplmodeError = "only support high_performance, high_precision"; | |||||
const char *const kDynamicBatchSizeError = "It can only contains digit, \",\", \" \""; | |||||
const char *const kDynamicImageSizeError = "It can only contains digit, \",\", \" \" and \";\""; | |||||
const char *const kKeepDtypeError = "file not found"; | |||||
const char *const kInputShapeRangeInvalid = "format of shape range is invalid"; | |||||
const char *const kInputShapeRangeSizeInvalid = " shape range size less than 2 is invalid"; | |||||
const char *const kShapeRangeValueConvertError = "transfer from string to int64 error"; | |||||
const char *const kInputShapeRangeSample1 = "\"input_name1:[n1~n2,c1,h1,w1]\""; | |||||
const char *const kInputShapeRangeSample2 = "\"[1~20]\""; | |||||
const char *const kInputShapeRangeSample3 = "\"[1~20,3,3~6,-1]\""; | |||||
const char *const kInputShapeRangeSample4 = "\"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\""; | |||||
vector<string> SplitInputShape(const std::string &input_shape) { | |||||
vector<string> shape_pair_vec; | |||||
size_t pos = input_shape.rfind(":"); | |||||
if (pos != std::string::npos) { | |||||
shape_pair_vec.emplace_back(input_shape.substr(0, pos)); | |||||
shape_pair_vec.emplace_back(input_shape.substr(pos + 1, input_shape.size() - pos)); | |||||
} | |||||
return shape_pair_vec; | |||||
} | |||||
static bool StringToLongNoThrow(const string &str, long &val) { | |||||
try { | |||||
val = std::stol(str); | |||||
return true; | |||||
} catch (const std::invalid_argument) { | |||||
REPORT_INPUT_ERROR("E10048", std::vector<std::string>({"shape_range", "reason", "sample"}), | |||||
std::vector<string>({str, kShapeRangeValueConvertError, kInputShapeRangeSample3})); | |||||
GELOGE(PARAM_INVALID, "[Parse][Parameter] str:%s to long failed, reason: %s, correct sample is %s.", | |||||
str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); | |||||
} catch (const std::out_of_range) { | |||||
REPORT_INPUT_ERROR("E10048", std::vector<std::string>({"shape_range", "reason", "sample"}), | |||||
std::vector<string>({str, kShapeRangeValueConvertError, kInputShapeRangeSample3})); | |||||
GELOGE(PARAM_INVALID, "[Parse][Parameter] str:%s to long failed, reason: %s, correct sample is %s.", | |||||
str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); | |||||
} | |||||
return false; | |||||
} | |||||
static bool ParseShapeRangePair(const string &shape_range, | |||||
const vector<string> &range_pair_set, | |||||
std::pair<int64_t, int64_t> &range_pair) { | |||||
if (range_pair_set.size() == 1) { | |||||
long range_value = 0; | |||||
if (!StringToLongNoThrow(range_pair_set.at(0), range_value)) { | |||||
return false; | |||||
} | |||||
if (range_value < 0) { | |||||
range_pair = std::make_pair(1, range_value); | |||||
} else { | |||||
range_pair = std::make_pair(range_value, range_value); | |||||
} | |||||
} 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)) { | |||||
return false; | |||||
} | |||||
long range_right = 0; | |||||
if (!StringToLongNoThrow(range_pair_set.at(1), range_right)) { | |||||
return false; | |||||
} | |||||
if ((range_left < 0) || (range_right < 0)) { | |||||
REPORT_INPUT_ERROR("E10048", std::vector<std::string>({"shape_range", "reason", "sample"}), | |||||
std::vector<string>({shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample3})); | |||||
GELOGE(PARAM_INVALID, | |||||
"[Parse][InputParameter] [--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); | |||||
} else { | |||||
REPORT_INPUT_ERROR("E10048", std::vector<std::string>({"shape_range", "reason", "sample"}), | |||||
std::vector<string>({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); | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
} // namespace | |||||
Status CheckInputFormat(const string &input_format) { | |||||
if (input_format.empty()) { | |||||
return ge::SUCCESS; | |||||
} | |||||
if (!ge::TypeUtils::IsFormatValid(input_format.c_str())) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10001", {"parameter", "value", "reason"}, {"--input_format", input_format, "input format is invalid!"}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][InputFormat] --input_format[%s] is invalid!", input_format.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
bool CheckDynamicBatchSizeInputShapeValid(map<string, vector<int64_t>> shape_map, | |||||
std::string &dynamic_batch_size) { | |||||
int32_t size = 0; | |||||
for (auto iter = shape_map.begin(); iter != shape_map.end(); ++iter) { | |||||
vector<int64_t> shape = iter->second; | |||||
if (shape.empty()) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10012"); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][DynamicBatchSizeInputShape] shape size can not be less than 1 when set --dynamic_batch_size."); | |||||
return false; | |||||
} | |||||
if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { | |||||
continue; | |||||
} | |||||
bool ret = multibatch::CheckDynamicBatchShape(shape, iter->first); | |||||
if (ret) { | |||||
size++; | |||||
} | |||||
} | |||||
if (size == 0) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10031"); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][DynamicBatchSizeInputShape]At least one batch n must be equal to -1 when set dynamic_batch_size."); | |||||
return false; | |||||
} | |||||
for (char c : dynamic_batch_size) { | |||||
if (!isdigit(c) && (c != ',') && (c != ' ')) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10033", {"value", "reason"}, {dynamic_batch_size, kDynamicBatchSizeError}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] --dynamic_batch_size:%s is invalid. reason: %s", | |||||
dynamic_batch_size.c_str(), kDynamicBatchSizeError); | |||||
return false; | |||||
} | |||||
} | |||||
if (dynamic_batch_size.back() == ',') { | |||||
dynamic_batch_size.erase(dynamic_batch_size.end() - 1); | |||||
} | |||||
return true; | |||||
} | |||||
bool CheckDynamicImagesizeInputShapeValid(map<string, vector<int64_t>> shape_map, | |||||
const std::string input_format, std::string &dynamic_image_size) { | |||||
if (!input_format.empty() && !ge::TypeUtils::IsFormatValid(input_format.c_str())) { | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][DynamicImagesizeInputShape] input_format [%s] invalid, can not support now.", input_format.c_str()); | |||||
REPORT_INPUT_ERROR("E10414", std::vector<std::string>({"input_format"}), std::vector<std::string>({input_format})); | |||||
return false; | |||||
} | |||||
int32_t size = 0; | |||||
for (auto iter = shape_map.begin(); iter != shape_map.end(); ++iter) { | |||||
vector<int64_t> shape = iter->second; | |||||
// only support four dim | |||||
if (shape.size() != DIM_DEFAULT_SIZE) { | |||||
if (std::count(shape.begin(), shape.end(), kDynamicInputDim) > 0) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10019"); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicImagesizeInputShape] --input_shape invalid," | |||||
" only height and width can be -1 when set --dynamic_image_size."); | |||||
return false; | |||||
} | |||||
continue; | |||||
} | |||||
if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { | |||||
continue; | |||||
} | |||||
auto ret = multibatch::CheckDynamicImageSizeShape(shape, iter->first, input_format); | |||||
if (ret) { | |||||
size++; | |||||
} else { | |||||
return ret; | |||||
} | |||||
} | |||||
if (size == 0) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10019"); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicImagesizeInputShape]--input shape invalid, " | |||||
"only height and width can be -1 when set --dynamic_image_size."); | |||||
return false; | |||||
} | |||||
EraseEndSemicolon(dynamic_image_size); | |||||
for (char c : dynamic_image_size) { | |||||
bool is_char_valid = isdigit(c) || (c == ',') || (c == ' ') || (c == ';'); | |||||
if (!is_char_valid) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10033", {"value", "reason"}, {dynamic_image_size, kDynamicImageSizeError}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicImageSizeInputShape] --dynamic_image_size:%s is invalid. reason: %s", | |||||
dynamic_image_size.c_str(), kDynamicImageSizeError); | |||||
return false; | |||||
} | |||||
} | |||||
// Different parameter sets are split string by ';' | |||||
std::vector<std::string> split_set = StringUtils::Split(dynamic_image_size, ';'); | |||||
// Different dimensions are split by ',' | |||||
std::vector<std::string> split_dim; | |||||
for (auto str : split_set) { | |||||
split_dim = StringUtils::Split(str, ','); | |||||
if (split_dim.size() != static_cast<size_t>(kDynamicImageSizeNum)) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10020", {"DynamicImageSizeNum"}, | |||||
{std::to_string(kDynamicImageSizeNum)}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][DynamicImagesizeInputShape] invalid value:%s number of dimensions of each group must be %ld.", | |||||
dynamic_image_size.c_str(), kDynamicImageSizeNum); | |||||
return false; | |||||
} | |||||
} | |||||
return true; | |||||
} | |||||
bool CheckDynamicDimsInputShapeValid(const map<string, vector<int64_t>> &shape_map, | |||||
string input_format, string &dynamic_dims) { | |||||
if (input_format != "ND") { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10001", {"parameter", "value", "reason"}, | |||||
{"--input_format", input_format.c_str(), "input_format must be ND when set dynamic_dims"}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicDimsInputShape]--input_format must be ND when set dynamic_dims."); | |||||
return false; | |||||
} | |||||
int32_t dynamic_dim = 0; | |||||
for (auto &info_shapes : shape_map) { | |||||
auto &shapes = info_shapes.second; | |||||
if (shapes.size() > kMaxNDDimNum || shapes.size() < kMinNDDimNum) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10001", {"parameter", "value", "reason"}, | |||||
{"--input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicDimsInputShape]Dim num must within [%zu, %zu] when set dynamic_dims.", | |||||
kMinNDDimNum, kMaxNDDimNum); | |||||
return false; | |||||
} | |||||
dynamic_dim += std::count(shapes.begin(), shapes.end(), kDynamicInputDim); | |||||
} | |||||
if (dynamic_dim == 0) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10001", {"parameter", "value", "reason"}, | |||||
{"--input_shape's dynamic dim num", "0", "at least one dim should be -1 when set dynamic_dims"}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][DynamicDimsInputShape]--input_shape invalid," | |||||
"at least one dim should be -1 when set dynamic_dims."); | |||||
return false; | |||||
} | |||||
if (!CheckAndParseDynamicDims(dynamic_dim, dynamic_dims)) { | |||||
GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims]failed, %s invalid.", dynamic_dims.c_str()); | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims) { | |||||
EraseEndSemicolon(dynamic_dims); | |||||
if (dynamic_dims.empty()) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10001", {"parameter", "value", "reason"}, | |||||
{"--dynamic_dims", dynamic_dims.c_str(), "dynamic_dims can not be empty"}); | |||||
GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims]--dynamic_dims can not be empty."); | |||||
return false; | |||||
} | |||||
// Different parameter sets are split by ';' | |||||
vector<string> split_set = StringUtils::Split(dynamic_dims, ';'); | |||||
if (split_set.size() > kMaxDynamicDimNum) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10042", {"parameter", "reason"}, {"dynamic_dims", "dynamic_dims's num of parameter set can not exceed 100"}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[CheckAndParse][DynamicDims]dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); | |||||
return false; | |||||
} | |||||
for (auto split_dim : split_set) { | |||||
vector<string> one_set = StringUtils::Split(split_dim, ','); | |||||
if (one_set.size() != static_cast<size_t>(dynamic_dim_num)) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10042", {"parameter", "reason"}, | |||||
{"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); | |||||
GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims] --dynamic_dims:%s invalid. " | |||||
"reason: Each gear setting needs to be consistent with the number of -1 in the inputshape.", | |||||
dynamic_dims.c_str()); | |||||
return false; | |||||
} | |||||
for (auto dim : one_set) { | |||||
for (auto c : dim) { | |||||
if (!isdigit(c)) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage( | |||||
"E10001", {"parameter", "value", "reason"}, | |||||
{"--dynamic_dims's parameter", dim.c_str(), "must be positive integer"}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[CheckAndParse][DynamicDims]--dynamic_dims:%s parameter must be positive integer.", | |||||
dynamic_dims.c_str()); | |||||
return false; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return true; | |||||
} | |||||
bool ParseSingleShapeRange(std::string &shape_range, vector<pair<int64_t, int64_t>> &shape_range_vec) { | |||||
vector<char> square_brackets; | |||||
for (auto ch : shape_range) { | |||||
if (ch == '[' || ch == ']') { | |||||
square_brackets.push_back(ch); | |||||
} | |||||
} | |||||
bool is_square_brackets = (square_brackets.size() == kSquareBracketsSize) && | |||||
(square_brackets[0] == '[') && (square_brackets[1] == ']'); | |||||
if (!is_square_brackets) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, | |||||
{shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample2}); | |||||
GELOGE(PARAM_INVALID, "[Parse][Parameter] shape_range:%s invalid, reason: %s, correct sample is %s.", | |||||
shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample2); | |||||
return false; | |||||
} | |||||
// trim start bytes, after that, single input should be "1~20,3,3~6,-1" | |||||
if (ge::StringUtils::StartWith(shape_range, "[")) { | |||||
shape_range = shape_range.substr(1, shape_range.size() - 1); | |||||
} | |||||
// parse shape_range of single input. eg. "1~20,3,3~6,-1" | |||||
vector<string> dim_range_set = ge::StringUtils::Split(shape_range, ','); | |||||
for (const auto &range_pair_str : dim_range_set) { | |||||
vector<string> range_pair_set = ge::StringUtils::Split(range_pair_str, '~'); | |||||
pair<int64_t, int64_t> range_pair; | |||||
if (!ParseShapeRangePair(shape_range, range_pair_set, range_pair)) { | |||||
GELOGE(PARAM_INVALID, "[Parse][RangePair] parse range pair failed."); | |||||
return false; | |||||
} | |||||
shape_range_vec.emplace_back(range_pair); | |||||
} | |||||
return true; | |||||
} | |||||
/** | |||||
* Parser shape_range from string to map | |||||
* shape_range from option normally is "input1:[1~20,3,3~6,-1];input2:[1~20,3,3~6,-1]" | |||||
* @param shape_range | |||||
*/ | |||||
Status ParseInputShapeRange(const std::string &shape_range, | |||||
std::map<string, std::vector<std::pair<int64_t, int64_t>>> &shape_range_map) { | |||||
GELOGD("Input shape range %s", shape_range.c_str()); | |||||
vector<string> shape_range_vec = StringUtils::Split(shape_range, ';'); | |||||
const int DEFAULT_SHAPE_RANGE_PAIR_SIZE = 2; | |||||
for (const auto &shape_range_item : shape_range_vec) { | |||||
vector<string> shape_range_pair_vec = SplitInputShape(shape_range_item); | |||||
if (shape_range_pair_vec.size() != DEFAULT_SHAPE_RANGE_PAIR_SIZE) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, | |||||
{shape_range, kSplitError1, kInputShapeRangeSample1}); | |||||
GELOGE(PARAM_INVALID, "[Parse][Parameter]--input shape_range:%s invalid, reason: %s, correct sample is %s.", | |||||
shape_range.c_str(), kSplitError1, kInputShapeRangeSample1); | |||||
return PARAM_INVALID; | |||||
} | |||||
if (shape_range_pair_vec[1].empty()) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape", "reason", "sample"}, | |||||
{shape_range, kEmptyError, kInputShapeRangeSample1}); | |||||
GELOGE(PARAM_INVALID, "[Parse][Parameter]shape_range:%s invalid,reason: %s, correct sample is %s.", | |||||
shape_range.c_str(), kEmptyError, kInputShapeRangeSample1); | |||||
return PARAM_INVALID; | |||||
} | |||||
string shape_range_str = shape_range_pair_vec[1]; | |||||
vector<pair<int64_t, int64_t>> shape_range_val; | |||||
if (!ParseSingleShapeRange(shape_range_str, shape_range_val)) { | |||||
GELOGE(PARAM_INVALID, "[Parse][Parameter] shape_range_str: %s invalid.", shape_range_str.c_str()); | |||||
return PARAM_INVALID; | |||||
} | |||||
shape_range_map.emplace(make_pair(StringUtils::Trim(shape_range_pair_vec[0]), shape_range_val)); | |||||
} | |||||
return SUCCESS; | |||||
} | |||||
/** | |||||
* Parser shape_range from string to vector | |||||
* shape_range from option normally is "[1~20,3,3~6,-1],[1~20,3,3~6,-1]" | |||||
* @param shape_range | |||||
*/ | |||||
Status ParseInputShapeRange(const std::string &shape_range, | |||||
std::vector<std::vector<std::pair<int64_t, int64_t>>> &range) { | |||||
GELOGD("Input shape range %s", shape_range.c_str()); | |||||
if (shape_range.size() < 2) { | |||||
REPORT_INPUT_ERROR("E10048", std::vector<std::string>({"shape_range", "reason", "sample"}), | |||||
std::vector<std::string>({shape_range, kInputShapeRangeSizeInvalid, kInputShapeRangeSample4})); | |||||
GELOGE(PARAM_INVALID, "[Parse][ShapeRange] str:%s invalid, reason: %s, correct sample is %s.", | |||||
shape_range.c_str(), kInputShapeRangeSizeInvalid, kInputShapeRangeSample4); | |||||
return PARAM_INVALID; | |||||
} | |||||
// different shape_range of single input are split by ']' | |||||
vector<string> shape_range_set = ge::StringUtils::Split(shape_range, ']'); | |||||
if (shape_range_set.empty()) { | |||||
REPORT_INPUT_ERROR("E10048", std::vector<std::string>({"shape_range", "reason", "sample"}), | |||||
std::vector<string>({shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample4})); | |||||
GELOGE(PARAM_INVALID, "[Parse][ShapeRange] str:%s invalid, reason: %s, correct sample is %s.", | |||||
shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample4); | |||||
return PARAM_INVALID; | |||||
} | |||||
for (auto &shape_range_str : shape_range_set) { | |||||
if (shape_range_str.size() < 3) { | |||||
// shape_range_str should be "[2~3,1" | |||||
// or ",[2~3,1". because we should trim '[' or ',[' | |||||
// so shape_range_str.size() < 3 is invalid | |||||
continue; | |||||
} | |||||
// trim start bytes, after that, single input should be "1~20,3,3~6,-1" | |||||
if (ge::StringUtils::StartWith(shape_range_str, "[")) { | |||||
shape_range_str = shape_range_str.substr(1, shape_range_str.size()); | |||||
} | |||||
if (ge::StringUtils::StartWith(shape_range_str, ",")) { | |||||
shape_range_str = shape_range_str.substr(2, shape_range_str.size()); | |||||
} | |||||
// parse shape_range of single input. eg. "1~20,3,3~6,-1" | |||||
std::vector<std::pair<int64_t, int64_t>> range_of_single_input; | |||||
vector<string> dim_range_set = ge::StringUtils::Split(shape_range_str, ','); | |||||
for (const auto &range_pair_str : dim_range_set) { | |||||
vector<string> range_pair_set = ge::StringUtils::Split(range_pair_str, '~'); | |||||
pair<int64_t, int64_t> range_pair; | |||||
if (!ParseShapeRangePair(shape_range_str, range_pair_set, range_pair)) { | |||||
GELOGE(PARAM_INVALID, "[Parse][RangePair] Parse range pair failed."); | |||||
return PARAM_INVALID; | |||||
} | |||||
range_of_single_input.emplace_back(range_pair); | |||||
} | |||||
range.emplace_back(range_of_single_input); | |||||
} | |||||
return SUCCESS; | |||||
} | |||||
Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_image_size, string &dynamic_dims, | |||||
const string input_shape, const string input_shape_range, const string input_format, bool &is_dynamic_input) { | |||||
int32_t param_size = static_cast<int32_t>(!dynamic_batch_size.empty()) + | |||||
static_cast<int32_t>(!dynamic_image_size.empty()) + static_cast<int32_t>(!dynamic_dims.empty()); | |||||
if (param_size > 1) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10009", {"parameter0", "parameter1", "parameter2"}, | |||||
{"dynamic_batch_size", "dynamic_image_size", "dynamic_dims"}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Parse][Parameter]dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one"); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
if (param_size == 0) { | |||||
if (input_shape_range.find(":") != string::npos) { | |||||
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) != SUCCESS) { | |||||
GELOGE(ge::PARAM_INVALID, "[Parse][InputShapeRange] failed, range: %s", input_shape_range.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
} | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
map<string, vector<int64_t>> shape_map; | |||||
vector<pair<string, vector<int64_t>>> user_shape_map; | |||||
is_dynamic_input = true; | |||||
if (input_shape.empty()) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {"input_shape"}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][Parameter:input_shape]The input_shape can not be empty in dynamic input size scenario."); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
if (!ParseInputShape(input_shape, shape_map, user_shape_map, is_dynamic_input)) { | |||||
GELOGE(ge::PARAM_INVALID, "[Parse][InputShape]input_shape: %s invalid.", input_shape.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
if (!dynamic_batch_size.empty()) { | |||||
if (!CheckDynamicBatchSizeInputShapeValid(shape_map, dynamic_batch_size)) { | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] input_shape: %s invalid.", input_shape.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
} | |||||
if (!dynamic_image_size.empty()) { | |||||
if (!CheckDynamicImagesizeInputShapeValid(shape_map, input_format, dynamic_image_size)) { | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicImagesizeInputShape] %s invalid. dynamic_image_size:%s ", | |||||
input_shape.c_str(), dynamic_image_size.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
} | |||||
if (!dynamic_dims.empty()) { | |||||
if (!CheckDynamicDimsInputShapeValid(shape_map, input_format, dynamic_dims)) { | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DynamicDimsInputShape]: %s of input shape: %s failed.", dynamic_dims.c_str(), | |||||
input_shape.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
bool ParseInputShape(const string &input_shape, map<string, vector<int64_t>> &shape_map, | |||||
vector<pair<string, vector<int64_t>>> &user_shape_map, bool is_dynamic_input) { | |||||
vector<string> shape_vec = StringUtils::Split(input_shape, ';'); | |||||
const int DEFAULT_SHAPE_PAIR_SIZE = 2; | |||||
for (const auto &shape : shape_vec) { | |||||
vector<string> shape_pair_vec = SplitInputShape(shape); | |||||
if (shape_pair_vec.size() != DEFAULT_SHAPE_PAIR_SIZE) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10002", {"shape", "reason", "sample"}, | |||||
{shape, kSplitError1, kInputShapeSample1}); | |||||
GELOGW("Parse input parameter [--input_shape]'s shape[%s] failed, reason: %s, correct sample is %s.", | |||||
shape.c_str(), kSplitError1, kInputShapeSample1); | |||||
return false; | |||||
} | |||||
if (shape_pair_vec[1].empty()) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10002", {"shape", "reason", "sample"}, | |||||
{shape, kEmptyError, kInputShapeSample1}); | |||||
GELOGW("Parse input parameter [--input_shape]'s shape[%s] failed, reason: %s, correct sample is %s.", | |||||
shape.c_str(), kEmptyError, kInputShapeSample1); | |||||
return false; | |||||
} | |||||
vector<string> shape_value_strs = StringUtils::Split(shape_pair_vec[1], ','); | |||||
vector<int64_t> shape_values; | |||||
for (auto &shape_value_str : shape_value_strs) { | |||||
// stoul: The method may throw an exception: invalid_argument/out_of_range | |||||
if (std::string::npos != shape_value_str.find('.')) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10002", {"shape", "reason", "sample"}, | |||||
{shape, kFloatNumError, kInputShapeSample2}); | |||||
GELOGW("Parse input parameter [--input_shape]'s shape[%s] failed, reason: %s, correct sample is %s.", | |||||
shape.c_str(), kFloatNumError, kInputShapeSample2); | |||||
return false; | |||||
} | |||||
long left_result = 0; | |||||
try { | |||||
left_result = stol(StringUtils::Trim(shape_value_str)); | |||||
if (!shape_value_str.empty() && (shape_value_str.front() == '-')) { | |||||
// The value maybe dynamic shape [-1], need substr it and verify isdigit. | |||||
shape_value_str = shape_value_str.substr(1); | |||||
} | |||||
for (char c : shape_value_str) { | |||||
if (!isdigit(c)) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10002", {"shape", "reason", "sample"}, | |||||
{shape, kDigitError, kInputShapeSample2}); | |||||
GELOGE(PARAM_INVALID, "[Check][Param]--input_shape's shape value[%s] is not digit", | |||||
shape_value_str.c_str()); | |||||
return false; | |||||
} | |||||
} | |||||
} catch (const std::out_of_range &) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10013", {"parameter", "value"}, | |||||
{"--input_shape", shape_value_str}); | |||||
GELOGW("Input parameter[--input_shape]’s value[%s] cause out of range execption!", shape_value_str.c_str()); | |||||
return false; | |||||
} catch (const std::invalid_argument &) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10014", {"parameter", "value"}, | |||||
{"--input_shape", shape_value_str}); | |||||
GELOGW("Input parameter[--input_shape]’s value[%s] cause invalid argument!", shape_value_str.c_str()); | |||||
return false; | |||||
} catch (...) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10015", {"parameter", "value"}, | |||||
{"--input_shape", shape_value_str}); | |||||
GELOGW("Input parameter[--input_shape]’s value[%s] cause unkown execption!", shape_value_str.c_str()); | |||||
return false; | |||||
} | |||||
int64_t result = left_result; | |||||
// - 1 is not currently supported | |||||
if (!is_dynamic_input && result <= 0) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10011", {"shape", "result"}, | |||||
{shape, std::to_string(result)}); | |||||
GELOGW( | |||||
"Input parameter[--input_shape]’s shape value[%s] is invalid, " | |||||
"expect positive integer, but value is %ld.", | |||||
shape.c_str(), result); | |||||
return false; | |||||
} | |||||
shape_values.push_back(result); | |||||
} | |||||
shape_map.emplace(make_pair(StringUtils::Trim(shape_pair_vec[0]), shape_values)); | |||||
user_shape_map.push_back(make_pair(StringUtils::Trim(shape_pair_vec[0]), shape_values)); | |||||
} | |||||
return true; | |||||
} | |||||
Status CheckOutputTypeParamValid(const std::string output_type) { | |||||
if ((!output_type.empty()) && (kOutputTypeSupportDatatype.find(output_type) == kOutputTypeSupportDatatype.end())) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, | |||||
{"--output_type", output_type, kOutputTypeSupport}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][Param]Invalid value for --output_type[%s], %s.", output_type.c_str(), kOutputTypeSupport); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
Status CheckBufferOptimizeParamValid(const std::string buffer_optimize) { | |||||
if ((!buffer_optimize.empty()) && | |||||
(kBufferOptimizeSupportOption.find(buffer_optimize) == kBufferOptimizeSupportOption.end())) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, | |||||
{"--buffer_optimize", buffer_optimize, kBufferOptimizeSupport}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][BufferOptimize]Invalid value for [%s], %s.", buffer_optimize.c_str(), kBufferOptimizeSupport); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
Status CheckCompressWeightParamValid(const std::string enable_compress_weight, | |||||
const std::string compress_weight_conf) { | |||||
if ((!compress_weight_conf.empty()) && | |||||
(!CheckInputPathValid(compress_weight_conf, "--compress_weight_conf"))) { | |||||
GELOGE(ge::PARAM_INVALID, "[Check][InputPath]compress weight config file not found, file_name:%s", | |||||
compress_weight_conf.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
if ((enable_compress_weight != "") && (enable_compress_weight != "true") && (enable_compress_weight != "false")) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10005", {"parameter", "value"}, | |||||
{"enable_compress_weight", enable_compress_weight}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param:enable_compress_weight]" | |||||
"Input parameter[--enable_compress_weight]'s value:%s must be true or false.", | |||||
enable_compress_weight.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
if ((enable_compress_weight == "true") && (!compress_weight_conf.empty())) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10047", {"parameter0", "parameter1"}, | |||||
{"enable_compress_weight", "compress_weight_conf"}); | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][CompressWeight]enable_compress_weight and compress_weight_conf can not both exist!!"); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
Status CheckKeepTypeParamValid(const std::string &keep_dtype) { | |||||
if ((!keep_dtype.empty()) && (!CheckInputPathValid(keep_dtype, "--keep_dtype"))) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, | |||||
{"--keep_dtype", keep_dtype, kKeepDtypeError}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][InputPath::--keep_dtype] file not found, file_name:%s", keep_dtype.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
int CheckLogParamValidAndSetLogLevel(const std::string log) { | |||||
int ret = -1; | |||||
char *npu_collect_path = std::getenv("NPU_COLLECT_PATH"); | |||||
if (npu_collect_path != nullptr && log == "null") { | |||||
return 0; | |||||
} | |||||
if (log == "default") { | |||||
ret = 0; | |||||
} else if (log == "null") { | |||||
ret = dlog_setlevel(-1, DLOG_NULL, 0); | |||||
} else if (log == "debug") { | |||||
ret = dlog_setlevel(-1, DLOG_DEBUG, 1); | |||||
} else if (log == "info") { | |||||
ret = dlog_setlevel(-1, DLOG_INFO, 1); | |||||
} else if (log == "warning") { | |||||
ret = dlog_setlevel(-1, DLOG_WARN, 1); | |||||
} else if (log == "error") { | |||||
ret = dlog_setlevel(-1, DLOG_ERROR, 1); | |||||
} else { | |||||
GELOGE(ge::PARAM_INVALID, | |||||
"[Check][LogParam]log:%s invalid, only support debug, info, warning, error, null", log.c_str()); | |||||
REPORT_INPUT_ERROR("E10417", std::vector<std::string>({"loglevel"}), std::vector<std::string>({log})); | |||||
return ret; | |||||
} | |||||
if (ret != 0) { | |||||
GELOGE(ge::PARAM_INVALID, "[Set][LogLevel] fail, level:%s.", log.c_str()); | |||||
REPORT_INPUT_ERROR("E10417", std::vector<std::string>({"loglevel"}), std::vector<std::string>({log})); | |||||
} | |||||
return ret; | |||||
} | |||||
Status CheckInsertOpConfParamValid(const std::string insert_op_conf) { | |||||
if ((!insert_op_conf.empty()) && | |||||
(!CheckInputPathValid(insert_op_conf, "--insert_op_conf"))) { | |||||
GELOGE(ge::PARAM_INVALID, "[Check][InputPath]file not found: %s", insert_op_conf.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
Status CheckDisableReuseMemoryParamValid(const std::string disable_reuse_memory) { | |||||
if ((disable_reuse_memory != "") && (disable_reuse_memory != "0") && (disable_reuse_memory != "1")) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10006", {"parameter"}, {"disable_reuse_memory"}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][DisableReuseMemory]disable_reuse_memory must be 1 or 0."); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
Status CheckEnableSingleStreamParamValid(const std::string enable_single_stream) { | |||||
if ((enable_single_stream != "") && (enable_single_stream != "true") && (enable_single_stream != "false")) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10005", {"parameter", "value"}, | |||||
{"enable_single_stream", enable_single_stream}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param:--enable_single_stream] value:%s must be true or false.", | |||||
enable_single_stream.c_str()); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std::string &op_select_implmode) { | |||||
// only appointed op_select_implmode, can user appoint optypelist_for_implmode | |||||
if (optypelist_for_implmode != "" && op_select_implmode == "") { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, | |||||
{"--op_select_implmode", op_select_implmode.c_str(), | |||||
kCompressWeightError}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Param:--op_select_implmode]value:%s invalid, %s.", | |||||
op_select_implmode.c_str(), kCompressWeightError); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
// op_select_implmode default value is high_performance | |||||
if (op_select_implmode == "") { | |||||
op_select_implmode = IR_OPTION_OP_SELECT_IMPLMODE_DEFAULT; | |||||
} else { | |||||
if (op_select_implmode != IR_OPTION_OP_SELECT_IMPLMODE_DEFAULT && | |||||
op_select_implmode != IR_OPTION_OP_SELECT_IMPLMODE_PRECISON) { | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, | |||||
{"--op_select_implmode", op_select_implmode.c_str(), | |||||
kSelectImplmodeError}); | |||||
GELOGE(ge::PARAM_INVALID, "[Check][Implmode]Invalid value for --op_select_implmode[%s], %s.", | |||||
op_select_implmode.c_str(), kSelectImplmodeError); | |||||
return ge::PARAM_INVALID; | |||||
} | |||||
} | |||||
return ge::SUCCESS; | |||||
} | |||||
void PrintOptionMap(std::map<std::string, std::string> &options, std::string tips) { | |||||
for (auto iter = options.begin(); iter != options.end(); iter++) { | |||||
std::string key = iter->first; | |||||
std::string option_name = iter->second; | |||||
GELOGD("%s set successfully, option_key=%s, option_value=%s", tips.c_str(), key.c_str(), option_name.c_str()); | |||||
} | |||||
} | |||||
void EraseEndSemicolon(string ¶m) { | |||||
if (param.empty()) { | |||||
return; | |||||
} | |||||
if (param.back() == ';') { | |||||
param.erase(param.end() - 1); | |||||
} | |||||
} | |||||
Status UpdateDataOpShape(const OpDescPtr &op, map<string, vector<int64_t>> &shape_map) { | |||||
GE_CHECK_NOTNULL(op); | |||||
if (shape_map.empty()) { | |||||
GELOGI("Shape map of data op [%s] is empty, no need to update.", op->GetName().c_str()); | |||||
return SUCCESS; | |||||
} | |||||
auto tensor_input = op->MutableInputDesc(0); | |||||
auto tensor_output = op->MutableOutputDesc(0); | |||||
GE_CHECK_NOTNULL(tensor_input); | |||||
GE_CHECK_NOTNULL(tensor_output); | |||||
string data_op_name = op->GetName(); | |||||
auto iter = shape_map.find(data_op_name); | |||||
if (iter != shape_map.end()) { | |||||
tensor_input->SetShape(ge::GeShape(iter->second)); | |||||
tensor_output->SetShape(ge::GeShape(iter->second)); | |||||
GELOGI("Update input [%s] shape info", data_op_name.c_str()); | |||||
} else { | |||||
GELOGI("No need update input [%s] attr because not found from input_shape.", data_op_name.c_str()); | |||||
} | |||||
return SUCCESS; | |||||
} | |||||
Status UpdateDataOpShapeRange(const OpDescPtr &op, | |||||
const map<string, vector<pair<int64_t, int64_t>>> &name_shape_range_map) { | |||||
GE_CHECK_NOTNULL(op); | |||||
if (name_shape_range_map.empty()) { | |||||
GELOGI("Shape range name map of data op [%s] is empty.", op->GetName().c_str()); | |||||
return SUCCESS; | |||||
} | |||||
auto tensor_input = op->MutableInputDesc(0); | |||||
auto tensor_output = op->MutableOutputDesc(0); | |||||
GE_CHECK_NOTNULL(tensor_input); | |||||
GE_CHECK_NOTNULL(tensor_output); | |||||
string data_op_name = op->GetName(); | |||||
auto origin_shape = tensor_input->GetShape(); | |||||
auto iter = name_shape_range_map.find(data_op_name); | |||||
if (iter != name_shape_range_map.end()) { | |||||
auto cur_shape_range = iter->second; | |||||
if (TensorUtils::CheckShapeByShapeRange(origin_shape, cur_shape_range) != SUCCESS) { | |||||
GELOGE(PARAM_INVALID, "[Check][OpDescPtr] Check shape by shape range failed for op:%s.", data_op_name.c_str()); | |||||
return PARAM_INVALID; | |||||
} | |||||
for (size_t idx = 0; idx < cur_shape_range.size(); idx++) { | |||||
auto left_range = cur_shape_range[idx].first; | |||||
auto right_range = cur_shape_range[idx].second; | |||||
if (left_range != right_range) { | |||||
origin_shape.SetDim(idx, UNKNOWN_DIM); | |||||
} | |||||
} | |||||
tensor_input->SetShape(origin_shape); | |||||
tensor_input->SetShapeRange(cur_shape_range); | |||||
tensor_output->SetShape(origin_shape); | |||||
tensor_output->SetShapeRange(cur_shape_range); | |||||
GELOGI("Update input [%s] shape range info", data_op_name.c_str()); | |||||
} else { | |||||
GELOGI("No need to update input [%s] attr because not found from input_shape_range.", data_op_name.c_str()); | |||||
} | |||||
return SUCCESS; | |||||
} | |||||
Status UpdateDataOpShapeRange(const OpDescPtr &op, | |||||
const vector<vector<pair<int64_t, int64_t>>> &index_shape_range_map) { | |||||
GE_CHECK_NOTNULL(op); | |||||
if (index_shape_range_map.empty()) { | |||||
GELOGI("Shape range index map of data op [%s] is empty.", op->GetName().c_str()); | |||||
return SUCCESS; | |||||
} | |||||
GeAttrValue::INT index = 0; | |||||
if (!AttrUtils::GetInt(op, ATTR_NAME_INDEX, index)) { | |||||
GELOGW("[%s] Get index from data attr failed.", op->GetName().c_str()); | |||||
return SUCCESS; | |||||
} | |||||
if ((index < 0) || (static_cast<size_t>(index) >= index_shape_range_map.size())) { | |||||
std::string situation = "data op index[" + std::to_string(index) + "]"; | |||||
std::string reason = "it must less than user_input size[" + std::to_string(index_shape_range_map.size()) + "]"; | |||||
REPORT_INPUT_ERROR("E19025", std::vector<std::string>({"situation", "reason"}), | |||||
std::vector<std::string>({situation, reason})); | |||||
GELOGE(PARAM_INVALID, "user_input size = %zu, graph data op index = %ld.", index_shape_range_map.size(), index); | |||||
return FAILED; | |||||
} | |||||
auto tensor_input = op->MutableInputDesc(0); | |||||
auto tensor_output = op->MutableOutputDesc(0); | |||||
GE_CHECK_NOTNULL(tensor_input); | |||||
GE_CHECK_NOTNULL(tensor_output); | |||||
string data_op_name = op->GetName(); | |||||
auto origin_shape = tensor_input->GetShape(); | |||||
auto cur_shape_range = index_shape_range_map[index]; | |||||
if (TensorUtils::CheckShapeByShapeRange(origin_shape, cur_shape_range) != SUCCESS) { | |||||
GELOGE(PARAM_INVALID, "[Check][OpDescPtr] Check shape by shape range failed for op:%s.", data_op_name.c_str()); | |||||
return PARAM_INVALID; | |||||
} | |||||
for (size_t idx = 0; idx < cur_shape_range.size(); ++idx) { | |||||
auto left_range = cur_shape_range[idx].first; | |||||
auto right_range = cur_shape_range[idx].second; | |||||
if (left_range != right_range) { | |||||
origin_shape.SetDim(idx, UNKNOWN_DIM); | |||||
} | |||||
} | |||||
tensor_input->SetShape(origin_shape); | |||||
tensor_input->SetShapeRange(cur_shape_range); | |||||
tensor_output->SetShape(origin_shape); | |||||
tensor_output->SetShapeRange(cur_shape_range); | |||||
GELOGI("Update input [%s] shape range info success.", data_op_name.c_str()); | |||||
return SUCCESS; | |||||
} | |||||
static Status CheckInputShapeRangeNode(const ComputeGraphPtr &compute_graph, | |||||
const map<string, vector<pair<int64_t, int64_t>>> &shape_range_map) { | |||||
for (const auto &it : shape_range_map) { | |||||
std::string node_name = it.first; | |||||
ge::NodePtr node = compute_graph->FindNode(node_name); | |||||
if (node == nullptr) { | |||||
REPORT_INPUT_ERROR("E10016", std::vector<std::string>({"parameter", "opname"}), | |||||
std::vector<std::string>({"input_shape_range", node_name})); | |||||
GELOGE(PARAM_INVALID, "[Check][InputNode]Input parameter[--input_shape_range]'s opname[%s] is not exist in model", | |||||
node_name.c_str()); | |||||
return PARAM_INVALID; | |||||
} | |||||
if (node->GetType() != DATA) { | |||||
REPORT_INPUT_ERROR("E10017", std::vector<std::string>({"parameter", "opname"}), | |||||
std::vector<std::string>({"input_shape_range", node_name})); | |||||
GELOGE(PARAM_INVALID, "[Check][InputNode]Input parameter[--input_shape_range]'s opname[%s] is not a input opname", | |||||
node_name.c_str()); | |||||
return PARAM_INVALID; | |||||
} | |||||
} | |||||
return SUCCESS; | |||||
} | |||||
Status UpdateDynamicInputShapeRange(const ge::ComputeGraphPtr &compute_graph, const string &input_shape_range) { | |||||
if (input_shape_range.empty()) { | |||||
return SUCCESS; | |||||
} | |||||
GE_CHECK_NOTNULL(compute_graph); | |||||
map<string, vector<pair<int64_t, int64_t>>> shape_range_map; | |||||
if (ParseInputShapeRange(input_shape_range, shape_range_map) != SUCCESS) { | |||||
GELOGE(PARAM_INVALID, "[Parse][InputShapeRange] input_shape_range:%s invalid.", input_shape_range.c_str()); | |||||
return PARAM_INVALID; | |||||
} | |||||
if (CheckInputShapeRangeNode(compute_graph, shape_range_map) != SUCCESS) { | |||||
GELOGE(PARAM_INVALID, "[Check][InputShapeRange]check input shape range:%s failed.", input_shape_range.c_str()); | |||||
return PARAM_INVALID; | |||||
} | |||||
for (NodePtr &input_node : compute_graph->GetDirectNode()) { | |||||
GE_CHECK_NOTNULL(input_node); | |||||
OpDescPtr op = input_node->GetOpDesc(); | |||||
GE_CHECK_NOTNULL(op); | |||||
if (op->GetType() == DATA) { | |||||
if (UpdateDataOpShapeRange(op, shape_range_map) != SUCCESS) { | |||||
GELOGE(FAILED, "[Update][InputShapeRange] fail for op:%s.", op->GetName().c_str()); | |||||
return FAILED; | |||||
} | |||||
} | |||||
} | |||||
return SUCCESS; | |||||
} | |||||
} // namespace ge |
@@ -1,91 +0,0 @@ | |||||
/** | |||||
* Copyright 2020 Huawei Technologies Co., Ltd | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
*/ | |||||
#ifndef FRAMEWORK_DOMI_ATC_IR_COMMON_H_ | |||||
#define FRAMEWORK_DOMI_ATC_IR_COMMON_H_ | |||||
#include <unistd.h> | |||||
#include <string> | |||||
#include <unordered_map> | |||||
#include <utility> | |||||
#include <vector> | |||||
#include <set> | |||||
#include "framework/common/debug/ge_log.h" | |||||
#include "framework/common/ge_inner_error_codes.h" | |||||
#include "framework/omg/omg_inner_types.h" | |||||
#include "graph/preprocess/multi_batch_options.h" | |||||
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", "NCDHW"}; | |||||
static std::map<std::string, domiTensorFormat_t> input_format_str_to_geformat = { | |||||
{"ND", domi::DOMI_TENSOR_ND}, | |||||
{"NCHW", domi::DOMI_TENSOR_NCHW}, | |||||
{"NHWC", domi::DOMI_TENSOR_NHWC}, | |||||
{"CHWN", domi::DOMI_TENSOR_CHWN}, | |||||
{"NC1HWC0", domi::DOMI_TENSOR_NC1HWC0}, | |||||
{"NHWC1C0", domi::DOMI_TENSOR_NHWC1C0}, | |||||
{"NCDHW", domi::DOMI_TENSOR_NCDHW}, | |||||
{"NDHWC", domi::DOMI_TENSOR_NDHWC} | |||||
}; | |||||
static const std::string kEnableCompressWeightTrue = "1"; | |||||
static const std::string kEnableCompressWeightFalse = "0"; | |||||
bool CheckDynamicBatchSizeInputShapeValid(map<string, vector<int64_t>> shape_map, | |||||
std::string &dynamic_batch_size); | |||||
bool CheckDynamicImagesizeInputShapeValid(map<string, vector<int64_t>> shape_map, | |||||
const std::string input_format, std::string &dynamic_image_size); | |||||
bool CheckDynamicDimsInputShapeValid(const std::map<std::string, std::vector<int64_t>> &shape_map, | |||||
std::string input_format, std::string &dynamic_dims); | |||||
bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims); | |||||
Status CheckDynamicInputParamValid(std::string &dynamic_batch_size, std::string &dynamic_image_size, | |||||
std::string &dynamic_dims, const std::string input_shape, | |||||
const std::string input_shape_range, const std::string input_format, | |||||
bool &is_dynamic_input); | |||||
bool ParseInputShape(const std::string &input_shape, std::map<string, std::vector<int64_t>> &shape_map, | |||||
std::vector<std::pair<string, vector<int64_t>>> &user_shape_map, bool is_dynamic_input = false); | |||||
Status ParseInputShapeRange(const std::string &shape_range, | |||||
std::map<string, std::vector<std::pair<int64_t, int64_t>>> &shape_range_map); | |||||
Status ParseInputShapeRange(const std::string &shape_range, | |||||
std::vector<std::vector<std::pair<int64_t, int64_t>>> &range); | |||||
Status CheckOutputTypeParamValid(const std::string output_type); | |||||
Status CheckBufferOptimizeParamValid(const std::string buffer_optimize); | |||||
Status CheckCompressWeightParamValid(const std::string enable_compress_weight, const std::string compress_weight_conf); | |||||
int CheckLogParamValidAndSetLogLevel(const std::string log); | |||||
Status CheckInsertOpConfParamValid(const std::string insert_op_conf); | |||||
Status CheckDisableReuseMemoryParamValid(const std::string disable_reuse_memory); | |||||
Status CheckEnableSingleStreamParamValid(const std::string enable_single_stream); | |||||
Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std::string &op_select_implmode); | |||||
Status CheckInputFormat(const string &input_format); | |||||
Status CheckKeepTypeParamValid(const std::string &keep_dtype); | |||||
void PrintOptionMap(std::map<std::string, std::string> &options, std::string tips); | |||||
void EraseEndSemicolon(std::string ¶m); | |||||
Status UpdateDataOpShape(const OpDescPtr &op, std::map<std::string, std::vector<int64_t>> &shape_map); | |||||
Status UpdateDataOpShapeRange( | |||||
const OpDescPtr &op, const std::map<std::string, std::vector<std::pair<int64_t, int64_t>>> &name_shape_range_map); | |||||
Status UpdateDataOpShapeRange(const OpDescPtr &op, | |||||
const std::vector<std::vector<std::pair<int64_t, int64_t>>> &index_shape_range_map); | |||||
Status UpdateDynamicInputShapeRange(const ge::ComputeGraphPtr &compute_graph, const string &input_shape_range); | |||||
} | |||||
#endif // FRAMEWORK_DOMI_ATC_IR_COMMON_H_ |
@@ -1,75 +0,0 @@ | |||||
syntax = "proto3"; | |||||
package toolkit.aicpu.dump; | |||||
message Shape { | |||||
repeated uint64 dim = 1; | |||||
} | |||||
message Output { | |||||
int32 data_type = 1; | |||||
int32 format = 2; | |||||
Shape shape = 3; | |||||
uint64 address = 4; | |||||
string original_name = 5; | |||||
int32 original_output_index = 6; | |||||
int32 original_output_data_type = 7; | |||||
int32 original_output_format = 8; | |||||
uint64 size = 9; | |||||
Shape origin_shape = 10; | |||||
} | |||||
message Input { | |||||
int32 data_type =1; | |||||
int32 format = 2; | |||||
Shape shape = 3; | |||||
uint64 address = 4; | |||||
uint64 size = 5; | |||||
Shape origin_shape = 6; | |||||
} | |||||
enum BufferType { | |||||
L1 = 0; | |||||
} | |||||
message OpBuffer { | |||||
BufferType buffer_type = 1; | |||||
uint64 address = 2; | |||||
uint64 size = 3; | |||||
} | |||||
message Op { | |||||
string op_name = 1; | |||||
string op_type = 2; | |||||
} | |||||
message Task { | |||||
uint32 task_id = 1; | |||||
uint32 stream_id = 2; | |||||
Op op = 3; | |||||
repeated Output output = 4; | |||||
bool end_graph = 5; | |||||
repeated Input input = 6; | |||||
repeated OpBuffer buffer = 7; | |||||
} | |||||
message OpMappingInfo { | |||||
string dump_path = 1; | |||||
oneof model_name_param { | |||||
string model_name = 2; | |||||
} | |||||
oneof model_id_param { | |||||
uint32 model_id = 3; | |||||
} | |||||
oneof step_id { | |||||
uint64 step_id_addr = 4; | |||||
} | |||||
oneof iterations_per_loop { | |||||
uint64 iterations_per_loop_addr = 5; | |||||
} | |||||
oneof loop_cond { | |||||
uint64 loop_cond_addr = 6; | |||||
} | |||||
uint32 flag = 7; // 0x01 load, 0x00 unload | |||||
repeated Task task = 8; | |||||
string dump_step = 9; | |||||
} |