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.

adaptive_pooling.h 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * \file dnn/test/common/adaptive_pooling.h
  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
  10. * implied.
  11. */
  12. #pragma once
  13. #include <cstddef>
  14. #include "megdnn/basic_types.h"
  15. #include "megdnn/opr_param_defs.h"
  16. namespace megdnn {
  17. namespace test {
  18. namespace adaptive_pooling {
  19. struct TestArg {
  20. param::AdaptivePooling param;
  21. TensorShape ishape;
  22. TensorShape oshape;
  23. TestArg(param::AdaptivePooling param, TensorShape ishape,
  24. TensorShape oshape)
  25. : param(param), ishape(ishape), oshape(oshape) {}
  26. };
  27. inline std::vector<TestArg> get_args() {
  28. std::vector<TestArg> args;
  29. using Param = param::AdaptivePooling;
  30. using Mode = param::AdaptivePooling::Mode;
  31. for (size_t i = 36; i < 40; ++i) {
  32. args.emplace_back(Param{Mode::AVERAGE}, TensorShape{2, 3, i, i + 1},
  33. TensorShape{2, 3, i - 4, i - 2});
  34. args.emplace_back(Param{Mode::MAX}, TensorShape{2, 3, i, i + 1},
  35. TensorShape{2, 3, i - 4, i - 2});
  36. }
  37. for (size_t i = 5; i < 10; ++i) {
  38. args.emplace_back(Param{Mode::AVERAGE}, TensorShape{2, 3, i, i + 1},
  39. TensorShape{2, 3, i - 3, i - 2});
  40. args.emplace_back(Param{Mode::MAX}, TensorShape{2, 3, i, i + 1},
  41. TensorShape{2, 3, i - 3, i - 2});
  42. }
  43. return args;
  44. }
  45. } // namespace adaptive_pooling
  46. } // namespace test
  47. } // namespace megdnn
  48. // vim: syntax=cpp.doxygen

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