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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * \file dnn/test/naive/images2neibs.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, IMAGES2NEIBS_FORWARD) {
  17. Checker<Images2Neibs> checker(handle(), /* check_dispatch */false);
  18. Images2Neibs::Param param(0,0,1,1,1,1,2,2);
  19. checker.set_param(param).exect(
  20. Testcase{TensorValue({1, 1, 3, 3}, dtype::Uint8(),
  21. {0,1,2,
  22. 3,4,5,
  23. 6,7,8}), {}},
  24. Testcase{{},
  25. TensorValue({1, 1, 2, 2, 2, 2}, dtype::Uint8(),
  26. {0,1,3,4,
  27. 1,2,4,5,
  28. 3,4,6,7,
  29. 4,5,7,8})});
  30. param.pad_h = 1;
  31. param.pad_w = 1;
  32. param.stride_h = 2;
  33. param.stride_w = 2;
  34. param.dilate_h = 2;
  35. param.dilate_w = 2;
  36. param.window_h = 3;
  37. param.window_w = 3;
  38. checker.set_param(param).exect(
  39. Testcase{TensorValue({1, 1, 6, 7}, dtype::Uint8(),
  40. {0,1,2,3,4,5,6,
  41. 7,8,9,10,11,12,13,
  42. 14,15,16,17,18,19,20,
  43. 21,22,23,24,25,26,27,
  44. 28,29,30,31,32,33,34,
  45. 35,36,37,38,39,40,41}), {}},
  46. Testcase{{},
  47. TensorValue({1, 1, 2, 3, 3, 3}, dtype::Uint8(),
  48. {0,0,0,0,8,10,0,22,24,
  49. 0,0,0,8,10,12,22,24,26,
  50. 0,0,0,10,12,0,24,26,0,
  51. 0,8,10,0,22,24,0,36,38,
  52. 8,10,12,22,24,26,36,38,40,
  53. 10,12,0,24,26,0,38,40,0})});
  54. }

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