MCPcopy Create free account
hub / github.com/davisking/dlib / perform_test

Method perform_test

dlib/test/simd.cpp:79–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 simd_tester() : tester("test_simd", "Run tests on SIMD conversions.") {}
78
79 void perform_test() override
80 {
81 test_conversions<simd4f, simd4i>();
82 test_conversions<simd8f, simd8i>();
83 test_resize();
84
85 const simd4f values(1.75f, -2.5f, 0.0f, 17.0f);
86 const simd4i converted(values);
87 DLIB_TEST(converted[0] == 1);
88 DLIB_TEST(converted[1] == -2);
89 DLIB_TEST(converted[2] == 0);
90 DLIB_TEST(converted[3] == 17);
91
92 const simd4i integers(1, -2, 0, 17);
93 for (unsigned int i = 0; i < 4; ++i)
94 DLIB_TEST(integers[i] == converted[i]);
95
96#ifdef DLIB_HAVE_NEON
97 simd4i assigned;
98 assigned = values;
99 for (unsigned int i = 0; i < 4; ++i)
100 DLIB_TEST(assigned[i] == converted[i]);
101
102 // Both raw integer conversions remain available, even if their types alias.
103 const int32x4_t signed_vector = integers;
104 const uint32x4_t unsigned_vector = integers;
105 int32 signed_lanes[4];
106 uint32 unsigned_lanes[4];
107 vst1q_s32(signed_lanes, signed_vector);
108 vst1q_u32(unsigned_lanes, unsigned_vector);
109 for (unsigned int i = 0; i < 4; ++i)
110 DLIB_TEST(unsigned_lanes[i] == static_cast<uint32>(signed_lanes[i]));
111
112 const float32x4_t float_vector = values;
113 float float_lanes[4];
114 vst1q_f32(float_lanes, float_vector);
115 for (unsigned int i = 0; i < 4; ++i)
116 DLIB_TEST(float_lanes[i] == values[i]);
117
118 // A separate raw float-to-int conversion is possible only with distinct types.
119 if (!std::is_same<float32x4_t, int32x4_t>::value)
120 {
121 const int32x4_t raw_converted = values;
122 vst1q_s32(signed_lanes, raw_converted);
123 for (unsigned int i = 0; i < 4; ++i)
124 DLIB_TEST(signed_lanes[i] == converted[i]);
125 }
126#endif
127 }
128 } a;
129}

Callers

nothing calls this directly

Calls 1

test_resizeFunction · 0.85

Tested by

no test coverage detected