Skip to content

Commit b18983a

Browse files
committed
test(hal): properly dispatch FP16 test
1 parent 76f7fb5 commit b18983a

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

modules/core/test/test_intrin.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#include "test_precomp.hpp"
2-
#include "test_intrin_utils.hpp"
32
#include <climits>
43

4+
#include "test_intrin_utils.hpp"
5+
6+
#define CV_CPU_SIMD_FILENAME "test_intrin_utils.hpp"
7+
#define CV_CPU_DISPATCH_MODE FP16
8+
#include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp"
9+
10+
511
using namespace cv;
612

713
namespace cvtest { namespace hal {
14+
using namespace CV_CPU_OPTIMIZATION_NAMESPACE;
815

916
//============= 8-bit integer =====================================================================
1017

@@ -220,4 +227,10 @@ TEST(hal_intrin, float64x2) {
220227
}
221228
#endif
222229

230+
TEST(hal_intrin,float16x4)
231+
{
232+
CV_CPU_CALL_FP16(test_hal_intrin_float16x4, ());
233+
throw SkipTestException("Unsupported hardware: FP16 is not available");
234+
}
235+
223236
}}

modules/core/test/test_intrin.fp16.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
#include "test_intrin_utils.hpp"
33

44
namespace cvtest { namespace hal {
5-
TEST(hal_intrin, float16x4) {
5+
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
6+
7+
void test_hal_intrin_float16x4()
8+
{
69
TheTest<v_float16x4>()
710
.test_loadstore_fp16()
811
.test_float_cvt_fp16()
912
;
1013
}
11-
}}
14+
15+
CV_CPU_OPTIMIZATION_NAMESPACE_END
16+
}} // namespace

modules/core/test/test_intrin_utils.hpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#ifndef _TEST_UTILS_HPP_
2-
#define _TEST_UTILS_HPP_
3-
41
#include "opencv2/core/hal/intrin.hpp"
5-
#include "opencv2/ts.hpp"
6-
#include <ostream>
7-
#include <algorithm>
8-
#include <climits>
2+
3+
namespace cvtest { namespace hal {
4+
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
5+
6+
void test_hal_intrin_float16x4();
7+
8+
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
99

1010
template <typename R> struct Data;
1111
template <int N> struct initializer;
@@ -156,8 +156,6 @@ template <typename R> std::ostream & operator<<(std::ostream & out, const Data<R
156156
return out;
157157
}
158158

159-
namespace cvtest { namespace hal {
160-
161159
template<typename T> static inline void EXPECT_COMPARE_EQ_(const T a, const T b);
162160
template<> inline void EXPECT_COMPARE_EQ_<float>(const float a, const float b)
163161
{
@@ -962,7 +960,8 @@ template<typename R> struct TheTest
962960
}
963961

964962
};
965-
}
966-
}
967963

968964
#endif
965+
966+
CV_CPU_OPTIMIZATION_NAMESPACE_END
967+
}} // namespace

0 commit comments

Comments
 (0)