未验证 提交 e1515e40 编写于 作者: W WangZhen 提交者: GitHub

Fix Function name error when Load program (#44782)

上级 9735d1b8
......@@ -71,30 +71,31 @@ const std::vector<std::pair<std::string, std::string>> PdmodelFilePaths(
ReplaceAll(&format_path, R"(\\)", "/");
ReplaceAll(&format_path, R"(\)", "/");
std::string layer_prefix =
std::string layer_name =
format_path.substr(format_path.find_last_of("/") + 1);
std::string dir_path =
format_path.substr(0, format_path.length() - layer_prefix.length());
format_path.substr(0, format_path.length() - layer_name.length());
DIR* dir = opendir(dir_path.c_str());
struct dirent* ptr;
while ((ptr = readdir(dir)) != nullptr) {
std::string file_name = ptr->d_name;
if (StartsWith(file_name, layer_prefix) &&
if (StartsWith(file_name, layer_name) &&
EndsWith(file_name, PDMODEL_SUFFIX)) {
std::string prefix = file_name.substr(
0, file_name.length() - std::string(PDMODEL_SUFFIX).length());
std::string func_name = prefix.substr(prefix.find_first_of(".") + 1);
VLOG(3) << "func_name:" << func_name << "path:" << dir_path + file_name;
if (func_name == layer_prefix) {
if (prefix == layer_name) {
pdmodel_paths.emplace_back(
std::make_pair("forward", dir_path + file_name));
} else {
std::string func_name = prefix.substr(layer_name.size() + 1);
pdmodel_paths.emplace_back(
std::make_pair(func_name, dir_path + file_name));
}
VLOG(3) << "func_name: " << pdmodel_paths.back().first
<< ", path:" << dir_path + file_name;
}
}
closedir(dir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册