forked from mindspore-Ecosystem/mindspore
!21963 fix a profiling bug to improve performance
Merge pull request !21963 from lvchangquan/master
This commit is contained in:
commit
d2a42f131f
|
@ -22,10 +22,20 @@
|
|||
#include <string>
|
||||
#include "utils/profile.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/ms_context.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace device {
|
||||
PynativeProfiler::PynativeProfiler() {
|
||||
auto ms_context = MsContext::GetInstance();
|
||||
MS_EXCEPTION_IF_NULL(ms_context);
|
||||
enable_profiler_flag = ms_context->get_param<bool>(MS_CTX_ENABLE_PROFILING);
|
||||
}
|
||||
|
||||
void PynativeProfiler::SingleOpProfilingData() {
|
||||
if (!enable_profiler_flag) {
|
||||
return;
|
||||
}
|
||||
static std::ofstream of("pynative_forward_profiling_data.csv");
|
||||
of.setf(std::ios::fixed, std::ios::floatfield);
|
||||
if (real_run_op_index_ == 1) {
|
||||
|
|
|
@ -41,10 +41,11 @@ class PynativeProfiler {
|
|||
void SingleOpProfilingData();
|
||||
|
||||
private:
|
||||
PynativeProfiler() = default;
|
||||
PynativeProfiler();
|
||||
~PynativeProfiler() = default;
|
||||
PynativeProfiler(const PynativeProfiler &) = delete;
|
||||
PynativeProfiler &operator=(const PynativeProfiler &) = delete;
|
||||
bool enable_profiler_flag = false;
|
||||
int real_run_op_index_ = 0;
|
||||
std::string real_run_op_name_;
|
||||
std::pair<double, double> real_run_op_start_time_end_time_;
|
||||
|
|
Loading…
Reference in New Issue