|
|
|
@ -54,6 +54,7 @@ const int kSocVersionLen = 50;
|
|
|
|
|
const int kDefaultDeviceIdForTrain = 0;
|
|
|
|
|
const int kDefaultDeviceIdForInfer = -1;
|
|
|
|
|
const char *const kGlobalOptionFpCeilingModeDefault = "2";
|
|
|
|
|
const int32_t ACL_ERROR_RT_FEATURE_NOT_SUPPORT = 207000;
|
|
|
|
|
} // namespace
|
|
|
|
|
static std::shared_ptr<GELib> instancePtr_ = nullptr;
|
|
|
|
|
|
|
|
|
@ -76,6 +77,13 @@ Status GELib::Initialize(const map<string, string> &options) {
|
|
|
|
|
GELOGE(ret, "GeLib initial failed.");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = instancePtr_->SetAiCoreNum(new_options);
|
|
|
|
|
if (ret != SUCCESS) {
|
|
|
|
|
GELOGE(ret, "GeLib initial: SetAiCoreNum failed.");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
instancePtr_->SetDefaultPrecisionMode(new_options);
|
|
|
|
|
|
|
|
|
|
if (new_options.find("ge.fpCeilingMode") == new_options.end()) {
|
|
|
|
@ -251,6 +259,24 @@ Status GELib::SetRTSocVersion(const map<string, string> &options, map<string, st
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Status GELib::SetAiCoreNum(map<string, string> &options) {
|
|
|
|
|
// Already set or get AICORE_NUM from options in offline mode
|
|
|
|
|
if (options.find(AICORE_NUM) != options.end()) {
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t aicore_num = 0;
|
|
|
|
|
rtError_t ret = rtGetAiCoreCount(&aicore_num);
|
|
|
|
|
if (ret == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) { // offline without ATC Input of AiCoreNum
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
} else if (ret == RT_ERROR_NONE) { // online-mode
|
|
|
|
|
options.emplace(std::make_pair(AICORE_NUM, std::to_string(aicore_num)));
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
GELOGE(FAILED, "rtGetAiCoreCount failed.");
|
|
|
|
|
return FAILED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GELib::InitOptions(const map<string, string> &options) {
|
|
|
|
|
this->options_.session_id = 0;
|
|
|
|
|
auto iter = options.find(OPTION_EXEC_SESSION_ID);
|
|
|
|
|