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.cpp 2.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * \file dnn/test/naive/sliding_window_transpose.cpp
  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. #include "test/naive/fixture.h"
  12. #include "megdnn/oprs/nn.h"
  13. #include "test/common/checker.h"
  14. using namespace megdnn;
  15. using namespace test;
  16. TEST_F(NAIVE, SlidingWindowTranspose_FORWARD) {
  17. Checker<SlidingWindowTranspose> checker(handle(), /* check_dispatch */false);
  18. SlidingWindowTranspose::Param param(3,3,0,0,1,1,1,1,2,2);
  19. checker.set_param(param).exect(
  20. Testcase{TensorValue({1, 1, 2, 2, 2, 2}, dtype::Uint8(),
  21. {0,1,3,4,
  22. 1,2,4,5,
  23. 3,4,6,7,
  24. 4,5,7,8}), {}},
  25. Testcase{{},
  26. TensorValue({1, 1, 3, 3}, dtype::Uint8(),
  27. {0,2,2,
  28. 6,16,10,
  29. 6,14,8})});
  30. param.out_h = 6;
  31. param.out_w = 7;
  32. param.pad_h = 1;
  33. param.pad_w = 1;
  34. param.stride_h = 2;
  35. param.stride_w = 2;
  36. param.dilate_h = 2;
  37. param.dilate_w = 2;
  38. param.window_h = 3;
  39. param.window_w = 3;
  40. checker.set_param(param).exect(
  41. Testcase{TensorValue({1, 1, 2, 3, 3, 3}, dtype::Uint8(),
  42. {0,0,0,0,8,10,0,22,24,
  43. 0,0,0,8,10,12,22,24,26,
  44. 0,0,0,10,12,0,24,26,0,
  45. 0,8,10,0,22,24,0,36,38,
  46. 8,10,12,22,24,26,36,38,40,
  47. 10,12,0,24,26,0,38,40,0}), {}},
  48. Testcase{{},
  49. TensorValue({1, 1, 6, 7}, dtype::Uint8(),
  50. {0,0,0,0,0,0,0,
  51. 0,32,0,60,0,48,0,
  52. 0,0,0,0,0,0,0,
  53. 0,88,0,144,0,104,0,
  54. 0,0,0,0,0,0,0,
  55. 0,72,0,114,0,80,0})});
  56. }

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