@@ -170,6 +170,64 @@ template <typename T, typename Distance> void test_distance() {
170170 test_distance_single<std::int8_t , Distance, N>(-10 , 1 );
171171}
172172
173+ CATCH_TEST_CASE (" SQDataset Element Size" , " [quantization][scalar]" ) {
174+ CATCH_SECTION (" Check element_size()" ) {
175+ // Test with int8_t, dynamic dimensions
176+ auto sq_int8_dynamic = scalar::SQDataset<std::int8_t >(10 , 128 );
177+ CATCH_REQUIRE (sq_int8_dynamic.element_size () == sizeof (std::int8_t ) * 128 );
178+
179+ // Test with int8_t, fixed dimensions
180+ constexpr size_t dims_64 = 64 ;
181+ auto sq_int8_fixed = scalar::SQDataset<std::int8_t , dims_64>({}, 1 .0F , 0 .0F );
182+ CATCH_REQUIRE (sq_int8_fixed.element_size () == sizeof (std::int8_t ) * dims_64);
183+
184+ // Test with int16_t, dynamic dimensions
185+ auto sq_int16_dynamic = scalar::SQDataset<std::int16_t >(5 , 256 );
186+ CATCH_REQUIRE (sq_int16_dynamic.element_size () == sizeof (std::int16_t ) * 256 );
187+
188+ // Test with int16_t, fixed dimensions
189+ constexpr size_t dims_32 = 32 ;
190+ auto sq_int16_fixed = scalar::SQDataset<std::int16_t , dims_32>({}, 2 .0F , 1 .0F );
191+ CATCH_REQUIRE (sq_int16_fixed.element_size () == sizeof (std::int16_t ) * dims_32);
192+
193+ // Test with uint8_t, dynamic dimensions
194+ auto sq_uint8_dynamic = scalar::SQDataset<std::uint8_t >(8 , 96 );
195+ CATCH_REQUIRE (sq_uint8_dynamic.element_size () == sizeof (std::uint8_t ) * 96 );
196+
197+ // Test with uint8_t, fixed dimensions
198+ constexpr size_t dims_48 = 48 ;
199+ auto sq_uint8_fixed = scalar::SQDataset<std::uint8_t , dims_48>({}, 1 .5F , 0 .5F );
200+ CATCH_REQUIRE (sq_uint8_fixed.element_size () == sizeof (std::uint8_t ) * dims_48);
201+
202+ // Test with uint16_t, dynamic dimensions
203+ auto sq_uint16_dynamic = scalar::SQDataset<std::uint16_t >(12 , 200 );
204+ CATCH_REQUIRE (sq_uint16_dynamic.element_size () == sizeof (std::uint16_t ) * 200 );
205+
206+ // Test element_size consistency across different instances with same type/dims
207+ auto sq1 = scalar::SQDataset<std::int8_t >(10 , 100 );
208+ // Different size, same dims
209+ auto sq2 = scalar::SQDataset<std::int8_t >(50 , 100 );
210+ CATCH_REQUIRE (sq1.element_size () == sq2.element_size ());
211+
212+ // Test different quantized types with same dimensions
213+ auto sq_int8_128 = scalar::SQDataset<std::int8_t >(5 , 128 );
214+ auto sq_int16_128 = scalar::SQDataset<std::int16_t >(5 , 128 );
215+ CATCH_REQUIRE (sq_int8_128.element_size () == sizeof (std::int8_t ) * 128 );
216+ CATCH_REQUIRE (sq_int16_128.element_size () == sizeof (std::int16_t ) * 128 );
217+ // int16 is 2x int8
218+ CATCH_REQUIRE (sq_int16_128.element_size () == 2 * sq_int8_128.element_size ());
219+
220+ // Test that element_size reflects the quantized type, not original float
221+ auto original = svs::data::SimpleData<float >(5 , 128 );
222+ auto compressed = scalar::SQDataset<std::int8_t >::compress (original);
223+ CATCH_REQUIRE (compressed.element_size () == sizeof (std::int8_t ) * 128 );
224+ // Should be smaller
225+ CATCH_REQUIRE (compressed.element_size () != sizeof (float ) * 128 );
226+ // int8 vs float
227+ CATCH_REQUIRE (compressed.element_size () == original.element_size () / 4 );
228+ }
229+ }
230+
173231CATCH_TEST_CASE (" Testing SQDataset" , " [quantization][scalar]" ) {
174232 CATCH_SECTION (" Default SQDataset" ) {}
175233
0 commit comments