diff --git a/parser/common/acl_graph_parser_util.cc b/parser/common/acl_graph_parser_util.cc index 7f1261c..0e1dc4b 100644 --- a/parser/common/acl_graph_parser_util.cc +++ b/parser/common/acl_graph_parser_util.cc @@ -183,7 +183,7 @@ void AclGraphParserUtil::SaveCustomCaffeProtoPath() { path = path_env; GELOGI("Get custom proto path from env : %s", path_env); } - if (mmIsDir((path + "/vendors").c_str()) != EN_OK) { + if (mmIsDir((path + "/built-in").c_str()) != EN_OK) { ge::GetParserContext().custom_proto_path = path + "framework/custom/caffe/"; } else { ge::GetParserContext().custom_proto_path = path + "vendors/customize/framework/caffe/"; diff --git a/parser/common/tbe_plugin_loader.cc b/parser/common/tbe_plugin_loader.cc index 906b7ce..73f0a09 100644 --- a/parser/common/tbe_plugin_loader.cc +++ b/parser/common/tbe_plugin_loader.cc @@ -45,6 +45,7 @@ namespace ge { namespace { const char_t *const kOppEnvName = "ASCEND_OPP_PATH"; +const char_t *const kBuiltIn = "built-in"; // opp built-in directory name const char_t *const kVendors = "vendors"; // opp vendors directory name const char_t *const kConfig = "config.ini"; // opp vendors config file name const size_t kVendorConfigPartsCount = 2U; @@ -137,14 +138,17 @@ Status TBEPluginLoader::GetOppPath(std::string &opp_path) { } bool TBEPluginLoader::IsNewOppPathStruct(const std::string &opp_path) { - return mmIsDir((opp_path + kVendors).c_str()) == EN_OK; + return mmIsDir((opp_path + kBuiltIn).c_str()) == EN_OK; } Status TBEPluginLoader::GetOppPluginVendors(const std::string &vendors_config, std::vector &vendors) { GELOGI("Enter get opp plugin config file schedule"); - GE_ASSERT_TRUE(!vendors_config.empty(), "[Check]Value of vendors_config should not be empty!"); + GELOGI("Config file is '%s'", vendors_config.c_str()); std::ifstream config(vendors_config); - GE_ASSERT_TRUE(config.good(), "File '%s' open failed!", vendors_config.c_str()); + if (!config.good()) { + GELOGI("Can not open file '%s'!", vendors_config.c_str()); + return FAILED; + } std::string content; std::getline(config, content); config.close(); @@ -161,10 +165,9 @@ Status TBEPluginLoader::GetOppPluginPathOld(const std::string &opp_path, std::string &plugin_path, const std::string &path_fmt_custom) { GELOGI("Enter get opp plugin path old schedule"); - const std::string &fmt_builtin = path_fmt; const std::string &fmt_custom = path_fmt_custom.empty() ? path_fmt : path_fmt_custom; plugin_path = (opp_path + std::regex_replace(fmt_custom, std::regex("%s"), "custom") + ":") - + (opp_path + std::regex_replace(fmt_builtin, std::regex("%s"), "built-in")); + + (opp_path + std::regex_replace(path_fmt, std::regex("%s"), "built-in")); return SUCCESS; } @@ -175,13 +178,15 @@ Status TBEPluginLoader::GetOppPluginPathNew(const std::string &opp_path, GELOGI("Enter get opp plugin path new schedule"); const std::string vendors_config = opp_path + kVendors + "/" + kConfig; std::vector vendors; - GE_ASSERT_TRUE(GetOppPluginVendors(vendors_config, vendors) == SUCCESS, "Failed to get opp plugin vendors!"); - const std::string &fmt_builtin = path_fmt; - const std::string &fmt_custom = path_fmt_custom.empty() ? path_fmt : path_fmt_custom; - for (const auto &vendor : vendors) { - plugin_path += opp_path + kVendors + "/" + std::regex_replace(fmt_custom, std::regex("%s"), vendor) + ":"; + if (GetOppPluginVendors(vendors_config, vendors) != SUCCESS) { + GELOGI("Can not get opp plugin vendors!"); + } else { + const std::string &fmt_custom = path_fmt_custom.empty() ? path_fmt : path_fmt_custom; + for (const auto &vendor : vendors) { + plugin_path += opp_path + kVendors + "/" + std::regex_replace(fmt_custom, std::regex("%s"), vendor) + ":"; + } } - plugin_path += opp_path + std::regex_replace(fmt_builtin, std::regex("%s"), "built-in"); + plugin_path += opp_path + std::regex_replace(path_fmt, std::regex("%s"), "built-in"); return SUCCESS; } diff --git a/tests/st/testcase/test_tensorflow_parser.cc b/tests/st/testcase/test_tensorflow_parser.cc index 07eccd9..6e09fc9 100644 --- a/tests/st/testcase/test_tensorflow_parser.cc +++ b/tests/st/testcase/test_tensorflow_parser.cc @@ -4379,8 +4379,8 @@ TEST_F(STestTensorflowParser, test_plugin_manager_GetOpsProtoPath_01) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); - std::string path_vendors = opp_path + "vendors"; - system(("rm -rf " + path_vendors).c_str()); + std::string path_builtin = opp_path + "built-in"; + system(("rm -rf " + path_builtin).c_str()); std::string opsproto_path; Status ret = TBEPluginLoader::GetOpsProtoPath(opsproto_path); @@ -4395,8 +4395,10 @@ TEST_F(STestTensorflowParser, test_plugin_manager_GetOpsProtoPath_02) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); + std::string path_builtin = opp_path + "built-in"; std::string path_vendors = opp_path + "vendors"; std::string path_config = path_vendors + "/config.ini"; + system(("mkdir -p " + path_builtin).c_str()); system(("mkdir -p " + path_vendors).c_str()); system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); @@ -4416,8 +4418,8 @@ TEST_F(STestTensorflowParser, test_plugin_manager_GetCustomOpPath_01) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); - std::string path_vendors = opp_path + "vendors"; - system(("rm -rf " + path_vendors).c_str()); + std::string path_builtin = opp_path + "built-in"; + system(("rm -rf " + path_builtin).c_str()); std::string customop_path; TBEPluginLoader::GetCustomOpPath(customop_path); @@ -4429,8 +4431,10 @@ TEST_F(STestTensorflowParser, test_plugin_manager_GetCustomOpPath_02) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); + std::string path_builtin = opp_path + "built-in"; std::string path_vendors = opp_path + "vendors"; std::string path_config = path_vendors + "/config.ini"; + system(("mkdir -p " + path_builtin).c_str()); system(("mkdir -p " + path_vendors).c_str()); system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index ab86e2e..8f66aed 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -4866,8 +4866,8 @@ TEST_F(UtestTensorflowParser, test_plugin_manager_GetOpsProtoPath_01) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); - std::string path_vendors = opp_path + "vendors"; - system(("rm -rf " + path_vendors).c_str()); + std::string path_builtin = opp_path + "built-in"; + system(("rm -rf " + path_builtin).c_str()); std::string opsproto_path; Status ret = TBEPluginLoader::GetOpsProtoPath(opsproto_path); @@ -4882,8 +4882,10 @@ TEST_F(UtestTensorflowParser, test_plugin_manager_GetOpsProtoPath_02) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); + std::string path_builtin = opp_path + "built-in"; std::string path_vendors = opp_path + "vendors"; std::string path_config = path_vendors + "/config.ini"; + system(("mkdir -p " + path_builtin).c_str()); system(("mkdir -p " + path_vendors).c_str()); system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); @@ -4903,8 +4905,8 @@ TEST_F(UtestTensorflowParser, test_plugin_manager_GetCustomOpPath_01) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); - std::string path_vendors = opp_path + "vendors"; - system(("rm -rf " + path_vendors).c_str()); + std::string path_builtin = opp_path + "built-in"; + system(("rm -rf " + path_builtin).c_str()); std::string customop_path; TBEPluginLoader::GetCustomOpPath(customop_path); @@ -4916,8 +4918,10 @@ TEST_F(UtestTensorflowParser, test_plugin_manager_GetCustomOpPath_02) { opp_path = opp_path.substr(0, opp_path.rfind("/") + 1); setenv("ASCEND_OPP_PATH", opp_path.c_str(), 1); + std::string path_builtin = opp_path + "built-in"; std::string path_vendors = opp_path + "vendors"; std::string path_config = path_vendors + "/config.ini"; + system(("mkdir -p " + path_builtin).c_str()); system(("mkdir -p " + path_vendors).c_str()); system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str());