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.

deformable_ps_roi_pooling.cpp 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * \file dnn/test/naive/deformable_ps_roi_pooling.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/benchmarker.h"
  14. #include "test/common/checker.h"
  15. #include "test/common/random_state.h"
  16. using namespace megdnn;
  17. using namespace test;
  18. TEST_F(NAIVE, DEFORMABLE_PSROI_POOLING_FWD) {
  19. Checker<DeformablePSROIPooling> checker(handle());
  20. DeformablePSROIPooling::Param param;
  21. param.no_trans = true;
  22. param.pooled_h = 3;
  23. param.pooled_w = 3;
  24. param.trans_std = 1.f;
  25. param.spatial_scale = 1.f;
  26. param.part_size = 1;
  27. param.sample_per_part = 1;
  28. UniformIntRNG data{0, 4};
  29. UniformIntRNG rois{0, 4};
  30. UniformIntRNG trans{-2, 2};
  31. checker.set_rng(0, &data).set_rng(1, &rois).set_rng(2, &trans);
  32. checker.set_param(param).execs({{4, 2, 5, 5}, {2, 5}, {4, 2, 5, 5}, {}, {}});
  33. }
  34. TEST_F(NAIVE, DEFORMABLE_PSROI_POOLING_BWD) {
  35. Checker<DeformablePSROIPoolingBackward> checker(handle());
  36. DeformablePSROIPoolingBackward::Param param;
  37. param.no_trans = true;
  38. param.pooled_h = 3;
  39. param.pooled_w = 3;
  40. param.trans_std = 1.f;
  41. param.spatial_scale = 1.f;
  42. param.part_size = 1;
  43. param.sample_per_part = 1;
  44. UniformIntRNG data{0, 4};
  45. UniformIntRNG rois{0, 4};
  46. UniformIntRNG trans{-2, 2};
  47. UniformIntRNG out_diff{-2, 2};
  48. UniformIntRNG out_count{-2, 2};
  49. checker.set_rng(0, &data)
  50. .set_rng(1, &rois)
  51. .set_rng(2, &trans)
  52. .set_rng(3, &out_diff)
  53. .set_rng(4, &out_count);
  54. checker.set_param(param).execs(
  55. {{4, 2, 5, 5}, // data
  56. {2, 5}, // rois
  57. {4, 2, 5, 5}, // trans
  58. {2, 2, 3, 3}, // out_diff
  59. {2, 2, 3, 3}, // out_count
  60. {4, 2, 5, 5},
  61. {4, 2, 5, 5}});
  62. }
  63. // vim: syntax=cpp.doxygen

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