Browse Source

fix(dnn/rdnn): add warmup before profile

GitOrigin-RevId: 7962525e90
release-1.10
Megvii Engine Team 3 years ago
parent
commit
ccea0e2386
2 changed files with 18 additions and 3 deletions
  1. +1
    -1
      src/rdnn/impl/algo_chooser.cpp
  2. +17
    -2
      src/rdnn/impl/profiler.cpp

+ 1
- 1
src/rdnn/impl/algo_chooser.cpp View File

@@ -961,7 +961,7 @@ void AlgoChooser<Opr>::AlgoChooserHelper::profile(
continue;
})
if (!cur_rst.valid()) {
mgb_log_warn(
mgb_log_debug(
"timeout when %s; timeout setting: %.3fsec", msg.c_str(),
cur_timeout);
continue;


+ 17
- 2
src/rdnn/impl/profiler.cpp View File

@@ -304,6 +304,21 @@ typename TimedProfiler<Opr>::TResult TimedProfiler<Opr>::prof_impl(
RealTimer timer;
auto ev_start = cn.create_event(CompNode::Event::NEED_TIMER),
ev_end = cn.create_event(CompNode::Event::NEED_TIMER);
for (int i = 0; i < 5; ++i) {
if_constexpr<opr_supports_preprocess<Opr>()>(
[&](auto _) {
auto&& opr = _(megdnn_opr);
PreprocessFilter<Opr>* pf =
preprocessed_layout.empty() ? nullptr : &prep_flt;
APPLY(opr->exec(args.as_megdnn()..., pf, mdn_workspace), inp_val,
out_val);
},
/* else */
[&](auto _) {
APPLY(_(megdnn_opr)->exec(args.as_megdnn()..., mdn_workspace),
inp_val, out_val);
});
}
ev_start->record();
if_constexpr<opr_supports_preprocess<Opr>()>(
[&](auto _) {
@@ -327,12 +342,12 @@ typename TimedProfiler<Opr>::TResult TimedProfiler<Opr>::prof_impl(
while (!ev_end->finished()) {
if (timer.get_secs() >= next_report_time) {
#if MGB_ENABLE_GETENV
mgb_log_warn(
mgb_log_debug(
"profiling conv algo %s already took %.3f/%.3f secs"
" (limit can be set by MGB_CONV_PROFILING_TIMEOUT) ",
algo->name(), timer.get_secs(), param.actual_timeout);
#else
mgb_log_warn(
mgb_log_debug(
"profiling conv algo %s already took %.3f/%.3f secs", algo->name(),
timer.get_secs(), param.actual_timeout);
#endif


Loading…
Cancel
Save