Browse Source

V200 support NAN INF

pull/185/head
wangzhengjun 5 years ago
parent
commit
d7efa3d302
7 changed files with 65 additions and 2 deletions
  1. +8
    -0
      ge/graph/build/model_builder.cc
  2. +11
    -0
      ge/graph/load/new_model_manager/davinci_model.cc
  3. +22
    -0
      ge/graph/manager/graph_manager.cc
  4. +6
    -0
      ge/init/gelib.cc
  5. +1
    -1
      metadef
  6. +1
    -1
      parser
  7. +16
    -0
      prebuild_env.sh

+ 8
- 0
ge/graph/build/model_builder.cc View File

@@ -418,6 +418,14 @@ Status ModelBuilder::BuildModelDef(ge::Model &model) {
return FAILED);
GELOGI("For model, max_mem_offset_: %zu, p2p_mem_size: %zu, zero_copy_mem_size_: %zu", max_mem_offset_,
p2p_mem_offset_, zero_copy_mem_size_);
string fp_ceiling_mode;
if (ge::GetContext().GetOption("ge.fpCeilingMode", fp_ceiling_mode) == SUCCESS) {
if (!ge::AttrUtils::SetStr(&model, ATTR_FP_CEILING_MODE, fp_ceiling_mode)) {
GELOGE(FAILED, "Failed to set attr ATTR_FP_CEILING_MODE");
return FAILED;
}
GELOGI("Set attr ATTR_FP_CEILING_MODE to model, value is %s.", fp_ceiling_mode.c_str());
}

string ge_core_type;
Status ret = ge::GetContext().GetOption(kCoreType, ge_core_type);


+ 11
- 0
ge/graph/load/new_model_manager/davinci_model.cc View File

@@ -689,6 +689,17 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size
need_destroy_aicpu_kernel_ = IsAicpuKernelConnectSpecifiedLayer();
(void)ge::AttrUtils::GetListStr(ge_model_, ATTR_MODEL_OUT_NODES_NAME, out_node_name_);

string fp_ceiling_mode;
if (ge::AttrUtils::GetStr(ge_model_, ATTR_FP_CEILING_MODE, fp_ceiling_mode)) {
GELOGI("Get attr ATTR_FP_CEILING_MODE from model, value is %s.", fp_ceiling_mode.c_str());
// mode 0: Do not perform saturation processing. By default, IEEE754 is used.
rtError_t ret = rtSetCtxINFMode((fp_ceiling_mode != "0"));
if (ret != RT_ERROR_NONE) {
GELOGE(FAILED, "Failed to set fp_ceiling_mode to runtime.");
return FAILED;
}
}

// collect profiling for ge
if (ProfilingManager::Instance().ProfilingModelLoadOn()) {
std::vector<ComputeGraphDescInfo> compute_graph_desc_info;


+ 22
- 0
ge/graph/manager/graph_manager.cc View File

@@ -130,6 +130,22 @@ bool IsTailingOptimization() {
GELOGW("OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION not set, use BFSTopologicalSorting by default.");
return false;
}

ge::Status CheckFpCeilingMode() {
static const std::unordered_set<std::string> kValidFpCeilingMode = {"0", "1", "2"};
string mode;
auto ret = ge::GetContext().GetOption("ge.fpCeilingMode", mode);
if (ret == ge::GRAPH_SUCCESS) {
if (kValidFpCeilingMode.count(mode) == 0) {
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "The fp_ceiling_mode %s is invalid, options are 0, 1, and 2.", mode.c_str());
return ge::GE_GRAPH_OPTIONS_INVALID;
}
GELOGI("The parameter fp_ceiling_mode is set to %s.", mode.c_str());
return ge::SUCCESS;
}
GELOGW("The parameter fp_ceiling_mode is noe set.");
return ge::SUCCESS;
}
} // namespace

namespace ge {
@@ -165,6 +181,12 @@ Status GraphManager::Initialize(const std::map<string, string> &options) {
return ret;
}

ret = CheckFpCeilingMode();
if (ret != SUCCESS) {
GELOGE(ret, "[Initialize] Check fp-ceiling-mode options failed.");
return ret;
}

ret = graph_context_->Initialize(options);
if (ret != SUCCESS) {
GELOGE(ret, "[Initialize] GraphContext initialize failed.");


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

@@ -56,6 +56,7 @@ const int kDefaultDeviceIdForInfer = -1;
const uint32_t kAicoreOverflow = (0x1 << 0);
const uint32_t kAtomicOverflow = (0x1 << 1);
const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow);
const char *const kGlobalOptionFpCeilingModeDefault = "2";
} // namespace
static std::shared_ptr<GELib> instancePtr_ = nullptr;

@@ -79,6 +80,11 @@ Status GELib::Initialize(const map<string, string> &options) {
return ret;
}
instancePtr_->SetDefaultPrecisionMode(new_options);

if (new_options.find("ge.fpCeilingMode") == new_options.end()) {
new_options["ge.fpCeilingMode"] = kGlobalOptionFpCeilingModeDefault;
}

GetMutableGlobalOptions().insert(new_options.begin(), new_options.end());
GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions());
GE_TIMESTAMP_START(Init);


+ 1
- 1
metadef

@@ -1 +1 @@
Subproject commit cc9de48a7779cf95cab90a23db608421a691fd12
Subproject commit 63dfb1fd98c1356c3c738d96cd4d9f760dec1b63

+ 1
- 1
parser

@@ -1 +1 @@
Subproject commit f86c751307835d85329260feb51b559d378b5710
Subproject commit db4e6070bb2cec01cead264a44ceae07e7f3048e

+ 16
- 0
prebuild_env.sh View File

@@ -0,0 +1,16 @@
#!bin/bash
target_path=$(pwd)
echo "target path: ${target_path}/prebuild"

if [ ! -d "${target_path}/prebuild" ]; then
echo "cloning prebuild repository to ${target_path}"
cd ${target_path}
git clone https://gitee.com/mindspore/prebuild.git
else
echo "found prebuild in ${target_path}, attempting to update ..."
cd ${target_path}/prebuild
git pull
fi
cd -
export D_LINK_PATH=${target_path}/prebuild/lib64


Loading…
Cancel
Save