Browse Source

!936 set AiCoreNum in options

From: @HW_KK
Reviewed-by: 
Signed-off-by:
tags/v1.2.0
mindspore-ci-bot Gitee 3 years ago
parent
commit
c88506106e
3 changed files with 32 additions and 0 deletions
  1. +26
    -0
      ge/init/gelib.cc
  2. +1
    -0
      ge/init/gelib.h
  3. +5
    -0
      tests/depends/runtime/src/runtime_stub.cc

+ 26
- 0
ge/init/gelib.cc View File

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


+ 1
- 0
ge/init/gelib.h View File

@@ -81,6 +81,7 @@ class GE_FUNC_VISIBILITY GELib {
Status InnerInitialize(const map<string, string> &options);
Status SystemInitialize(const map<string, string> &options);
Status SetRTSocVersion(const map<string, string> &options, map<string, string> &new_options);
Status SetAiCoreNum(map<string, string> &options);
void SetDefaultPrecisionMode(map<string, string> &new_options);
void RollbackInit();
void InitOptions(const map<string, string> &options);


+ 5
- 0
tests/depends/runtime/src/runtime_stub.cc View File

@@ -354,6 +354,11 @@ rtError_t rtGetSocVersion(char *version, const uint32_t maxLen)
return RT_ERROR_NONE;
}

rtError_t rtGetAiCoreCount(uint32_t *aiCoreCnt)
{
return RT_ERROR_NONE;
}

rtError_t rtSetTaskFailCallback(rtTaskFailCallback callback)
{
return RT_ERROR_NONE;


Loading…
Cancel
Save