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.

reduce.cpp 2.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "test/naive/fixture.h"
  2. #include "megdnn/oprs/nn.h"
  3. #include "test/common/checker.h"
  4. #include "test/common/random_state.h"
  5. using namespace megdnn;
  6. using namespace test;
  7. TEST_F(NAIVE, REDUCE_QUANTIZED) {
  8. using Mode = Reduce::Param::Mode;
  9. Checker<Reduce> checker(handle(), /* check_dispatch */ false);
  10. Reduce::Param param;
  11. param.mode = Mode::SUM;
  12. param.data_type = param::Reduce::DataType::QUINT_I8xO32;
  13. param.axis = 0;
  14. checker.set_param(param).exect(
  15. Testcase{
  16. TensorValue(
  17. {3, 4}, dtype::Quantized8Asymm(0.1f, (uint8_t)128),
  18. {6, 97, 210, 47, 213, 246, 92, 121, 132, 133, 222, 166}),
  19. {}},
  20. Testcase{
  21. {},
  22. TensorValue(
  23. {1, 4}, dtype::QuantizedS32(0.1f), {-33, 92, 140, -50})});
  24. param.data_type = param::Reduce::DataType::DEFAULT;
  25. param.mode = Mode::MEAN;
  26. checker.set_param(param).exect(
  27. Testcase{
  28. TensorValue(
  29. {3, 4}, dtype::Quantized8Asymm(1.f, (uint8_t)128),
  30. {6, 97, 210, 47, 213, 246, 92, 121, 132, 133, 222, 166}),
  31. {}},
  32. Testcase{
  33. {},
  34. TensorValue(
  35. {1, 4}, dtype::Quantized8Asymm(1.f, (uint8_t)128),
  36. {117, 159, 175, 111})});
  37. checker.exect(
  38. Testcase{
  39. TensorValue(
  40. {3, 4}, dtype::Quantized8Asymm(0.00233f, (uint8_t)128),
  41. {6, 97, 210, 47, 213, 246, 92, 121, 132, 133, 222, 166}),
  42. {}},
  43. Testcase{
  44. {},
  45. TensorValue(
  46. {1, 4}, dtype::Quantized8Asymm(0.00233f, (uint8_t)128),
  47. {117, 159, 175, 111})});
  48. checker.exect(
  49. Testcase{
  50. TensorValue(
  51. {3, 4}, dtype::Quantized8Asymm(7e-10f, (uint8_t)45),
  52. {6, 97, 210, 47, 213, 246, 92, 121, 132, 133, 222, 166}),
  53. {}},
  54. Testcase{
  55. {},
  56. TensorValue(
  57. {1, 4}, dtype::Quantized8Asymm(7e-10f, (uint8_t)45),
  58. {117, 159, 175, 111})});
  59. }
  60. // vim: syntax=cpp.doxygen