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.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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-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 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 wh : {3, 4})
  32. for (uint32_t ww : {3, 4}) {
  33. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, wh, ww},
  34. TensorShape{2, 3, 5, 6});
  35. }
  36. // clang-format on
  37. // large window case
  38. args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 32, 64},
  39. TensorShape{2, 3, 96, 128});
  40. // large size
  41. args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1},
  42. TensorShape{128, 128, 28, 24});
  43. return args;
  44. }
  45. inline std::vector<TestArg> get_benchmark_args() {
  46. std::vector<TestArg> args;
  47. // clang-format off
  48. for (uint32_t ph : {0, 1})
  49. for (uint32_t pw : {0, 1})
  50. for (uint32_t sh : {1, 2})
  51. for (uint32_t sw : {1, 2})
  52. for (uint32_t wh : {3, 4})
  53. for (uint32_t ww : {3, 4})
  54. for (uint32_t b : {1, 64})
  55. for (uint32_t c : {64, 128})
  56. for (uint32_t hw : {64, 128}) {
  57. args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, wh, ww},
  58. TensorShape{b, c, hw, hw});
  59. }
  60. // clang-format on
  61. // large size
  62. args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1},
  63. TensorShape{1024, 128, 28, 24});
  64. return args;
  65. }
  66. } // namespace images2neibs
  67. } // namespace test
  68. } // namespace megdnn
  69. // vim: syntax=cpp.doxygen

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