@@ -2917,6 +2917,27 @@ def test_kernel_array_from_ptr(test, device):
2917
2917
assert_np_equal (arr .numpy (), np .array (((1.0 , 2.0 , 3.0 ), (0.0 , 0.0 , 0.0 ))))
2918
2918
2919
2919
2920
+ @wp .kernel
2921
+ def kernel_array_from_ptr_variable_shape (
2922
+ ptr : wp .uint64 ,
2923
+ shape_x : int ,
2924
+ shape_y : int ,
2925
+ ):
2926
+ arr = wp .array (ptr = ptr , shape = (shape_x , shape_y ), dtype = wp .float32 )
2927
+ arr [0 , 0 ] = 1.0
2928
+ arr [0 , 1 ] = 2.0
2929
+ if shape_y > 2 :
2930
+ arr [0 , 2 ] = 3.0
2931
+
2932
+
2933
+ def test_kernel_array_from_ptr_variable_shape (test , device ):
2934
+ arr = wp .zeros (shape = (2 , 3 ), dtype = wp .float32 , device = device )
2935
+ wp .launch (kernel_array_from_ptr_variable_shape , dim = (1 ,), inputs = (arr .ptr , 2 , 2 ), device = device )
2936
+ assert_np_equal (arr .numpy (), np .array (((1.0 , 2.0 , 0.0 ), (0.0 , 0.0 , 0.0 ))))
2937
+ wp .launch (kernel_array_from_ptr_variable_shape , dim = (1 ,), inputs = (arr .ptr , 2 , 3 ), device = device )
2938
+ assert_np_equal (arr .numpy (), np .array (((1.0 , 2.0 , 3.0 ), (0.0 , 0.0 , 0.0 ))))
2939
+
2940
+
2920
2941
def test_array_from_int32_domain (test , device ):
2921
2942
wp .zeros (np .array ([1504 , 1080 , 520 ], dtype = np .int32 ), dtype = wp .float32 , device = device )
2922
2943
@@ -3185,6 +3206,9 @@ def test_array_new_del(self):
3185
3206
add_function_test (TestArray , "test_array_inplace_non_diff_ops" , test_array_inplace_non_diff_ops , devices = devices )
3186
3207
add_function_test (TestArray , "test_direct_from_numpy" , test_direct_from_numpy , devices = ["cpu" ])
3187
3208
add_function_test (TestArray , "test_kernel_array_from_ptr" , test_kernel_array_from_ptr , devices = devices )
3209
+ add_function_test (
3210
+ TestArray , "test_kernel_array_from_ptr_variable_shape" , test_kernel_array_from_ptr_variable_shape , devices = devices
3211
+ )
3188
3212
3189
3213
add_function_test (TestArray , "test_array_from_int32_domain" , test_array_from_int32_domain , devices = devices )
3190
3214
add_function_test (TestArray , "test_array_from_int64_domain" , test_array_from_int64_domain , devices = devices )
0 commit comments