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.

plugin_options.h 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include <gflags/gflags.h>
  3. #if __linux__ || __unix__
  4. #include <unistd.h>
  5. #endif
  6. #include "megbrain/plugin/cpu_dispatch_checker.h"
  7. #include "megbrain/plugin/var_value_checker.h"
  8. #include "helpers/common.h"
  9. #include "helpers/text_table.h"
  10. #include "models/model.h"
  11. #include "option_base.h"
  12. DECLARE_bool(check_dispatch);
  13. DECLARE_double(range);
  14. DECLARE_string(check_var_value);
  15. #if MGB_ENABLE_JSON
  16. DECLARE_string(profile);
  17. DECLARE_string(profile_host);
  18. #endif
  19. DECLARE_bool(model_info);
  20. DECLARE_bool(verbose);
  21. DECLARE_bool(disable_assert_throw);
  22. #if __linux__ || __unix__
  23. DECLARE_bool(wait_gdb);
  24. #endif
  25. #ifndef __IN_TEE_ENV__
  26. #if MGB_ENABLE_JSON
  27. DECLARE_string(get_static_mem_info);
  28. #endif
  29. #endif
  30. namespace lar {
  31. class PluginOption final : public OptionBase {
  32. public:
  33. static bool is_valid();
  34. static std::shared_ptr<OptionBase> create_option();
  35. void config_model(
  36. RuntimeParam& runtime_param, std::shared_ptr<ModelBase> model) override;
  37. std::string option_name() const override { return m_option_name; };
  38. private:
  39. PluginOption();
  40. template <typename ModelImpl>
  41. void config_model_internel(RuntimeParam&, std::shared_ptr<ModelImpl>){};
  42. double range;
  43. bool enable_check_dispatch;
  44. #if MGB_ENABLE_JSON
  45. bool enable_profile_host;
  46. std::string profile_path;
  47. #endif
  48. std::string var_value_check_str;
  49. std::string m_option_name;
  50. std::unique_ptr<mgb::VarValueChecker> var_value_checker;
  51. std::unique_ptr<mgb::CPUDispatchChecker> cpu_dispatch_checker;
  52. };
  53. class DebugOption final : public OptionBase {
  54. public:
  55. static bool is_valid();
  56. static std::shared_ptr<OptionBase> create_option();
  57. void config_model(
  58. RuntimeParam& runtime_param, std::shared_ptr<ModelBase> model) override;
  59. std::string option_name() const override { return m_option_name; };
  60. private:
  61. DebugOption();
  62. template <typename ModelImpl>
  63. void format_and_print(const std::string&, std::shared_ptr<ModelImpl>){};
  64. template <typename ModelImpl>
  65. void config_model_internel(RuntimeParam&, std::shared_ptr<ModelImpl>){};
  66. bool enable_display_model_info;
  67. bool enable_verbose;
  68. bool disable_assert_throw;
  69. #if __linux__ || __unix__
  70. bool enable_wait_gdb;
  71. #endif
  72. #ifndef __IN_TEE_ENV__
  73. #if MGB_ENABLE_JSON
  74. std::string static_mem_log_dir_path;
  75. #endif
  76. #endif
  77. std::string m_option_name;
  78. };
  79. } // namespace lar