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

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

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