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.

comparator.inl 896 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "test/common/comparator.h"
  3. #include "test/common/utils.h"
  4. #include "megdnn/dtype.h"
  5. namespace megdnn {
  6. namespace test {
  7. template <typename T>
  8. bool DefaultComparator<T>::is_same(T expected, T actual) const {
  9. return expected == actual;
  10. }
  11. template <>
  12. class DefaultComparator<dt_float32> {
  13. public:
  14. bool is_same(dt_float32 expected, dt_float32 actual) const {
  15. return std::abs(diff(expected, actual)) < 1e-3;
  16. }
  17. };
  18. template <>
  19. class DefaultComparator<dt_qint8> {
  20. public:
  21. bool is_same(dt_qint8 expected, dt_qint8 actual) const {
  22. return expected.as_int8() == actual.as_int8();
  23. }
  24. };
  25. template <>
  26. class DefaultComparator<dt_qint32> {
  27. public:
  28. bool is_same(dt_qint32 expected, dt_qint32 actual) const {
  29. return expected.as_int32() == actual.as_int32();
  30. }
  31. };
  32. } // namespace test
  33. } // namespace megdnn
  34. // vim: syntax=cpp.doxygen