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_layout_options.cpp 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #include <gtest/gtest.h>
  2. #include <string.h>
  3. #include <memory>
  4. #include "test_common.h"
  5. #include "test_options.h"
  6. using namespace lar;
  7. DECLARE_bool(lite);
  8. DECLARE_bool(cpu);
  9. #if LITE_WITH_CUDA
  10. DECLARE_bool(cuda);
  11. #endif
  12. DECLARE_bool(enable_nchw4);
  13. DECLARE_bool(enable_chwn4);
  14. DECLARE_bool(enable_nchw44);
  15. DECLARE_bool(enable_nchw88);
  16. DECLARE_bool(enable_nchw32);
  17. DECLARE_bool(enable_nchw64);
  18. DECLARE_bool(enable_nhwcd4);
  19. DECLARE_bool(enable_nchw44_dot);
  20. DECLARE_bool(fast_run);
  21. DECLARE_int32(iter);
  22. namespace {
  23. BOOL_OPTION_WRAP(enable_nchw4);
  24. BOOL_OPTION_WRAP(enable_chwn4);
  25. BOOL_OPTION_WRAP(enable_nchw44);
  26. BOOL_OPTION_WRAP(enable_nchw88);
  27. BOOL_OPTION_WRAP(enable_nchw32);
  28. BOOL_OPTION_WRAP(enable_nchw64);
  29. BOOL_OPTION_WRAP(enable_nhwcd4);
  30. BOOL_OPTION_WRAP(enable_nchw44_dot);
  31. BOOL_OPTION_WRAP(fast_run);
  32. INT32_OPTION_WRAP(iter, 10);
  33. BOOL_OPTION_WRAP(lite);
  34. BOOL_OPTION_WRAP(cpu);
  35. #if LITE_WITH_CUDA
  36. BOOL_OPTION_WRAP(cuda);
  37. #endif
  38. } // anonymous namespace
  39. TEST(TestLarLayout, X86_CPU) {
  40. DEFINE_INT32_WRAP(iter, 1);
  41. DEFINE_BOOL_WRAP(cpu);
  42. std::string model_path = "./shufflenet.mge";
  43. TEST_BOOL_OPTION(enable_nchw4);
  44. TEST_BOOL_OPTION(enable_chwn4);
  45. TEST_BOOL_OPTION(enable_nchw44);
  46. TEST_BOOL_OPTION(enable_nchw44_dot);
  47. TEST_BOOL_OPTION(enable_nchw64);
  48. TEST_BOOL_OPTION(enable_nchw32);
  49. TEST_BOOL_OPTION(enable_nchw88);
  50. }
  51. TEST(TestLarLayout, X86_CPU_LITE) {
  52. DEFINE_INT32_WRAP(iter, 1);
  53. DEFINE_BOOL_WRAP(cpu);
  54. DEFINE_BOOL_WRAP(lite);
  55. std::string model_path = "./shufflenet.mge";
  56. TEST_BOOL_OPTION(enable_nchw4);
  57. TEST_BOOL_OPTION(enable_nchw44);
  58. TEST_BOOL_OPTION(enable_nchw44_dot);
  59. TEST_BOOL_OPTION(enable_nchw64);
  60. TEST_BOOL_OPTION(enable_nchw32);
  61. TEST_BOOL_OPTION(enable_nchw88);
  62. }
  63. TEST(TestLarLayoutFastRun, CPU_LITE) {
  64. DEFINE_INT32_WRAP(iter, 1);
  65. DEFINE_BOOL_WRAP(cpu);
  66. DEFINE_BOOL_WRAP(lite);
  67. std::string model_path = "./shufflenet.mge";
  68. {
  69. DEFINE_BOOL_WRAP(enable_nchw44);
  70. DEFINE_BOOL_WRAP(fast_run);
  71. run_NormalStrategy(model_path);
  72. }
  73. }
  74. #if LITE_WITH_CUDA
  75. TEST(TestLarLayout, CUDA) {
  76. DEFINE_INT32_WRAP(iter, 1);
  77. DEFINE_BOOL_WRAP(cuda);
  78. std::string model_path = "./shufflenet.mge";
  79. TEST_BOOL_OPTION(enable_nchw4);
  80. TEST_BOOL_OPTION(enable_chwn4);
  81. TEST_BOOL_OPTION(enable_nchw64);
  82. TEST_BOOL_OPTION(enable_nchw32);
  83. FLAGS_cuda = false;
  84. }
  85. TEST(TestLarLayout, CUDA_LITE) {
  86. DEFINE_INT32_WRAP(iter, 1);
  87. DEFINE_BOOL_WRAP(cuda);
  88. DEFINE_BOOL_WRAP(lite);
  89. std::string model_path = "./shufflenet.mge";
  90. TEST_BOOL_OPTION(enable_nchw4);
  91. TEST_BOOL_OPTION(enable_nchw64);
  92. TEST_BOOL_OPTION(enable_nchw32);
  93. }
  94. #endif
  95. // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}