提交 1886ebc3 编写于 作者: M Megvii Engine Team

fix(lite/load_and_run): fix fast-run invalid in fitting mode

GitOrigin-RevId: a6761c1a35030dc1896c4957988fef357385f201
上级 20719502
#include "strategy_options.h"
#include "megbrain/utils/persistent_cache.h"
#include "megdnn/algorithm_cache.h"
#include "models/model_mdl.h"
using namespace lar;
DECLARE_bool(c_opr_lib_with_param);
......@@ -47,6 +48,15 @@ void StrategyOption::config_model(
//! make output specification
model_ptr->make_output_spec();
}
} else if (runtime_param.stage == RunStage::AFTER_MODEL_RUNNING) {
mgb_log_debug("clear cache");
#if LITE_WITH_OPENCL
megcoreOpenCLClearGlobalData();
#else
megdnn::AlgorithmCache::instance().clear();
//! WARNING:this is used to clean the profile result cache
//! auto profile_cache = mgb::PersistentCache::inst().get_cache();
#endif
}
}
......
#include <gtest/gtest.h>
#include <string.h>
#include <memory>
#include "./test_common.h"
#include "test_options.h"
using namespace lar;
DECLARE_bool(lite);
DECLARE_int32(iter);
DECLARE_bool(fast_run);
namespace {
BOOL_OPTION_WRAP(fast_run);
BOOL_OPTION_WRAP(lite);
INT32_OPTION_WRAP(iter, 10);
} // anonymous namespace
TEST(TestLarFastRun, FAST_RUN) {
double heristic_time = 0, fast_run_time = 0;
lite::Timer timer("profile");
{
std::string model_path = "./shufflenet.mge";
timer.reset_start();
TEST_INT32_OPTION(iter, 1);
heristic_time = timer.get_used_time();
}
{
std::string model_path = "./shufflenet.mge";
timer.reset_start();
DEFINE_INT32_WRAP(iter, 1);
TEST_BOOL_OPTION(fast_run);
fast_run_time = timer.get_used_time();
}
//! profile time is longer than excute time
ASSERT_LT(heristic_time, fast_run_time);
}
TEST(TestLarFastRun, FAST_RUN_LITE) {
double heristic_time = 0, fast_run_time = 0;
lite::Timer timer("profile");
//! clear profile cache
auto profile_cache = mgb::PersistentCache::inst().get_cache();
DEFINE_BOOL_WRAP(lite);
{
std::string model_path = "./shufflenet.mge";
timer.reset_start();
TEST_INT32_OPTION(iter, 1);
heristic_time = timer.get_used_time();
}
{
std::string model_path = "./shufflenet.mge";
timer.reset_start();
DEFINE_INT32_WRAP(iter, 1);
TEST_BOOL_OPTION(fast_run);
fast_run_time = timer.get_used_time();
}
//! profile time is longer than excute time
ASSERT_LT(heristic_time, fast_run_time);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册