Browse Source

更新opp算子包中plugin新旧目录的判断标准

pull/740/head
likun104 3 years ago
parent
commit
a22cd10bc6
4 changed files with 33 additions and 20 deletions
  1. +1
    -1
      parser/common/acl_graph_parser_util.cc
  2. +16
    -11
      parser/common/tbe_plugin_loader.cc
  3. +8
    -4
      tests/st/testcase/test_tensorflow_parser.cc
  4. +8
    -4
      tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc

+ 1
- 1
parser/common/acl_graph_parser_util.cc View File

@@ -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/";


+ 16
- 11
parser/common/tbe_plugin_loader.cc View File

@@ -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<std::string> &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<std::string> 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;
}



+ 8
- 4
tests/st/testcase/test_tensorflow_parser.cc View File

@@ -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());



+ 8
- 4
tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc View File

@@ -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());



Loading…
Cancel
Save