Browse Source

feat(mgb): add load_and_run option

GitOrigin-RevId: b383beb886
release-1.5
Megvii Engine Team 4 years ago
parent
commit
379a28f9b0
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      sdk/load-and-run/src/mgblar.cpp

+ 16
- 0
sdk/load-and-run/src/mgblar.cpp View File

@@ -138,6 +138,8 @@ R"__usage__(
level 2 the computing graph can be destructed to reduce memory usage. Read level 2 the computing graph can be destructed to reduce memory usage. Read
the doc of `ComputingGraph::Options::comp_node_seq_record_level` for more the doc of `ComputingGraph::Options::comp_node_seq_record_level` for more
details. details.
--get-static-mem-info <svgname>
Record the static graph's static memory info.
)__usage__" )__usage__"
#if MGB_ENABLE_FASTRUN #if MGB_ENABLE_FASTRUN
R"__usage__( R"__usage__(
@@ -522,6 +524,7 @@ struct Args {
#endif #endif
bool reproducible = false; bool reproducible = false;
std::string fast_run_cache_path; std::string fast_run_cache_path;
std::string static_mem_svg_path;
bool copy_to_host = false; bool copy_to_host = false;
int nr_run = 10; int nr_run = 10;
int nr_warmup = 1; int nr_warmup = 1;
@@ -746,6 +749,9 @@ void run_test_st(Args &env) {
} }


auto func = env.load_ret.graph_compile(out_spec); auto func = env.load_ret.graph_compile(out_spec);
if (!env.static_mem_svg_path.empty()) {
func->get_static_memory_alloc_info(env.static_mem_svg_path);
}
auto warmup = [&]() { auto warmup = [&]() {
printf("=== prepare: %.3fms; going to warmup\n", printf("=== prepare: %.3fms; going to warmup\n",
timer.get_msecs_reset()); timer.get_msecs_reset());
@@ -1319,6 +1325,16 @@ Args Args::from_argv(int argc, char **argv) {
graph_opt.comp_node_seq_record_level = 2; graph_opt.comp_node_seq_record_level = 2;
continue; continue;
} }
if (!strcmp(argv[i], "--get-static-mem-info")) {
++i;
mgb_assert(i < argc, "value not given for --get-static-mem-info");
ret.static_mem_svg_path = argv[i];
mgb_assert(
ret.static_mem_svg_path.find(".svg") != std::string::npos,
"the filename should be end with .svg, but got %s",
ret.static_mem_svg_path.c_str());
continue;
}
#if MGB_ENABLE_FASTRUN #if MGB_ENABLE_FASTRUN
if (!strcmp(argv[i], "--fast-run")) { if (!strcmp(argv[i], "--fast-run")) {
ret.use_fast_run = true; ret.use_fast_run = true;


Loading…
Cancel
Save