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.

group_local.cpp 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * \file dnn/test/cpu/group_local.cpp
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. */
  11. #include "megdnn/oprs/nn.h"
  12. #include "test/cpu/fixture.h"
  13. #include "test/common/checker.h"
  14. namespace megdnn {
  15. namespace test {
  16. TEST_F(CPU, GROUP_LOCAL)
  17. {
  18. auto run = [&](size_t N, size_t IC, size_t IH, size_t IW,
  19. size_t FH, size_t FW,
  20. size_t OC, size_t OH, size_t OW,
  21. size_t PH, size_t PW,
  22. size_t SH, size_t SW,
  23. size_t group)
  24. {
  25. Checker<GroupLocal> checker(handle());
  26. GroupLocal::Param param;
  27. param.pad_h = PH;
  28. param.pad_w = PW;
  29. param.stride_h = SH;
  30. param.stride_w = SW;
  31. auto ICg = IC / group;
  32. auto OCg = OC / group;
  33. checker.set_param(param).exec({{N, IC, IH, IW},
  34. {group, OH, OW, ICg, FH, FW, OCg},
  35. {}});
  36. };
  37. // simple groupped
  38. run(2, 6, 5, 5,
  39. 2, 2,
  40. 9, 4, 4,
  41. 0, 0,
  42. 1, 1,
  43. 3);
  44. // ungroupped
  45. run(1, 1, 1, 1,
  46. 1, 1,
  47. 1, 1, 1,
  48. 0, 0,
  49. 1, 1,
  50. 1);
  51. // normal case
  52. run(2, 64, 7, 7,
  53. 3, 3,
  54. 32, 5, 5,
  55. 0, 0,
  56. 1, 1,
  57. 1);
  58. // padded and stridded case
  59. run(2, 32, 7, 7,
  60. 3, 3,
  61. 64, 9, 4,
  62. 2, 1,
  63. 1, 2,
  64. 4);
  65. // strided case with larger batch
  66. run(7, 32, 7, 7,
  67. 3, 3,
  68. 64, 3, 3,
  69. 0, 0,
  70. 2, 2,
  71. 8);
  72. }
  73. } // namespace test
  74. } // namespace megdnn
  75. // vim: syntax=cpp.doxygen

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台

Contributors (1)