@@ -243,12 +243,40 @@ START_TEST(test_take1_ok) {
243243}
244244END_TEST
245245
246+ START_TEST (test_take1_offset ) {
247+ const uint32_t data [24 ] = {0 , 1 , 2 , 3 };
248+ const size_t data_dims [1 ] = {4 };
249+ const size_t out_dims [1 ] = {2 };
250+ const uint32_t idx [4 ] = {20 , 3 , 3 , 2 };
251+ GpuArray v ;
252+ GpuArray i ;
253+ GpuArray r ;
254+
255+ ga_assert_ok (GpuArray_empty (& v , ctx , GA_UINT , 1 , data_dims , GA_C_ORDER ));
256+ ga_assert_ok (GpuArray_write (& v , data , sizeof (data )));
257+
258+ ga_assert_ok (GpuArray_empty (& i , ctx , GA_UINT , 1 , data_dims , GA_C_ORDER ));
259+ ga_assert_ok (GpuArray_write (& i , idx , sizeof (idx )));
260+
261+ ga_assert_ok (GpuArray_empty (& r , ctx , GA_UINT , 1 , out_dims , GA_C_ORDER ));
262+
263+ /* Fake subtensor for offset */
264+ i .offset = 8 ;
265+ i .dimensions [0 ] = 2 ;
266+
267+ ga_assert_ok (GpuArray_take1 (& r , & v , & i , 1 ));
268+ /* The actual results are not important, this is just to check that
269+ we don't trigger the out of bounds check */
270+ }
271+ END_TEST
272+
246273Suite * get_suite (void ) {
247274 Suite * s = suite_create ("array" );
248275 TCase * tc = tcase_create ("take1" );
249276 tcase_add_checked_fixture (tc , setup , teardown );
250277 tcase_set_timeout (tc , 8.0 );
251278 tcase_add_test (tc , test_take1_ok );
279+ tcase_add_test (tc , test_take1_offset );
252280 suite_add_tcase (s , tc );
253281 return s ;
254282}
0 commit comments