diff --git a/ge/graph/build/model_builder.cc b/ge/graph/build/model_builder.cc index a78bbdcc..cf8eb83e 100755 --- a/ge/graph/build/model_builder.cc +++ b/ge/graph/build/model_builder.cc @@ -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); diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index 6d255cd1..03e25b7e 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -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 compute_graph_desc_info; diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 3f07b47e..71584e50 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -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 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 &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."); diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index 85a742b2..8a5cb610 100755 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -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 instancePtr_ = nullptr; @@ -79,6 +80,11 @@ Status GELib::Initialize(const map &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); diff --git a/metadef b/metadef index cc9de48a..63dfb1fd 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit cc9de48a7779cf95cab90a23db608421a691fd12 +Subproject commit 63dfb1fd98c1356c3c738d96cd4d9f760dec1b63 diff --git a/parser b/parser index f86c7513..db4e6070 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit f86c751307835d85329260feb51b559d378b5710 +Subproject commit db4e6070bb2cec01cead264a44ceae07e7f3048e diff --git a/prebuild_env.sh b/prebuild_env.sh new file mode 100644 index 00000000..ff152a6a --- /dev/null +++ b/prebuild_env.sh @@ -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 +