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.

conv_bias.cpp 2.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "test/armv7/fixture.h"
  2. #include "test/common/benchmarker.h"
  3. #include "test/common/checker.h"
  4. #include "test/common/conv_bias.h"
  5. #include "test/common/convolution.h"
  6. #include "test/common/rng.h"
  7. using namespace megdnn;
  8. using namespace test;
  9. namespace {
  10. TEST_F(ARMV7, CONV_BIAS_MATMUL_QU8) {
  11. using namespace conv_bias;
  12. std::vector<TestArg> args = get_quantized_args();
  13. Checker<ConvBiasForward> checker(handle());
  14. checker.set_before_exec_callback(
  15. conv_bias::ConvBiasAlgoChecker<ConvBias>("QU8MATMUL"));
  16. UniformIntRNG rng{0, 127};
  17. for (auto&& arg : args) {
  18. if (arg.bias.ndim == 4 && arg.bias[2] != 1 && arg.bias[3] != 1)
  19. continue;
  20. checker.set_dtype(0, dtype::Quantized8Asymm(2.5f, static_cast<uint8_t>(127)))
  21. .set_dtype(1, dtype::Quantized8Asymm(2.7f, static_cast<uint8_t>(129)))
  22. .set_dtype(2, dtype::QuantizedS32(6.75f))
  23. .set_dtype(4, dtype::Quantized8Asymm(60.25f, static_cast<uint8_t>(125)))
  24. .set_rng(0, &rng)
  25. .set_rng(1, &rng)
  26. .set_rng(2, &rng)
  27. .set_param(arg.param)
  28. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  29. }
  30. }
  31. TEST_F(ARMV7, CONV_BIAS_MATMUL_QS8) {
  32. using namespace conv_bias;
  33. std::vector<TestArg> args = get_quantized_args();
  34. Checker<ConvBiasForward> checker(handle());
  35. checker.set_before_exec_callback(
  36. conv_bias::ConvBiasAlgoChecker<ConvBias>("S8MATMUL"));
  37. UniformIntRNG rng{0, 127};
  38. for (auto&& arg : args) {
  39. if (arg.bias.ndim == 4 && arg.bias[2] != 1 && arg.bias[3] != 1)
  40. continue;
  41. checker.set_dtype(0, dtype::QuantizedS8(2.5f))
  42. .set_dtype(1, dtype::QuantizedS8(2.7f))
  43. .set_dtype(2, dtype::QuantizedS32(6.75f))
  44. .set_dtype(4, dtype::QuantizedS8(60.25f))
  45. .set_rng(0, &rng)
  46. .set_rng(1, &rng)
  47. .set_rng(2, &rng)
  48. .set_param(arg.param)
  49. .set_epsilon(1.0f)
  50. .execs({arg.src, arg.filter, arg.bias, {}, {}});
  51. }
  52. }
  53. } // namespace
  54. // vim: syntax=cpp.doxygen