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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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-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
  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, TensorShape oshape)
  24. : param(param), ishape(ishape), oshape(oshape) {}
  25. };
  26. inline std::vector<TestArg> get_args() {
  27. std::vector<TestArg> args;
  28. using Param = param::AdaptivePooling;
  29. using Mode = param::AdaptivePooling::Mode;
  30. for (size_t i = 36; i < 40; ++i) {
  31. args.emplace_back(
  32. Param{Mode::AVERAGE}, TensorShape{2, 3, i, i + 1},
  33. TensorShape{2, 3, i - 4, i - 2});
  34. args.emplace_back(
  35. Param{Mode::MAX}, TensorShape{2, 3, i, i + 1},
  36. TensorShape{2, 3, i - 4, i - 2});
  37. }
  38. for (size_t i = 5; i < 10; ++i) {
  39. args.emplace_back(
  40. Param{Mode::AVERAGE}, TensorShape{2, 3, i, i + 1},
  41. TensorShape{2, 3, i - 3, i - 2});
  42. args.emplace_back(
  43. Param{Mode::MAX}, TensorShape{2, 3, i, i + 1},
  44. TensorShape{2, 3, i - 3, i - 2});
  45. }
  46. return args;
  47. }
  48. } // namespace adaptive_pooling
  49. } // namespace test
  50. } // namespace megdnn
  51. // vim: syntax=cpp.doxygen

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