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

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

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