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.

sliding_window_transpose.h 2.9 kB

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

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