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.

pooling.cpp 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * \file dnn/test/naive/pooling.cpp
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2020 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. #include "test/common/random_state.h"
  15. using namespace megdnn;
  16. using namespace test;
  17. TEST_F(NAIVE, POOLING_QUANTIZED) {
  18. using Mode = Pooling::Param::Mode;
  19. Checker<Pooling> checker(handle(), /* check_dispatch */false);
  20. Pooling::Param param{Mode::MAX, 1, 1, 2, 2, 2, 2};
  21. auto dt = dtype::Quantized8Asymm(0.1f, (uint8_t)128);
  22. Testcase input{TensorValue({1, 1, 3, 3}, dt,
  23. {90, 136, 85,
  24. 48, 9, 226,
  25. 118, 109, 87}), {}};
  26. checker.set_param(param).exect(input, Testcase{{},
  27. TensorValue({1, 1, 2, 2}, dt, {90, 136,
  28. 118, 226})});
  29. param = {Mode::AVERAGE, 1, 1, 2, 2, 2, 2};
  30. checker.set_param(param).exect(input, Testcase{{},
  31. TensorValue({1, 1, 2, 2}, dt, {119, 119,
  32. 106, 108})});
  33. param = {Mode::AVERAGE_COUNT_EXCLUDE_PADDING, 1, 1, 2, 2, 2, 2};
  34. checker.set_param(param).exect(input, Testcase{{},
  35. TensorValue({1, 1, 2, 2}, dt, {90, 111,
  36. 83, 108})});
  37. auto dt32 = dtype::QuantizedS32(0.233f);
  38. Testcase input32{TensorValue({1, 1, 3, 3}, dt32,
  39. {12315, 10086, 10010,
  40. 12306, 23333, 19191,
  41. 9987, 12450, 12345}), {}};
  42. param = {Mode::MAX, 1, 1, 2, 2, 2, 2};
  43. checker.set_param(param).exect(input32, Testcase{{},
  44. TensorValue({1, 1, 2, 2}, dt32, {12315, 10086,
  45. 12306, 23333})});
  46. }
  47. // vim: syntax=cpp.doxygen

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