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

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