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 1.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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-2021 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/common/checker.h"
  13. #include "test/cpu/fixture.h"
  14. namespace megdnn {
  15. namespace test {
  16. TEST_F(CPU, GROUP_LOCAL) {
  17. auto run = [&](size_t N, size_t IC, size_t IH, size_t IW, size_t FH, size_t FW,
  18. size_t OC, size_t OH, size_t OW, size_t PH, size_t PW, size_t SH,
  19. size_t SW, size_t group) {
  20. Checker<GroupLocal> checker(handle());
  21. GroupLocal::Param param;
  22. param.pad_h = PH;
  23. param.pad_w = PW;
  24. param.stride_h = SH;
  25. param.stride_w = SW;
  26. auto ICg = IC / group;
  27. auto OCg = OC / group;
  28. checker.set_param(param).exec(
  29. {{N, IC, IH, IW}, {group, OH, OW, ICg, FH, FW, OCg}, {}});
  30. };
  31. // simple groupped
  32. run(2, 6, 5, 5, 2, 2, 9, 4, 4, 0, 0, 1, 1, 3);
  33. // ungroupped
  34. run(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1);
  35. // normal case
  36. run(2, 64, 7, 7, 3, 3, 32, 5, 5, 0, 0, 1, 1, 1);
  37. // padded and stridded case
  38. run(2, 32, 7, 7, 3, 3, 64, 9, 4, 2, 1, 1, 2, 4);
  39. // strided case with larger batch
  40. run(7, 32, 7, 7, 3, 3, 64, 3, 3, 0, 0, 2, 2, 8);
  41. }
  42. } // namespace test
  43. } // namespace megdnn
  44. // vim: syntax=cpp.doxygen

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