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.

test_options.h 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include <iostream>
  3. #include <thread>
  4. #include "../load_and_run/src/strategys/strategy.h"
  5. #include "../load_and_run/src/strategys/strategy_normal.h"
  6. #include "megbrain/common.h"
  7. #include "megbrain/utils/timer.h"
  8. #include "megbrain/version.h"
  9. #include "megdnn/version.h"
  10. #include "misc.h"
  11. namespace lar {
  12. //! run load_and_run NormalStrategy to test different options
  13. void run_NormalStrategy(std::string model_path);
  14. } // namespace lar
  15. #define BOOL_OPTION_WRAP(option) \
  16. struct BoolOptionWrap_##option { \
  17. BoolOptionWrap_##option() { FLAGS_##option = true; } \
  18. ~BoolOptionWrap_##option() { FLAGS_##option = false; } \
  19. };
  20. #define STRING_OPTION_WRAP(option, default_val) \
  21. struct StringOptionWrap_##option { \
  22. StringOptionWrap_##option(const char* val) { FLAGS_##option = val; } \
  23. ~StringOptionWrap_##option() { FLAGS_##option = default_val; } \
  24. };
  25. #define INT32_OPTION_WRAP(option, default_val) \
  26. struct Int32OptionWrap_##option { \
  27. Int32OptionWrap_##option(int32_t val) { FLAGS_##option = val; } \
  28. ~Int32OptionWrap_##option() { FLAGS_##option = default_val; } \
  29. };
  30. #define DEFINE_BOOL_WRAP(option) BoolOptionWrap_##option flags_##option;
  31. #define DEFINE_STRING_WRAP(option, value) \
  32. StringOptionWrap_##option flags_##option(value);
  33. #define DEFINE_INT32_WRAP(option, value) Int32OptionWrap_##option flags_##option(value);
  34. #define TEST_BOOL_OPTION(option) \
  35. { \
  36. DEFINE_BOOL_WRAP(option); \
  37. run_NormalStrategy(model_path); \
  38. }
  39. #define TEST_STRING_OPTION(option, value) \
  40. { \
  41. DEFINE_STRING_WRAP(option, value); \
  42. run_NormalStrategy(model_path); \
  43. }
  44. #define TEST_INT32_OPTION(option, value) \
  45. { \
  46. DEFINE_INT32_WRAP(option, value); \
  47. run_NormalStrategy(model_path); \
  48. }
  49. // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}