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.

accuracy_shake.cpp 3.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * \file dnn/test/x86/accuracy_shake.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
  10. * implied.
  11. */
  12. #include "test/x86/fixture.h"
  13. #include "megdnn/opr_param_defs.h"
  14. #include "megdnn/oprs.h"
  15. #include "test/common/accuracy_shake_checker.h"
  16. #include "test/common/convolution.h"
  17. #include "test/common/rng.h"
  18. #include "test/common/tensor.h"
  19. #include "test/common/workspace_wrapper.h"
  20. namespace megdnn {
  21. namespace test {
  22. TEST_F(X86, SHAKE_CONV_BIAS_FORWARD) {
  23. AccuracyShakeChecker<ConvBiasForward> checker(handle());
  24. NormalRNG default_rng;
  25. checker.set_dtype(0, dtype::Float32())
  26. .set_dtype(1, dtype::Float32())
  27. .set_dtype(2, dtype::Float32())
  28. .set_rng(0, &default_rng)
  29. .set_rng(1, &default_rng);
  30. checker.set_before_exec_callback(AlgoGenerator<ConvBiasForward>("X86"));
  31. // convolution
  32. checker.exec({{6, 16, 32, 32}, {64, 16, 3, 3}, {}, {}, {}});
  33. // convbias without z
  34. checker.exec({{6, 16, 32, 32}, {64, 16, 3, 3}, {1, 64, 1, 1}, {}, {}});
  35. // convbias with z
  36. checker.exec({{6, 16, 32, 32}, {64, 16, 3, 3}, {1, 64, 1, 1}, {6, 64, 30, 30}, {}});
  37. // group
  38. ConvBias::Param param;
  39. param.sparse = ConvBias::Param::Sparse::GROUP;
  40. checker.set_param(param);
  41. checker.exec({{6, 16, 32, 32}, {2, 32, 8, 3, 3}, {}, {}, {}});
  42. checker.exec({{6, 16, 32, 32}, {2, 32, 8, 3, 3}, {1, 64, 1, 1}, {}, {}});
  43. checker.exec(
  44. {{6, 16, 32, 32}, {2, 32, 8, 3, 3}, {1, 64, 1, 1}, {6, 64, 30, 30}, {}});
  45. }
  46. TEST_F(X86, SHAKE_CONV_BIAS_FORWARD_INT8) {
  47. AccuracyShakeChecker<ConvBiasForward> checker(handle());
  48. UniformIntRNG rng{-50, 50};
  49. checker.set_dtype(0, dtype::QuantizedS8(2.5f))
  50. .set_dtype(1, dtype::QuantizedS8(2.5f))
  51. .set_dtype(2, dtype::QuantizedS32(6.25f))
  52. .set_dtype(3, dtype::QuantizedS32(6.25f))
  53. .set_dtype(4, {})
  54. .set_rng(0, &rng)
  55. .set_rng(1, &rng)
  56. .set_rng(2, &rng);
  57. checker.set_before_exec_callback(AlgoGenerator<ConvBiasForward>("X86"));
  58. // convolution
  59. checker.exec({{6, 16, 32, 32}, {64, 16, 3, 3}, {}, {}, {}});
  60. // convbias without z
  61. checker.exec({{6, 16, 32, 32}, {64, 16, 3, 3}, {1, 64, 1, 1}, {}, {}});
  62. // convbias with z
  63. checker.exec({{6, 16, 32, 32}, {64, 16, 3, 3}, {1, 64, 1, 1}, {6, 64, 30, 30}, {}});
  64. // group
  65. ConvBias::Param param;
  66. param.sparse = ConvBias::Param::Sparse::GROUP;
  67. checker.set_param(param);
  68. checker.exec({{6, 16, 32, 32}, {2, 32, 8, 3, 3}, {}, {}, {}});
  69. checker.exec({{6, 16, 32, 32}, {2, 32, 8, 3, 3}, {1, 64, 1, 1}, {}, {}});
  70. checker.exec(
  71. {{6, 16, 32, 32}, {2, 32, 8, 3, 3}, {1, 64, 1, 1}, {6, 64, 30, 30}, {}});
  72. }
  73. TEST_F(X86, SHAKE_MATRIX_MUL_FORWARD) {
  74. AccuracyShakeChecker<MatrixMul> checker(handle());
  75. checker.set_dtype(0, dtype::Float32())
  76. .set_dtype(1, dtype::Float32())
  77. .set_dtype(2, dtype::Float32())
  78. .exec({{20, 100}, {100, 60}, {}});
  79. }
  80. TEST_F(X86, SHAKE_MATRIX_MUL_6x16_FORWARD) {
  81. AccuracyShakeChecker<MatrixMul> checker(handle());
  82. checker.set_before_exec_callback(AlgoGenerator<MatrixMul>("X86_F32_6x16"));
  83. checker.set_dtype(0, dtype::Float32())
  84. .set_dtype(1, dtype::Float32())
  85. .set_dtype(2, dtype::Float32())
  86. .exec({{20, 100}, {100, 60}, {}});
  87. }
  88. } // namespace test
  89. } // namespace megdnn
  90. // vim: syntax=cpp.doxygen