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.

pooling.h 2.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * \file dnn/test/common/pooling.h
  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. #pragma once
  12. #include "megdnn/opr_param_defs.h"
  13. #include "megdnn/basic_types.h"
  14. #include <cstddef>
  15. namespace megdnn {
  16. namespace test {
  17. namespace pooling {
  18. struct TestArg {
  19. param::Pooling param;
  20. TensorShape ishape;
  21. TestArg(param::Pooling param, TensorShape ishape)
  22. : param(param), ishape(ishape) {}
  23. };
  24. inline std::vector<TestArg> get_args() {
  25. std::vector<TestArg> args;
  26. using Param = param::Pooling;
  27. using Mode = param::Pooling::Mode;
  28. // ppssww
  29. for (size_t i = 32; i < 40; ++i) {
  30. args.emplace_back(Param{Mode::AVERAGE, 1, 1, 2, 2, 2, 2},
  31. TensorShape{2, 3, i, i + 1});
  32. /* reserved for future test */
  33. /*
  34. args.emplace_back(Param{Mode::AVERAGE_COUNT_EXCLUDE_PADDING, 1, 1, 2, 2,
  35. 2, 2}, TensorShape{2, 3, i, i+1});
  36. */
  37. args.emplace_back(Param{Mode::MAX, 1, 1, 2, 2, 2, 2},
  38. TensorShape{2, 3, i, i + 1});
  39. }
  40. for (size_t i = 32; i < 40; ++i) {
  41. args.emplace_back(Param{Mode::MAX, 1, 1, 2, 2, 3, 3},
  42. TensorShape{2, 3, i, i + 1});
  43. }
  44. for (uint32_t ph : {0, 1, 2})
  45. for (uint32_t pw : {0, 1, 2}) {
  46. args.emplace_back(Param{Mode::MAX, ph, pw, 1, 1, 3, 3},
  47. TensorShape{2, 3, 20, 22});
  48. }
  49. // small shape for float16
  50. for (size_t i = 5; i < 10; ++i) {
  51. args.emplace_back(Param{Mode::AVERAGE, 1, 1, 2, 2, 2, 2},
  52. TensorShape{2, 3, i, i + 1});
  53. /* reserved for future test */
  54. /*
  55. args.emplace_back(Param{Mode::AVERAGE_COUNT_EXCLUDE_PADDING, 1, 1, 2, 2,
  56. 2, 2}, TensorShape{2, 3, i, i+1});
  57. */
  58. }
  59. for (uint32_t ph : {0, 1, 2})
  60. for (uint32_t pw : {0, 1, 2}) {
  61. args.emplace_back(Param{Mode::MAX, ph, pw, 1, 1, 3, 3},
  62. TensorShape{1, 2, 10, 11});
  63. }
  64. return args;
  65. }
  66. } // namespace pooling
  67. } // namespace test
  68. } // namespace megdnn
  69. // vim: syntax=cpp.doxygen

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