diff --git a/paddle/phi/kernels/autotune/auto_tune_base.h b/paddle/phi/kernels/autotune/auto_tune_base.h index 91685c2ed547c1d1a3268da3e7b24e48fc3fd03d..1f79855107e764593b446a510c6a54efeacc0a32 100644 --- a/paddle/phi/kernels/autotune/auto_tune_base.h +++ b/paddle/phi/kernels/autotune/auto_tune_base.h @@ -120,8 +120,8 @@ class AutoTuneBase { template float RunAndMeasureKernel(const Context& ctx, const int idx, Args&&... args) { - // Regard 1st run as warmup. Judge the result by the time cost of rest run - // cycles. + // Regard 1st run as warmup, judge the compare result by the time cost + // of rest cycles. constexpr int repeats = 3; phi::GpuTimer timer; float time_cost = 0; @@ -153,20 +153,15 @@ template class TransposeAutoTuner : public AutoTuneBase { public: static AutoTuneBase* Instance(KernelType kernel) { + static std::once_flag transpose_init_flag_; static std::unique_ptr> instance_; - std::call_once(init_flag_, [&] { + std::call_once(transpose_init_flag_, [&] { instance_.reset(new AutoTuneBase(kernel)); }); return instance_.get(); } - - private: - static std::once_flag init_flag_; }; -template -std::once_flag TransposeAutoTuner::init_flag_; - template static AutoTuneBase>* MakeTransposeTuner(RetureType (*func)(Args...)) {