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.

images2neibs.h 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * \file dnn/test/common/images2neibs.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 images2neibs {
  18. struct TestArg {
  19. param::Images2Neibs param;
  20. TensorShape ishape;
  21. TestArg(param::Images2Neibs param, TensorShape ishape)
  22. : param(param), ishape(ishape) {}
  23. };
  24. inline std::vector<TestArg> get_args() {
  25. std::vector<TestArg> args;
  26. // clang-format off
  27. for (uint32_t ph : {0, 1})
  28. for (uint32_t pw : {0, 1})
  29. for (uint32_t sh : {1, 2})
  30. for (uint32_t sw : {1, 2})
  31. for (uint32_t dh : {1, 2, 3})
  32. for (uint32_t dw : {1, 2, 3})
  33. for (uint32_t wh : {3, 4})
  34. for (uint32_t ww : {3, 4}) {
  35. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  36. TensorShape{2, 3, 19, 20});
  37. }
  38. // clang-format on
  39. // large window case
  40. args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1, 32, 64},
  41. TensorShape{2, 3, 96, 128});
  42. // large size
  43. args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  44. TensorShape{128, 128, 28, 24});
  45. return args;
  46. }
  47. inline std::vector<TestArg> get_benchmark_args() {
  48. std::vector<TestArg> args;
  49. // clang-format off
  50. for (uint32_t ph : {0, 1})
  51. for (uint32_t pw : {0, 1})
  52. for (uint32_t sh : {1, 2})
  53. for (uint32_t sw : {1, 2})
  54. for (uint32_t dh : {1, 2})
  55. for (uint32_t dw : {1, 2})
  56. for (uint32_t wh : {3, 4})
  57. for (uint32_t ww : {3, 4})
  58. for (uint32_t b : {1, 64})
  59. for (uint32_t c : {64, 128})
  60. for (uint32_t hw : {64, 128}) {
  61. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
  62. TensorShape{b, c, hw, hw});
  63. }
  64. // clang-format on
  65. // large size
  66. args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
  67. TensorShape{1024, 128, 28, 24});
  68. return args;
  69. }
  70. } // namespace images2neibs
  71. } // namespace test
  72. } // namespace megdnn
  73. // vim: syntax=cpp.doxygen

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