Browse Source

!24250 fix some review issues in profiler

Merge pull request !24250 from yanghaitao/yht_fix_review_issue_0927
tags/v1.6.0
i-robot Gitee 4 years ago
parent
commit
9f92ac51b1
4 changed files with 11 additions and 4 deletions
  1. +8
    -1
      mindspore/ccsrc/profiler/device/ascend/memory_profiling.cc
  2. +0
    -1
      mindspore/ccsrc/profiler/device/ascend/memory_profiling.h
  3. +3
    -0
      mindspore/ccsrc/profiler/device/gpu/gpu_data_saver.cc
  4. +0
    -2
      mindspore/ccsrc/profiler/device/gpu/gpu_data_saver.h

+ 8
- 1
mindspore/ccsrc/profiler/device/ascend/memory_profiling.cc 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;
}


+ 0
- 1
mindspore/ccsrc/profiler/device/ascend/memory_profiling.h 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; }


+ 3
- 0
mindspore/ccsrc/profiler/device/gpu/gpu_data_saver.cc 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();


+ 0
- 2
mindspore/ccsrc/profiler/device/gpu/gpu_data_saver.h 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;


Loading…
Cancel
Save