@@ -418,6 +418,14 @@ Status ModelBuilder::BuildModelDef(ge::Model &model) { | |||||
return FAILED); | return FAILED); | ||||
GELOGI("For model, max_mem_offset_: %zu, p2p_mem_size: %zu, zero_copy_mem_size_: %zu", max_mem_offset_, | 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_); | 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; | string ge_core_type; | ||||
Status ret = ge::GetContext().GetOption(kCoreType, ge_core_type); | Status ret = ge::GetContext().GetOption(kCoreType, ge_core_type); | ||||
@@ -676,7 +676,9 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size | |||||
auto all_dump_model = GetDumpProperties().GetAllDumpModel(); | auto all_dump_model = GetDumpProperties().GetAllDumpModel(); | ||||
bool findByOmName = all_dump_model.find(om_name_) != all_dump_model.end(); | bool findByOmName = all_dump_model.find(om_name_) != all_dump_model.end(); | ||||
bool findByModelName = all_dump_model.find(name_) != all_dump_model.end(); | bool findByModelName = all_dump_model.find(name_) != all_dump_model.end(); | ||||
if (all_dump_model.find(ge::DUMP_ALL_MODEL) != all_dump_model.end() || findByOmName || findByModelName) { | |||||
bool dump_l1fusion_op = (all_dump_model.find(ge::DUMP_ALL_MODEL) != all_dump_model.end()) || | |||||
findByOmName || findByModelName; | |||||
if (dump_l1fusion_op) { | |||||
// malloc 2M for dump l1fusion op | // malloc 2M for dump l1fusion op | ||||
GE_CHK_RT_RET(rtMalloc(&l1_fusion_addr_, kDumpL1FusionOpMByteSize, RT_MEMORY_DDR)); | GE_CHK_RT_RET(rtMalloc(&l1_fusion_addr_, kDumpL1FusionOpMByteSize, RT_MEMORY_DDR)); | ||||
@@ -690,6 +692,13 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size | |||||
need_destroy_aicpu_kernel_ = IsAicpuKernelConnectSpecifiedLayer(); | need_destroy_aicpu_kernel_ = IsAicpuKernelConnectSpecifiedLayer(); | ||||
(void)ge::AttrUtils::GetListStr(ge_model_, ATTR_MODEL_OUT_NODES_NAME, out_node_name_); | (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. | |||||
GE_CHK_RT_RET(rtSetCtxINFMode((fp_ceiling_mode != "0"))); | |||||
} | |||||
// collect profiling for ge | // collect profiling for ge | ||||
if (ProfilingManager::Instance().ProfilingModelLoadOn()) { | if (ProfilingManager::Instance().ProfilingModelLoadOn()) { | ||||
std::vector<ComputeGraphDescInfo> compute_graph_desc_info; | std::vector<ComputeGraphDescInfo> compute_graph_desc_info; | ||||
@@ -131,6 +131,22 @@ bool IsTailingOptimization() { | |||||
GELOGW("OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION not set, use BFSTopologicalSorting by default."); | GELOGW("OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION not set, use BFSTopologicalSorting by default."); | ||||
return false; | 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 not set."); | |||||
return ge::SUCCESS; | |||||
} | |||||
} // namespace | } // namespace | ||||
namespace ge { | namespace ge { | ||||
@@ -166,6 +182,12 @@ Status GraphManager::Initialize(const std::map<string, string> &options) { | |||||
return ret; | return ret; | ||||
} | } | ||||
ret = CheckFpCeilingMode(); | |||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "[Initialize] Check fp-ceiling-mode options failed."); | |||||
return ret; | |||||
} | |||||
ret = graph_context_->Initialize(options); | ret = graph_context_->Initialize(options); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "[Initialize] GraphContext initialize failed."); | GELOGE(ret, "[Initialize] GraphContext initialize failed."); | ||||
@@ -56,6 +56,7 @@ const int kDefaultDeviceIdForInfer = -1; | |||||
const uint32_t kAicoreOverflow = (0x1 << 0); | const uint32_t kAicoreOverflow = (0x1 << 0); | ||||
const uint32_t kAtomicOverflow = (0x1 << 1); | const uint32_t kAtomicOverflow = (0x1 << 1); | ||||
const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | ||||
const char *const kGlobalOptionFpCeilingModeDefault = "2"; | |||||
} // namespace | } // namespace | ||||
static std::shared_ptr<GELib> instancePtr_ = nullptr; | static std::shared_ptr<GELib> instancePtr_ = nullptr; | ||||
@@ -79,6 +80,11 @@ Status GELib::Initialize(const map<string, string> &options) { | |||||
return ret; | return ret; | ||||
} | } | ||||
instancePtr_->SetDefaultPrecisionMode(new_options); | 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()); | GetMutableGlobalOptions().insert(new_options.begin(), new_options.end()); | ||||
GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); | GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); | ||||
GE_TIMESTAMP_START(Init); | GE_TIMESTAMP_START(Init); | ||||