1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

use universal intrinsic for FP16

* use v_float16x4 (universal intrinsic) instead of raw SSE/NEON implementation
  * define v_load_f16/v_store_f16 since v_load can't be distinguished when short pointer passed
  * brush up implementation on old compiler (guard correctly)
  * add test for v_load_f16 and round trip conversion of v_float16x4
  * fix conversion error
This commit is contained in:
Tomoaki Teshima
2016-09-02 21:57:46 +09:00
parent 28db4a2207
commit 903789f7af
4 changed files with 149 additions and 36 deletions
+53
View File
@@ -1,3 +1,4 @@
#include "test_precomp.hpp"
#include "test_intrin_utils.hpp"
#include <climits>
@@ -710,6 +711,49 @@ template<typename R> struct TheTest
return *this;
}
#if CV_FP16
TheTest & test_loadstore_fp16()
{
AlignedData<R> data;
AlignedData<R> out;
// check if addresses are aligned and unaligned respectively
EXPECT_EQ((size_t)0, (size_t)&data.a.d % 16);
EXPECT_NE((size_t)0, (size_t)&data.u.d % 16);
EXPECT_EQ((size_t)0, (size_t)&out.a.d % 16);
EXPECT_NE((size_t)0, (size_t)&out.u.d % 16);
// check some initialization methods
R r1 = data.u;
R r2 = v_load_f16(data.a.d);
R r3(r2);
EXPECT_EQ(data.u[0], r1.get0());
EXPECT_EQ(data.a[0], r2.get0());
EXPECT_EQ(data.a[0], r3.get0());
// check some store methods
out.a.clear();
v_store_f16(out.a.d, r1);
EXPECT_EQ(data.a, out.a);
return *this;
}
TheTest & test_float_cvt_fp16()
{
AlignedData<v_float32x4> data;
// check conversion
v_float32x4 r1 = v_load(data.a.d);
v_float16x4 r2 = v_cvt_f16(r1);
v_float32x4 r3 = v_cvt_f32(r2);
EXPECT_EQ(0x3c00, r2.get0());
EXPECT_EQ(r3.get0(), r1.get0());
return *this;
}
#endif
};
@@ -915,6 +959,15 @@ TEST(hal_intrin, float64x2) {
}
#endif
#if CV_FP16
TEST(hal_intrin, float16x4) {
TheTest<v_float16x4>()
.test_loadstore_fp16()
.test_float_cvt_fp16()
;
}
#endif
};
};