You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <gflags/gflags.h>
  2. #include <string>
  3. #include "misc.h"
  4. #include "strategys/strategy.h"
  5. std::string simple_usage = R"(
  6. load_and_run: load_and_run <model_path> [options Flags...]
  7. Flags from lite/load_and_run/src/models/model.cpp:
  8. -lite type: bool default: false use megengine lite interface to run model
  9. Flags from lite/load_and_run/src/options/strategy_options.cpp:
  10. -iter type: int32 default: 10 iteration number for run model
  11. -thread type: int32 default: 1 thread number for run model when <thread> is supported
  12. -warmup_iter type: int32 default: 1 iteration number for warm up model before run
  13. Flags from com_github_gflags_gflags/src/gflags.cc:
  14. -flagfile type: string default: "" load flags from file
  15. -fromenv type: string default: "" set flags from the environment [use 'export FLAGS_flag1=value']
  16. ...
  17. Flags from com_github_gflags_gflags/src/gflags_reporting.cc:
  18. -help type: bool default: false show help on all flags
  19. -helpmatch type: string default: "" show help on modules whose name contains the specified substr
  20. -version type: bool default: false show version and build info and exit
  21. ...
  22. More details using "--help" to get!!
  23. )";
  24. int main(int argc, char** argv) {
  25. mgb::set_log_level(mgb::LogLevel::INFO);
  26. lite::set_log_level(LiteLogLevel::INFO);
  27. std::string usage = "load_and_run <model_path> [options Flags...]";
  28. if (argc < 2) {
  29. printf("usage: %s\n", simple_usage.c_str());
  30. return -1;
  31. }
  32. gflags::SetUsageMessage(usage);
  33. gflags::SetVersionString("1.0");
  34. gflags::ParseCommandLineFlags(&argc, &argv, true);
  35. std::string model_path = argv[1];
  36. auto strategy = lar::StrategyBase::create_strategy(model_path);
  37. strategy->run();
  38. gflags::ShutDownCommandLineFlags();
  39. return 0;
  40. }
  41. // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}