Merge pull request !663 from zhangfan/ge_devpull/665/MERGE
@@ -87,28 +87,6 @@ static string GetSoPath() { | |||
} | |||
} | |||
static void GetOpsProtoPath(string &opsproto_path) { | |||
GELOGD("Start to get ops proto path schedule."); | |||
const char *path_env = std::getenv("ASCEND_OPP_PATH"); | |||
if (path_env != nullptr) { | |||
string path = path_env; | |||
string file_path = ge::parser::RealPath(path.c_str()); | |||
if (file_path.empty()) { | |||
REPORT_INNER_ERROR("E19999", "File path %s is invalid.", path.c_str()); | |||
GELOGE(ge::FAILED, "[Get][Path] File path %s is invalid.", path.c_str()); | |||
return; | |||
} | |||
opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); | |||
GELOGI("Get opsproto so path from env : %s", path.c_str()); | |||
return; | |||
} | |||
string path_base = GetSoPath(); | |||
GELOGI("path_base is %s", path_base.c_str()); | |||
path_base = path_base.substr(0, path_base.rfind('/')); | |||
path_base = path_base.substr(0, path_base.rfind('/') + 1); | |||
opsproto_path = (path_base + "ops/op_proto/custom/" + ":") + (path_base + "ops/op_proto/built-in/"); | |||
} | |||
static void GetAclParams(const std::map<ge::AscendString, ge::AscendString> &parser_params, const string &key, | |||
string &value) { | |||
for (auto &ele : parser_params) { | |||
@@ -173,7 +151,10 @@ static Status CheckOutNode(ge::OpDescPtr op_desc, int32_t index) { | |||
domi::Status AclGrphParseUtil::LoadOpsProtoLib() { | |||
string opsproto_path; | |||
GetOpsProtoPath(opsproto_path); | |||
ge::Status ret = ge::TBEPluginLoader::GetOpsProtoPath(opsproto_path); | |||
if (ret != ge::SUCCESS) { | |||
GELOGW("Failed to get ops proto path!"); | |||
} | |||
GELOGI("Get opsproto path is %s", opsproto_path.c_str()); | |||
OpsProtoManager *manager = OpsProtoManager::Instance(); | |||
map<string, string> option_tmp; | |||
@@ -196,18 +177,17 @@ void AclGrphParseUtil::SaveCustomCaffeProtoPath() { | |||
path_base = path_base.substr(0, path_base.rfind('/') + 1); | |||
ge::GetParserContext().caffe_proto_path = path_base + "include/proto/"; | |||
string custom_op_path; | |||
std::string path = path_base + "ops"; | |||
const char *path_env = std::getenv("ASCEND_OPP_PATH"); | |||
if (path_env != nullptr) { | |||
std::string path = path_env; | |||
custom_op_path = path + "/framework/custom/caffe/"; | |||
path = path_env; | |||
GELOGI("Get custom proto path from env : %s", path_env); | |||
GetParserContext().custom_proto_path = custom_op_path; | |||
return; | |||
} | |||
custom_op_path = path_base + "ops/framework/custom/caffe/"; | |||
ge::GetParserContext().custom_proto_path = custom_op_path; | |||
return; | |||
if (mmIsDir((path + "/vendors").c_str()) != EN_OK) { | |||
ge::GetParserContext().custom_proto_path = path + "framework/custom/caffe/"; | |||
} else { | |||
ge::GetParserContext().custom_proto_path = path + "vendors/customize/framework/caffe/"; | |||
} | |||
} | |||
// Initialize PARSER, load custom op plugin | |||
@@ -29,16 +29,26 @@ | |||
#include <map> | |||
#include <memory> | |||
#include <string> | |||
#include <regex> | |||
#include "external/ge/ge_api_types.h" | |||
#include "common/util/error_manager/error_manager.h" | |||
#include "framework/common/debug/ge_log.h" | |||
#include "framework/common/string_util.h" | |||
#include "framework/common/util.h" | |||
#include "framework/omg/parser/parser_inner_ctx.h" | |||
#include "graph/utils/type_utils.h" | |||
#include "parser/common/acl_graph_parser_util.h" | |||
#include "mmpa/mmpa_api.h" | |||
#include "common/checker.h" | |||
namespace ge { | |||
namespace { | |||
const char_t *const kOppEnvName = "ASCEND_OPP_PATH"; | |||
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; | |||
} // namespace | |||
std::map<string, string> TBEPluginLoader::options_ = {}; | |||
// Get Singleton Instance | |||
@@ -101,6 +111,93 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginLoader::LoadPlugi | |||
} | |||
} | |||
Status TBEPluginLoader::GetOppPath(std::string &opp_path) { | |||
GELOGI("Enter get opp path schedule"); | |||
const char *path_env = std::getenv(kOppEnvName); | |||
if (path_env != nullptr) { | |||
opp_path = path_env; | |||
std::string file_path = parser::RealPath(opp_path.c_str()); | |||
if (file_path.empty()) { | |||
GELOGW("[Call][RealPath] File path %s is invalid.", opp_path.c_str()); | |||
} else { | |||
GELOGI("Get opp path from env: %s", opp_path.c_str()); | |||
} | |||
if (opp_path.back() != '/') { | |||
opp_path += '/'; | |||
} | |||
} | |||
if (opp_path.empty()) { | |||
opp_path = GetPath(); | |||
GELOGI("Get opp path from so path, value is %s", opp_path.c_str()); | |||
opp_path = opp_path.substr(0, opp_path.rfind('/')); | |||
opp_path = opp_path.substr(0, opp_path.rfind('/') + 1); | |||
opp_path += "ops/"; | |||
} | |||
return SUCCESS; | |||
} | |||
bool TBEPluginLoader::IsNewOppPathStruct(const std::string &opp_path) { | |||
return mmIsDir((opp_path + kVendors).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!"); | |||
std::ifstream config(vendors_config); | |||
GE_ASSERT_TRUE(config.good(), "File '%s' open failed!", vendors_config.c_str()); | |||
std::string content; | |||
std::getline(config, content); | |||
config.close(); | |||
GE_ASSERT_TRUE(!content.empty(), "Content of file '%s' is empty!", vendors_config.c_str()); | |||
std::vector<std::string> v_parts = StringUtils::Split(content, '='); | |||
GE_ASSERT_TRUE(v_parts.size() == kVendorConfigPartsCount, "Format of file content is invalid!"); | |||
vendors = StringUtils::Split(v_parts[1], ','); | |||
GE_ASSERT_TRUE(!vendors.empty(), "Format of file content is invalid!"); | |||
return SUCCESS; | |||
} | |||
Status TBEPluginLoader::GetOppPluginPathOld(const std::string &opp_path, | |||
const std::string &path_fmt, | |||
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")); | |||
return SUCCESS; | |||
} | |||
Status TBEPluginLoader::GetOppPluginPathNew(const std::string &opp_path, | |||
const std::string &path_fmt, | |||
std::string &plugin_path, | |||
const std::string &path_fmt_custom) { | |||
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) + ":"; | |||
} | |||
plugin_path += opp_path + std::regex_replace(fmt_builtin, std::regex("%s"), "built-in"); | |||
return SUCCESS; | |||
} | |||
Status TBEPluginLoader::GetOpsProtoPath(std::string &opsproto_path) { | |||
GELOGI("Enter GetOpsProtoPath schedule"); | |||
std::string opp_path; | |||
GE_ASSERT_TRUE(GetOppPath(opp_path) == SUCCESS, "Failed to get opp path!"); | |||
if (!IsNewOppPathStruct(opp_path)) { | |||
GELOGI("Opp plugin path structure is old version!"); | |||
return GetOppPluginPathOld(opp_path, "op_proto/%s/", opsproto_path); | |||
} else { | |||
GELOGI("Opp plugin path structure is new version!"); | |||
return GetOppPluginPathNew(opp_path, "%s/op_proto/", opsproto_path); | |||
} | |||
} | |||
void TBEPluginLoader::GetCustomOpPath(std::string &customop_path) { | |||
GELOGI("Enter get custom op path schedule"); | |||
std::string fmk_type; | |||
@@ -112,18 +209,22 @@ void TBEPluginLoader::GetCustomOpPath(std::string &customop_path) { | |||
fmk_type = ge::TypeUtils::FmkTypeToSerialString(type); | |||
GELOGI("Framework type is %s.", fmk_type.c_str()); | |||
const char *path_env = std::getenv("ASCEND_OPP_PATH"); | |||
if (path_env != nullptr) { | |||
std::string path = path_env; | |||
customop_path = (path + "/framework/custom" + "/:") + (path + "/framework/built-in/" + fmk_type); | |||
GELOGI("Get custom so path from env : %s", path_env); | |||
std::string opp_path; | |||
Status ret = GetOppPath(opp_path); | |||
if (ret != SUCCESS) { | |||
GELOGW("Failed to get opp path."); | |||
return; | |||
} | |||
std::string path_base = GetPath(); | |||
GELOGI("path_base is %s", path_base.c_str()); | |||
path_base = path_base.substr(0, path_base.rfind('/')); | |||
path_base = path_base.substr(0, path_base.rfind('/') + 1); | |||
customop_path = (path_base + "ops/framework/custom" + "/:") + (path_base + "ops/framework/built-in/" + fmk_type); | |||
if (!IsNewOppPathStruct(opp_path)) { | |||
GELOGI("Opp plugin path structure is old version!"); | |||
ret = GetOppPluginPathOld(opp_path, "framework/%s/" + fmk_type + "/", customop_path, "framework/%s/"); | |||
} else { | |||
GELOGI("Opp plugin path structure is new version!"); | |||
ret = GetOppPluginPathNew(opp_path, "%s/framework/" + fmk_type + "/", customop_path, "%s/framework/"); | |||
} | |||
if (ret != SUCCESS) { | |||
GELOGW("Failed to get custom op path!"); | |||
} | |||
} | |||
string TBEPluginLoader::GetPath() { | |||
@@ -40,12 +40,25 @@ public: | |||
static string GetPath(); | |||
static Status GetOpsProtoPath(std::string &opsproto_path); | |||
private: | |||
TBEPluginLoader() = default; | |||
~TBEPluginLoader() = default; | |||
Status ClearHandles_(); | |||
static void ProcessSoFullName(vector<string> &file_list, string &caffe_parser_path, string &full_name, | |||
const string &caffe_parser_so_suff); | |||
static Status GetOppPath(std::string &opp_path); | |||
static bool IsNewOppPathStruct(const std::string &opp_path); | |||
static Status GetOppPluginVendors(const std::string &vendors_config, std::vector<std::string> &vendors); | |||
static Status GetOppPluginPathOld(const std::string &opp_path, | |||
const std::string &path_fmt, | |||
std::string &plugin_path, | |||
const std::string &path_fmt_custom = ""); | |||
static Status GetOppPluginPathNew(const std::string &opp_path, | |||
const std::string &path_fmt, | |||
std::string &plugin_path, | |||
const std::string &path_fmt_custom = ""); | |||
static void GetCustomOpPath(std::string &customop_path); | |||
static void GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path); | |||
static void FindParserSo(const string &path, vector<string> &file_list, string &caffe_parser_path); | |||
@@ -249,6 +249,15 @@ INT32 mmGetErrorCode() | |||
INT32 mmIsDir(const CHAR *fileName) | |||
{ | |||
struct stat fileStat; | |||
memset(&fileStat, sizeof(fileStat), 0); | |||
int32_t ret = lstat(fileName, &fileStat); | |||
if (ret < 0) { | |||
return -1; | |||
} | |||
if (S_ISDIR(fileStat.st_mode) == 0) { | |||
return -1; | |||
} | |||
return 0; | |||
} | |||
@@ -320,4 +329,4 @@ CHAR *mmDirName(CHAR *path) { | |||
path[last_sep_pos] = '\0'; | |||
return path; | |||
} | |||
} |
@@ -1144,18 +1144,16 @@ TEST_F(STestTensorflowParser, tensorflow_parserfrommemory_failed) | |||
std::size_t idx = caseDir.find_last_of("/"); | |||
caseDir = caseDir.substr(0, idx); | |||
std::string modelFile = caseDir + "/origin_models/tf_add.pb"; | |||
const char *data = modelFile.c_str(); | |||
uint32_t size = 1; | |||
ge::Graph graph; | |||
std::map<ge::AscendString, ge::AscendString> parser_params; | |||
Status ret = ge::aclgrphParseTensorFlow(modelFile.c_str(), parser_params, graph); | |||
ASSERT_EQ(ret, SUCCESS); | |||
modelFile = caseDir + "/origin_models/tf_add.pb"; | |||
parser_params = {{AscendString(ge::ir_option::OUT_NODES), AscendString("Placeholder:0;Placeholder_1:0")}}; | |||
ret = ge::aclgrphParseTensorFlow(modelFile.c_str(), parser_params, graph); | |||
ge::ComputeGraphPtr compute_graph = ge::GraphUtils::GetComputeGraph(graph); | |||
ret = modelParser.ParseFromMemory(data, size, compute_graph); | |||
ret = modelParser.ParseFromMemory(modelFile.c_str(), size, compute_graph); | |||
EXPECT_NE(ret, SUCCESS); | |||
} | |||
@@ -3709,7 +3707,7 @@ TEST_F(STestTensorflowParser, tensorflow_tbe_tfplugin_loader_test) | |||
setenv("ASCEND_OPP_PATH", "aaa", 1); | |||
std::string customop_path = ""; | |||
pluginLoad.GetCustomOpPath(customop_path); | |||
ASSERT_EQ(customop_path, "aaa/framework/custom/:aaa/framework/built-in/tensorflow"); | |||
ASSERT_EQ(customop_path, "aaa/framework/custom/:aaa/framework/built-in/tensorflow/"); | |||
Status ret = pluginLoad.Finalize(); | |||
EXPECT_EQ(ret, SUCCESS); | |||
@@ -4348,4 +4346,120 @@ TEST_F(STestTensorflowParser, AddDumpOriginName_test) | |||
EXPECT_EQ(original_names[1], "abc"); | |||
} | |||
TEST_F(STestTensorflowParser, test_plugin_manager_getopp_plugin_vendors_01) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); | |||
std::vector<std::string> vendors; | |||
Status ret = TBEPluginLoader::GetOppPluginVendors(path_config, vendors); | |||
EXPECT_EQ(ret, SUCCESS); | |||
EXPECT_EQ(vendors[0], "customize"); | |||
EXPECT_EQ(vendors[1], "mdc"); | |||
EXPECT_EQ(vendors[2], "lhisi"); | |||
} | |||
TEST_F(STestTensorflowParser, test_plugin_manager_getopp_plugin_vendors_02) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo '' > " + path_config).c_str()); | |||
std::vector<std::string> vendors; | |||
Status ret = TBEPluginLoader::GetOppPluginVendors(path_config, vendors); | |||
EXPECT_NE(ret, SUCCESS); | |||
} | |||
TEST_F(STestTensorflowParser, test_plugin_manager_getopp_plugin_vendors_03) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority' > " + path_config).c_str()); | |||
std::vector<std::string> vendors; | |||
Status ret = TBEPluginLoader::GetOppPluginVendors(path_config, vendors); | |||
EXPECT_NE(ret, SUCCESS); | |||
} | |||
TEST_F(STestTensorflowParser, test_plugin_manager_GetOpsProtoPath_01) { | |||
std::string opp_path = __FILE__; | |||
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 opsproto_path; | |||
Status ret = TBEPluginLoader::GetOpsProtoPath(opsproto_path); | |||
EXPECT_EQ(ret, SUCCESS); | |||
EXPECT_EQ(opsproto_path, | |||
opp_path + "op_proto/custom/:" + opp_path + "op_proto/built-in/" | |||
); | |||
} | |||
TEST_F(STestTensorflowParser, test_plugin_manager_GetOpsProtoPath_02) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); | |||
std::string opsproto_path; | |||
Status ret = TBEPluginLoader::GetOpsProtoPath(opsproto_path); | |||
EXPECT_EQ(ret, SUCCESS); | |||
EXPECT_EQ(opsproto_path, | |||
path_vendors + "/customize/op_proto/:" + | |||
path_vendors + "/mdc/op_proto/:" + | |||
path_vendors + "/lhisi/op_proto/:" + | |||
opp_path + "built-in/op_proto/" | |||
); | |||
} | |||
TEST_F(STestTensorflowParser, test_plugin_manager_GetCustomOpPath_01) { | |||
std::string opp_path = __FILE__; | |||
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 customop_path; | |||
TBEPluginLoader::GetCustomOpPath(customop_path); | |||
EXPECT_EQ(customop_path.find(opp_path + "framework/custom/:" + opp_path + "framework/built-in/"), 0); | |||
} | |||
TEST_F(STestTensorflowParser, test_plugin_manager_GetCustomOpPath_02) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); | |||
std::string customop_path; | |||
TBEPluginLoader::GetCustomOpPath(customop_path); | |||
EXPECT_EQ(customop_path.find( | |||
path_vendors + "/customize/framework/:" + | |||
path_vendors + "/mdc/framework/:" + | |||
path_vendors + "/lhisi/framework/:" + | |||
opp_path + "built-in/framework/"), 0); | |||
} | |||
} // namespace ge |
@@ -1295,18 +1295,16 @@ TEST_F(UtestTensorflowParser, tensorflow_parserfrommemory_failed) | |||
std::size_t idx = caseDir.find_last_of("/"); | |||
caseDir = caseDir.substr(0, idx); | |||
std::string modelFile = caseDir + "/tensorflow_model/tf_add.pb"; | |||
const char *data = modelFile.c_str(); | |||
uint32_t size = 1; | |||
ge::Graph graph; | |||
std::map<ge::AscendString, ge::AscendString> parser_params; | |||
Status ret = ge::aclgrphParseTensorFlow(modelFile.c_str(), parser_params, graph); | |||
ASSERT_EQ(ret, SUCCESS); | |||
modelFile = caseDir + "/tensorflow_model/tf_add.pb"; | |||
parser_params = {{AscendString(ge::ir_option::OUT_NODES), AscendString("Placeholder:0;Placeholder_1:0")}}; | |||
ret = ge::aclgrphParseTensorFlow(modelFile.c_str(), parser_params, graph); | |||
ge::ComputeGraphPtr compute_graph = ge::GraphUtils::GetComputeGraph(graph); | |||
ret = modelParser.ParseFromMemory(data, size, compute_graph); | |||
ret = modelParser.ParseFromMemory(modelFile.c_str(), size, compute_graph); | |||
EXPECT_NE(ret, SUCCESS); | |||
} | |||
@@ -3813,7 +3811,7 @@ TEST_F(UtestTensorflowParser, tensorflow_tbe_tfplugin_loader_test) | |||
setenv("ASCEND_OPP_PATH", "aaa", 1); | |||
std::string customop_path = ""; | |||
pluginLoad.GetCustomOpPath(customop_path); | |||
ASSERT_EQ(customop_path, "aaa/framework/custom/:aaa/framework/built-in/tensorflow"); | |||
ASSERT_EQ(customop_path, "aaa/framework/custom/:aaa/framework/built-in/tensorflow/"); | |||
Status ret = pluginLoad.Finalize(); | |||
EXPECT_EQ(ret, SUCCESS); | |||
@@ -4835,4 +4833,120 @@ TEST_F(UtestTensorflowParser, AddDumpOriginName_test) | |||
EXPECT_EQ(original_names[1], "abc"); | |||
} | |||
TEST_F(UtestTensorflowParser, test_plugin_manager_getopp_plugin_vendors_01) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); | |||
std::vector<std::string> vendors; | |||
Status ret = TBEPluginLoader::GetOppPluginVendors(path_config, vendors); | |||
EXPECT_EQ(ret, SUCCESS); | |||
EXPECT_EQ(vendors[0], "customize"); | |||
EXPECT_EQ(vendors[1], "mdc"); | |||
EXPECT_EQ(vendors[2], "lhisi"); | |||
} | |||
TEST_F(UtestTensorflowParser, test_plugin_manager_getopp_plugin_vendors_02) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo '' > " + path_config).c_str()); | |||
std::vector<std::string> vendors; | |||
Status ret = TBEPluginLoader::GetOppPluginVendors(path_config, vendors); | |||
EXPECT_NE(ret, SUCCESS); | |||
} | |||
TEST_F(UtestTensorflowParser, test_plugin_manager_getopp_plugin_vendors_03) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority' > " + path_config).c_str()); | |||
std::vector<std::string> vendors; | |||
Status ret = TBEPluginLoader::GetOppPluginVendors(path_config, vendors); | |||
EXPECT_NE(ret, SUCCESS); | |||
} | |||
TEST_F(UtestTensorflowParser, test_plugin_manager_GetOpsProtoPath_01) { | |||
std::string opp_path = __FILE__; | |||
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 opsproto_path; | |||
Status ret = TBEPluginLoader::GetOpsProtoPath(opsproto_path); | |||
EXPECT_EQ(ret, SUCCESS); | |||
EXPECT_EQ(opsproto_path, | |||
opp_path + "op_proto/custom/:" + opp_path + "op_proto/built-in/" | |||
); | |||
} | |||
TEST_F(UtestTensorflowParser, test_plugin_manager_GetOpsProtoPath_02) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); | |||
std::string opsproto_path; | |||
Status ret = TBEPluginLoader::GetOpsProtoPath(opsproto_path); | |||
EXPECT_EQ(ret, SUCCESS); | |||
EXPECT_EQ(opsproto_path, | |||
path_vendors + "/customize/op_proto/:" + | |||
path_vendors + "/mdc/op_proto/:" + | |||
path_vendors + "/lhisi/op_proto/:" + | |||
opp_path + "built-in/op_proto/" | |||
); | |||
} | |||
TEST_F(UtestTensorflowParser, test_plugin_manager_GetCustomOpPath_01) { | |||
std::string opp_path = __FILE__; | |||
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 customop_path; | |||
TBEPluginLoader::GetCustomOpPath(customop_path); | |||
EXPECT_EQ(customop_path.find(opp_path + "framework/custom/:" + opp_path + "framework/built-in/"), 0); | |||
} | |||
TEST_F(UtestTensorflowParser, test_plugin_manager_GetCustomOpPath_02) { | |||
std::string opp_path = __FILE__; | |||
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"; | |||
std::string path_config = path_vendors + "/config.ini"; | |||
system(("mkdir -p " + path_vendors).c_str()); | |||
system(("echo 'load_priority=customize,mdc,lhisi' > " + path_config).c_str()); | |||
std::string customop_path; | |||
TBEPluginLoader::GetCustomOpPath(customop_path); | |||
EXPECT_EQ(customop_path.find( | |||
path_vendors + "/customize/framework/:" + | |||
path_vendors + "/mdc/framework/:" + | |||
path_vendors + "/lhisi/framework/:" + | |||
opp_path + "built-in/framework/"), 0); | |||
} | |||
} // namespace ge |