!24250 fix some review issues in profiler

Merge pull request !24250 from yanghaitao/yht_fix_review_issue_0927
This commit is contained in:
i-robot 2021-09-28 01:53:07 +00:00 committed by Gitee
commit 9f92ac51b1
4 changed files with 11 additions and 4 deletions

View File

@ -36,7 +36,14 @@ bool MemoryProfiling::IsMemoryProfilingEnable() const {
}
const std::string prof_options_str = ascend_profiler->GetProfilingOptions();
nlohmann::json options = nlohmann::json::parse(prof_options_str);
nlohmann::json options;
try {
options = nlohmann::json::parse(prof_options_str);
} catch (nlohmann::json::exception &e) {
MS_LOG(ERROR) << "Failed to parse profiling options.";
return false;
}
if (options["profile_memory"] == "off") {
return false;
}

View File

@ -108,7 +108,6 @@ class MemoryProfiling {
}
bool IsMemoryProfilingEnable() const;
MemoryProto &GetMemProto() { return memory_proto_; }
std::shared_ptr<GraphMemory> AddGraphMemoryNode(uint32_t graph_id);
std::shared_ptr<GraphMemory> GetGraphMemoryNode(uint32_t graph_id) const;
void SetDeviceMemSize(uint64_t size) { device_mem_size_ = size; }

View File

@ -281,6 +281,7 @@ void GpuDataSaver::WriteStepTraceAsyncLaunchKernel(const std::string &saver_base
} catch (const std::exception &e) {
MS_LOG(ERROR) << "Write " << file_path << "failed:" << e.what();
ofs.close();
return;
}
step++;
}
@ -326,6 +327,7 @@ void GpuDataSaver::WriteStepTrace(const std::string &saver_base_dir) {
} catch (const std::exception &e) {
MS_LOG(ERROR) << "Write " << file_path << "failed:" << e.what();
ofs.close();
return;
}
}
}
@ -351,6 +353,7 @@ void GpuDataSaver::WriteStartTime(const std::string &saver_base_dir, const BaseT
} catch (const std::exception &e) {
MS_LOG(ERROR) << "Write " << file_path << "failed:" << e.what();
ofs.close();
return;
}
ofs.close();

View File

@ -64,8 +64,6 @@ using AllActivityInfos = std::unordered_map<uint32_t, DeviceActivityInfos>; //
class GpuDataSaver : public DataSaver {
public:
GpuDataSaver() = delete;
GpuDataSaver(ProfilingTraceInfo step_trace_op_name, const std::vector<OneStepStartEndInfo> &all_step_start_end_info)
: step_trace_op_name_(step_trace_op_name), all_step_start_end_info_(all_step_start_end_info) {
step_trace_op_name_from_graph_ = step_trace_op_name;