warp-lang 1.4.1__py3-none-manylinux2014_aarch64.whl → 1.4.2__py3-none-manylinux2014_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of warp-lang might be problematic. Click here for more details.

warp/tests/test_array.py CHANGED
@@ -2361,64 +2361,75 @@ def test_array_from_cai(test, device):
2361
2361
  assert_np_equal(arr_warp.numpy(), np.array([[2, 1, 1], [1, 0, 0], [1, 0, 0]]))
2362
2362
 
2363
2363
 
2364
- def test_array_inplace_ops(test, device):
2365
- @wp.kernel
2366
- def inplace_add_1d(x: wp.array(dtype=float), y: wp.array(dtype=float)):
2367
- i = wp.tid()
2368
- x[i] += y[i]
2364
+ @wp.kernel
2365
+ def inplace_add_1d(x: wp.array(dtype=float), y: wp.array(dtype=float)):
2366
+ i = wp.tid()
2367
+ x[i] += y[i]
2369
2368
 
2370
- @wp.kernel
2371
- def inplace_add_2d(x: wp.array2d(dtype=float), y: wp.array2d(dtype=float)):
2372
- i, j = wp.tid()
2373
- x[i, j] += y[i, j]
2374
2369
 
2375
- @wp.kernel
2376
- def inplace_add_3d(x: wp.array3d(dtype=float), y: wp.array3d(dtype=float)):
2377
- i, j, k = wp.tid()
2378
- x[i, j, k] += y[i, j, k]
2370
+ @wp.kernel
2371
+ def inplace_add_2d(x: wp.array2d(dtype=float), y: wp.array2d(dtype=float)):
2372
+ i, j = wp.tid()
2373
+ x[i, j] += y[i, j]
2379
2374
 
2380
- @wp.kernel
2381
- def inplace_add_4d(x: wp.array4d(dtype=float), y: wp.array4d(dtype=float)):
2382
- i, j, k, l = wp.tid()
2383
- x[i, j, k, l] += y[i, j, k, l]
2384
2375
 
2385
- @wp.kernel
2386
- def inplace_sub_1d(x: wp.array(dtype=float), y: wp.array(dtype=float)):
2387
- i = wp.tid()
2388
- x[i] -= y[i]
2376
+ @wp.kernel
2377
+ def inplace_add_3d(x: wp.array3d(dtype=float), y: wp.array3d(dtype=float)):
2378
+ i, j, k = wp.tid()
2379
+ x[i, j, k] += y[i, j, k]
2389
2380
 
2390
- @wp.kernel
2391
- def inplace_sub_2d(x: wp.array2d(dtype=float), y: wp.array2d(dtype=float)):
2392
- i, j = wp.tid()
2393
- x[i, j] -= y[i, j]
2394
2381
 
2395
- @wp.kernel
2396
- def inplace_sub_3d(x: wp.array3d(dtype=float), y: wp.array3d(dtype=float)):
2397
- i, j, k = wp.tid()
2398
- x[i, j, k] -= y[i, j, k]
2382
+ @wp.kernel
2383
+ def inplace_add_4d(x: wp.array4d(dtype=float), y: wp.array4d(dtype=float)):
2384
+ i, j, k, l = wp.tid()
2385
+ x[i, j, k, l] += y[i, j, k, l]
2399
2386
 
2400
- @wp.kernel
2401
- def inplace_sub_4d(x: wp.array4d(dtype=float), y: wp.array4d(dtype=float)):
2402
- i, j, k, l = wp.tid()
2403
- x[i, j, k, l] -= y[i, j, k, l]
2404
2387
 
2405
- @wp.kernel
2406
- def inplace_add_vecs(x: wp.array(dtype=wp.vec3), y: wp.array(dtype=wp.vec3)):
2407
- i = wp.tid()
2408
- x[i] += y[i]
2388
+ @wp.kernel
2389
+ def inplace_sub_1d(x: wp.array(dtype=float), y: wp.array(dtype=float)):
2390
+ i = wp.tid()
2391
+ x[i] -= y[i]
2409
2392
 
2410
- @wp.kernel
2411
- def inplace_add_mats(x: wp.array(dtype=wp.mat33), y: wp.array(dtype=wp.mat33)):
2412
- i = wp.tid()
2413
- x[i] += y[i]
2414
2393
 
2415
- @wp.kernel
2416
- def inplace_add_rhs(x: wp.array(dtype=float), y: wp.array(dtype=float), z: wp.array(dtype=float)):
2417
- i = wp.tid()
2418
- a = y[i]
2419
- a += x[i]
2420
- wp.atomic_add(z, 0, a)
2394
+ @wp.kernel
2395
+ def inplace_sub_2d(x: wp.array2d(dtype=float), y: wp.array2d(dtype=float)):
2396
+ i, j = wp.tid()
2397
+ x[i, j] -= y[i, j]
2398
+
2399
+
2400
+ @wp.kernel
2401
+ def inplace_sub_3d(x: wp.array3d(dtype=float), y: wp.array3d(dtype=float)):
2402
+ i, j, k = wp.tid()
2403
+ x[i, j, k] -= y[i, j, k]
2404
+
2405
+
2406
+ @wp.kernel
2407
+ def inplace_sub_4d(x: wp.array4d(dtype=float), y: wp.array4d(dtype=float)):
2408
+ i, j, k, l = wp.tid()
2409
+ x[i, j, k, l] -= y[i, j, k, l]
2410
+
2421
2411
 
2412
+ @wp.kernel
2413
+ def inplace_add_vecs(x: wp.array(dtype=wp.vec3), y: wp.array(dtype=wp.vec3)):
2414
+ i = wp.tid()
2415
+ x[i] += y[i]
2416
+
2417
+
2418
+ @wp.kernel
2419
+ def inplace_add_mats(x: wp.array(dtype=wp.mat33), y: wp.array(dtype=wp.mat33)):
2420
+ i = wp.tid()
2421
+ x[i] += y[i]
2422
+
2423
+
2424
+ @wp.kernel
2425
+ def inplace_add_rhs(x: wp.array(dtype=float), y: wp.array(dtype=float), z: wp.array(dtype=float)):
2426
+ i = wp.tid()
2427
+ a = y[i]
2428
+ a += x[i]
2429
+ wp.atomic_add(z, 0, a)
2430
+
2431
+
2432
+ def test_array_inplace_diff_ops(test, device):
2422
2433
  N = 3
2423
2434
  x1 = wp.ones(N, dtype=float, requires_grad=True, device=device)
2424
2435
  x2 = wp.ones((N, N), dtype=float, requires_grad=True, device=device)
@@ -2528,6 +2539,32 @@ def test_array_inplace_ops(test, device):
2528
2539
  assert_np_equal(y.grad.numpy(), np.ones(1, dtype=float))
2529
2540
 
2530
2541
 
2542
+ @wp.kernel
2543
+ def inplace_mul_1d(x: wp.array(dtype=float), y: wp.array(dtype=float)):
2544
+ i = wp.tid()
2545
+ x[i] *= y[i]
2546
+
2547
+
2548
+ @wp.kernel
2549
+ def inplace_div_1d(x: wp.array(dtype=float), y: wp.array(dtype=float)):
2550
+ i = wp.tid()
2551
+ x[i] /= y[i]
2552
+
2553
+
2554
+ def test_array_inplace_non_diff_ops(test, device):
2555
+ N = 3
2556
+ x1 = wp.full(N, value=10.0, dtype=float, device=device)
2557
+ y1 = wp.full(N, value=5.0, dtype=float, device=device)
2558
+
2559
+ wp.launch(inplace_mul_1d, N, inputs=[x1, y1], device=device)
2560
+ assert_np_equal(x1.numpy(), np.full(N, fill_value=50.0, dtype=float))
2561
+
2562
+ x1.fill_(10.0)
2563
+ y1.fill_(5.0)
2564
+ wp.launch(inplace_div_1d, N, inputs=[x1, y1], device=device)
2565
+ assert_np_equal(x1.numpy(), np.full(N, fill_value=2.0, dtype=float))
2566
+
2567
+
2531
2568
  @wp.kernel
2532
2569
  def inc_scalar(a: wp.array(dtype=float)):
2533
2570
  tid = wp.tid()
@@ -2609,6 +2646,87 @@ def test_numpy_array_interface(test, device):
2609
2646
  assert a1.strides == a2.strides
2610
2647
 
2611
2648
 
2649
+ @wp.kernel
2650
+ def kernel_indexing_types(
2651
+ arr_1d: wp.array(dtype=wp.int32, ndim=1),
2652
+ arr_2d: wp.array(dtype=wp.int32, ndim=2),
2653
+ arr_3d: wp.array(dtype=wp.int32, ndim=3),
2654
+ arr_4d: wp.array(dtype=wp.int32, ndim=4),
2655
+ ):
2656
+ x = arr_1d[wp.uint8(0)]
2657
+ y = arr_1d[wp.int16(1)]
2658
+ z = arr_1d[wp.uint32(2)]
2659
+ w = arr_1d[wp.int64(3)]
2660
+
2661
+ x = arr_2d[wp.uint8(0), wp.uint8(0)]
2662
+ y = arr_2d[wp.int16(1), wp.int16(1)]
2663
+ z = arr_2d[wp.uint32(2), wp.uint32(2)]
2664
+ w = arr_2d[wp.int64(3), wp.int64(3)]
2665
+
2666
+ x = arr_3d[wp.uint8(0), wp.uint8(0), wp.uint8(0)]
2667
+ y = arr_3d[wp.int16(1), wp.int16(1), wp.int16(1)]
2668
+ z = arr_3d[wp.uint32(2), wp.uint32(2), wp.uint32(2)]
2669
+ w = arr_3d[wp.int64(3), wp.int64(3), wp.int64(3)]
2670
+
2671
+ x = arr_4d[wp.uint8(0), wp.uint8(0), wp.uint8(0), wp.uint8(0)]
2672
+ y = arr_4d[wp.int16(1), wp.int16(1), wp.int16(1), wp.int16(1)]
2673
+ z = arr_4d[wp.uint32(2), wp.uint32(2), wp.uint32(2), wp.uint32(2)]
2674
+ w = arr_4d[wp.int64(3), wp.int64(3), wp.int64(3), wp.int64(3)]
2675
+
2676
+ arr_1d[wp.uint8(0)] = 123
2677
+ arr_1d[wp.int16(1)] = 123
2678
+ arr_1d[wp.uint32(2)] = 123
2679
+ arr_1d[wp.int64(3)] = 123
2680
+
2681
+ arr_2d[wp.uint8(0), wp.uint8(0)] = 123
2682
+ arr_2d[wp.int16(1), wp.int16(1)] = 123
2683
+ arr_2d[wp.uint32(2), wp.uint32(2)] = 123
2684
+ arr_2d[wp.int64(3), wp.int64(3)] = 123
2685
+
2686
+ arr_3d[wp.uint8(0), wp.uint8(0), wp.uint8(0)] = 123
2687
+ arr_3d[wp.int16(1), wp.int16(1), wp.int16(1)] = 123
2688
+ arr_3d[wp.uint32(2), wp.uint32(2), wp.uint32(2)] = 123
2689
+ arr_3d[wp.int64(3), wp.int64(3), wp.int64(3)] = 123
2690
+
2691
+ arr_4d[wp.uint8(0), wp.uint8(0), wp.uint8(0), wp.uint8(0)] = 123
2692
+ arr_4d[wp.int16(1), wp.int16(1), wp.int16(1), wp.int16(1)] = 123
2693
+ arr_4d[wp.uint32(2), wp.uint32(2), wp.uint32(2), wp.uint32(2)] = 123
2694
+ arr_4d[wp.int64(3), wp.int64(3), wp.int64(3), wp.int64(3)] = 123
2695
+
2696
+ wp.atomic_add(arr_1d, wp.uint8(0), 123)
2697
+ wp.atomic_sub(arr_1d, wp.int16(1), 123)
2698
+ wp.atomic_min(arr_1d, wp.uint32(2), 123)
2699
+ wp.atomic_max(arr_1d, wp.int64(3), 123)
2700
+
2701
+ wp.atomic_add(arr_2d, wp.uint8(0), wp.uint8(0), 123)
2702
+ wp.atomic_sub(arr_2d, wp.int16(1), wp.int16(1), 123)
2703
+ wp.atomic_min(arr_2d, wp.uint32(2), wp.uint32(2), 123)
2704
+ wp.atomic_max(arr_2d, wp.int64(3), wp.int64(3), 123)
2705
+
2706
+ wp.atomic_add(arr_3d, wp.uint8(0), wp.uint8(0), wp.uint8(0), 123)
2707
+ wp.atomic_sub(arr_3d, wp.int16(1), wp.int16(1), wp.int16(1), 123)
2708
+ wp.atomic_min(arr_3d, wp.uint32(2), wp.uint32(2), wp.uint32(2), 123)
2709
+ wp.atomic_max(arr_3d, wp.int64(3), wp.int64(3), wp.int64(3), 123)
2710
+
2711
+ wp.atomic_add(arr_4d, wp.uint8(0), wp.uint8(0), wp.uint8(0), wp.uint8(0), 123)
2712
+ wp.atomic_sub(arr_4d, wp.int16(1), wp.int16(1), wp.int16(1), wp.int16(1), 123)
2713
+ wp.atomic_min(arr_4d, wp.uint32(2), wp.uint32(2), wp.uint32(2), wp.uint32(2), 123)
2714
+ wp.atomic_max(arr_4d, wp.int64(3), wp.int64(3), wp.int64(3), wp.int64(3), 123)
2715
+
2716
+
2717
+ def test_indexing_types(test, device):
2718
+ arr_1d = wp.zeros(shape=(4,), dtype=wp.int32, device=device)
2719
+ arr_2d = wp.zeros(shape=(4, 4), dtype=wp.int32, device=device)
2720
+ arr_3d = wp.zeros(shape=(4, 4, 4), dtype=wp.int32, device=device)
2721
+ arr_4d = wp.zeros(shape=(4, 4, 4, 4), dtype=wp.int32, device=device)
2722
+ wp.launch(
2723
+ kernel=kernel_indexing_types,
2724
+ dim=1,
2725
+ inputs=(arr_1d, arr_2d, arr_3d, arr_4d),
2726
+ device=device,
2727
+ )
2728
+
2729
+
2612
2730
  devices = get_test_devices()
2613
2731
 
2614
2732
 
@@ -2669,12 +2787,14 @@ add_function_test(TestArray, "test_array_from_numpy", test_array_from_numpy, dev
2669
2787
  add_function_test(TestArray, "test_array_aliasing_from_numpy", test_array_aliasing_from_numpy, devices=["cpu"])
2670
2788
  add_function_test(TestArray, "test_numpy_array_interface", test_numpy_array_interface, devices=["cpu"])
2671
2789
 
2672
- add_function_test(TestArray, "test_array_inplace_ops", test_array_inplace_ops, devices=devices)
2790
+ add_function_test(TestArray, "test_array_inplace_diff_ops", test_array_inplace_diff_ops, devices=devices)
2791
+ add_function_test(TestArray, "test_array_inplace_non_diff_ops", test_array_inplace_non_diff_ops, devices=devices)
2673
2792
  add_function_test(TestArray, "test_direct_from_numpy", test_direct_from_numpy, devices=["cpu"])
2674
2793
  add_function_test(TestArray, "test_kernel_array_from_ptr", test_kernel_array_from_ptr, devices=devices)
2675
2794
 
2676
2795
  add_function_test(TestArray, "test_array_from_int32_domain", test_array_from_int32_domain, devices=devices)
2677
2796
  add_function_test(TestArray, "test_array_from_int64_domain", test_array_from_int64_domain, devices=devices)
2797
+ add_function_test(TestArray, "test_indexing_types", test_indexing_types, devices=devices)
2678
2798
 
2679
2799
  try:
2680
2800
  import torch
@@ -220,12 +220,12 @@ def check_edge_closest_point_sufficient_necessary_kernel(
220
220
 
221
221
  def check_edge_closest_point_random(test, device):
222
222
  num_tests = 100000
223
- np.random.seed(12345)
224
- p1 = wp.array(np.random.randn(num_tests, 3), dtype=wp.vec3, device=device)
225
- q1 = wp.array(np.random.randn(num_tests, 3), dtype=wp.vec3, device=device)
223
+ rng = np.random.default_rng(123)
224
+ p1 = wp.array(rng.standard_normal(size=(num_tests, 3)), dtype=wp.vec3, device=device)
225
+ q1 = wp.array(rng.standard_normal(size=(num_tests, 3)), dtype=wp.vec3, device=device)
226
226
 
227
- p2 = wp.array(np.random.randn(num_tests, 3), dtype=wp.vec3, device=device)
228
- q2 = wp.array(np.random.randn(num_tests, 3), dtype=wp.vec3, device=device)
227
+ p2 = wp.array(rng.standard_normal(size=(num_tests, 3)), dtype=wp.vec3, device=device)
228
+ q2 = wp.array(rng.standard_normal(size=(num_tests, 3)), dtype=wp.vec3, device=device)
229
229
 
230
230
  wp.launch(
231
231
  kernel=check_edge_closest_point_sufficient_necessary_kernel,
@@ -235,10 +235,10 @@ def check_edge_closest_point_random(test, device):
235
235
  )
236
236
 
237
237
  # parallel edges
238
- p1 = np.random.randn(num_tests, 3)
239
- q1 = np.random.randn(num_tests, 3)
238
+ p1 = rng.standard_normal(size=(num_tests, 3))
239
+ q1 = rng.standard_normal(size=(num_tests, 3))
240
240
 
241
- shifts = np.random.randn(num_tests, 3)
241
+ shifts = rng.standard_normal(size=(num_tests, 3))
242
242
 
243
243
  p2 = p1 + shifts
244
244
  q2 = q1 + shifts
@@ -534,6 +534,45 @@ def test_error_mutating_constant_in_dynamic_loop(test, device):
534
534
  )
535
535
  assert_np_equal(output.numpy(), np.ones([num_threads, const_a + const_b + dyn_a + dyn_b + dyn_c + 1]))
536
536
 
537
+ @wp.kernel
538
+ def static_then_dynamic_loop_kernel(mats: wp.array(dtype=wp.mat33d)):
539
+ tid = wp.tid()
540
+ mat = wp.mat33d()
541
+ for i in range(3):
542
+ for j in range(3):
543
+ mat[i, j] = wp.float64(0.0)
544
+
545
+ dim = 2
546
+ for i in range(dim + 1):
547
+ for j in range(dim + 1):
548
+ mat[i, j] = wp.float64(1.0)
549
+
550
+ mats[tid] = mat
551
+
552
+ mats = wp.empty(1, dtype=wp.mat33d, device=device)
553
+ wp.launch(static_then_dynamic_loop_kernel, dim=1, inputs=[mats], device=device)
554
+ assert_np_equal(mats.numpy(), np.ones((1, 3, 3)))
555
+
556
+ @wp.kernel
557
+ def dynamic_then_static_loop_kernel(mats: wp.array(dtype=wp.mat33d)):
558
+ tid = wp.tid()
559
+ mat = wp.mat33d()
560
+
561
+ dim = 2
562
+ for i in range(dim + 1):
563
+ for j in range(dim + 1):
564
+ mat[i, j] = wp.float64(1.0)
565
+
566
+ for i in range(3):
567
+ for j in range(3):
568
+ mat[i, j] = wp.float64(0.0)
569
+
570
+ mats[tid] = mat
571
+
572
+ mats = wp.empty(1, dtype=wp.mat33d, device=device)
573
+ wp.launch(dynamic_then_static_loop_kernel, dim=1, inputs=[mats], device=device)
574
+ assert_np_equal(mats.numpy(), np.zeros((1, 3, 3)))
575
+
537
576
 
538
577
  @wp.kernel
539
578
  def test_call_syntax():
@@ -821,6 +821,38 @@ def test_fabricarray_fill_matrix(test, device):
821
821
  assert_np_equal(ifb.numpy(), np.zeros((*ifb.shape, *mat_shape), dtype=nptype))
822
822
 
823
823
 
824
+ @wp.kernel
825
+ def fa_kernel_indexing_types(
826
+ a: wp.fabricarray(dtype=wp.int32),
827
+ ):
828
+ x = a[wp.uint8(0)]
829
+ y = a[wp.int16(1)]
830
+ z = a[wp.uint32(2)]
831
+ w = a[wp.int64(3)]
832
+
833
+ a[wp.uint8(0)] = 123
834
+ a[wp.int16(1)] = 123
835
+ a[wp.uint32(2)] = 123
836
+ a[wp.int64(3)] = 123
837
+
838
+ wp.atomic_add(a, wp.uint8(0), 123)
839
+ wp.atomic_sub(a, wp.int16(1), 123)
840
+ # wp.atomic_min(a, wp.uint32(2), 123)
841
+ # wp.atomic_max(a, wp.int64(3), 123)
842
+
843
+
844
+ def test_fabricarray_indexing_types(test, device):
845
+ data = wp.zeros(shape=(4,), dtype=wp.int32, device=device)
846
+ iface = _create_fabric_array_interface(data, "foo", copy=True)
847
+ fa = wp.fabricarray(data=iface, attrib="foo")
848
+ wp.launch(
849
+ kernel=fa_kernel_indexing_types,
850
+ dim=1,
851
+ inputs=(fa,),
852
+ device=device,
853
+ )
854
+
855
+
824
856
  @wp.kernel
825
857
  def fa_generic_sums_kernel(a: wp.fabricarrayarray(dtype=Any), sums: wp.array(dtype=Any)):
826
858
  i = wp.tid()
@@ -945,6 +977,7 @@ add_function_test(TestFabricArray, "test_fabricarray_generic_array", test_fabric
945
977
  add_function_test(TestFabricArray, "test_fabricarray_fill_scalar", test_fabricarray_fill_scalar, devices=devices)
946
978
  add_function_test(TestFabricArray, "test_fabricarray_fill_vector", test_fabricarray_fill_vector, devices=devices)
947
979
  add_function_test(TestFabricArray, "test_fabricarray_fill_matrix", test_fabricarray_fill_matrix, devices=devices)
980
+ add_function_test(TestFabricArray, "test_fabricarray_indexing_types", test_fabricarray_indexing_types, devices=devices)
948
981
 
949
982
  # fabric arrays of arrays
950
983
  add_function_test(TestFabricArray, "test_fabricarrayarray", test_fabricarrayarray, devices=devices)
warp/tests/test_func.py CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import math
9
9
  import unittest
10
- from typing import Tuple
10
+ from typing import Any, Tuple
11
11
 
12
12
  import numpy as np
13
13
 
@@ -191,6 +191,37 @@ def test_user_func_return_multiple_values():
191
191
  wp.expect_eq(b, 54756.0)
192
192
 
193
193
 
194
+ @wp.func
195
+ def user_func_overload(
196
+ b: wp.array(dtype=Any),
197
+ i: int,
198
+ ):
199
+ return b[i] * 2.0
200
+
201
+
202
+ @wp.kernel
203
+ def user_func_overload_resolution_kernel(
204
+ a: wp.array(dtype=Any),
205
+ b: wp.array(dtype=Any),
206
+ ):
207
+ i = wp.tid()
208
+ a[i] = user_func_overload(b, i)
209
+
210
+
211
+ def test_user_func_overload_resolution(test, device):
212
+ a0 = wp.array((1, 2, 3), dtype=wp.vec3)
213
+ b0 = wp.array((2, 3, 4), dtype=wp.vec3)
214
+
215
+ a1 = wp.array((5,), dtype=float)
216
+ b1 = wp.array((6,), dtype=float)
217
+
218
+ wp.launch(user_func_overload_resolution_kernel, a0.shape, (a0, b0))
219
+ wp.launch(user_func_overload_resolution_kernel, a1.shape, (a1, b1))
220
+
221
+ assert_np_equal(a0.numpy()[0], (4, 6, 8))
222
+ assert a1.numpy()[0] == 12
223
+
224
+
194
225
  devices = get_test_devices()
195
226
 
196
227
 
@@ -375,6 +406,9 @@ add_kernel_test(
375
406
  dim=1,
376
407
  devices=devices,
377
408
  )
409
+ add_function_test(
410
+ TestFunc, func=test_user_func_overload_resolution, name="test_user_func_overload_resolution", devices=devices
411
+ )
378
412
 
379
413
 
380
414
  if __name__ == "__main__":
@@ -769,20 +769,21 @@ def point_query_aabb_and_closest(
769
769
 
770
770
  @unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
771
771
  def test_set_mesh_points(test, device):
772
+ rng = np.random.default_rng(123)
773
+
772
774
  vs, fs = load_mesh()
773
775
 
774
776
  vertices1 = wp.array(vs, dtype=wp.vec3, device=device)
775
- velocities1_np = np.random.randn(vertices1.shape[0], 3)
777
+ velocities1_np = rng.standard_normal(size=(vertices1.shape[0], 3))
776
778
  velocities1 = wp.array(velocities1_np, dtype=wp.vec3, device=device)
777
779
 
778
780
  faces = wp.array(fs, dtype=wp.int32, device=device)
779
781
  mesh = wp.Mesh(vertices1, faces, velocities=velocities1)
780
782
  fs_2D = faces.reshape((-1, 3))
781
- np.random.seed(12345)
782
783
  n = 1000
783
784
  query_radius = 0.2
784
785
 
785
- pts1 = wp.array(np.random.randn(n, 3), dtype=wp.vec3, device=device)
786
+ pts1 = wp.array(rng.standard_normal(size=(n, 3)), dtype=wp.vec3, device=device)
786
787
 
787
788
  query_results_num_cols1 = wp.zeros(n, dtype=wp.int32, device=device)
788
789
  query_results_min_dist1 = wp.zeros(n, dtype=float, device=device)
warp/tests/test_print.py CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  import sys
9
9
  import unittest
10
+ from typing import Any
10
11
 
11
12
  import warp as wp
12
13
  from warp.tests.unittest_utils import *
@@ -126,6 +127,139 @@ def test_print_boolean(test, device):
126
127
  test.assertRegex(s, rf"True{os.linesep}False{os.linesep}")
127
128
 
128
129
 
130
+ @wp.kernel
131
+ def generic_print_kernel(x: Any):
132
+ print(x)
133
+
134
+
135
+ @wp.struct
136
+ class SimpleStruct:
137
+ x: float
138
+ y: float
139
+
140
+
141
+ generic_print_types = [*wp.types.scalar_types]
142
+ for scalar_type in wp.types.scalar_types:
143
+ generic_print_types.append(wp.types.vector(2, scalar_type))
144
+ generic_print_types.append(wp.types.vector(3, scalar_type))
145
+ generic_print_types.append(wp.types.vector(4, scalar_type))
146
+ generic_print_types.append(wp.types.matrix((2, 2), scalar_type))
147
+ generic_print_types.append(wp.types.matrix((3, 3), scalar_type))
148
+ generic_print_types.append(wp.types.matrix((4, 4), scalar_type))
149
+ generic_print_types.append(wp.bool)
150
+ generic_print_types.append(SimpleStruct)
151
+ generic_print_types.append(wp.array(dtype=float))
152
+
153
+ for T in generic_print_types:
154
+ wp.overload(generic_print_kernel, [T])
155
+
156
+
157
+ def test_print_adjoint(test, device):
158
+ for scalar_type in wp.types.scalar_types:
159
+ # scalar
160
+ capture = StdOutCapture()
161
+ capture.begin()
162
+ wp.launch(
163
+ generic_print_kernel,
164
+ dim=1,
165
+ inputs=[scalar_type(17)],
166
+ adj_inputs=[scalar_type(42)],
167
+ adjoint=True,
168
+ device=device,
169
+ )
170
+ wp.synchronize_device(device)
171
+ s = capture.end()
172
+
173
+ # We skip the win32 comparison for now since the capture sometimes is an empty string
174
+ if sys.platform != "win32":
175
+ test.assertRegex(s, rf"17{os.linesep}adj: 42{os.linesep}")
176
+
177
+ for dim in (2, 3, 4):
178
+ # vector
179
+ vec_type = wp.types.vector(dim, scalar_type)
180
+ vec_data = np.arange(vec_type._length_, dtype=wp.dtype_to_numpy(scalar_type))
181
+ v = vec_type(vec_data)
182
+ adj_v = vec_type(vec_data[::-1])
183
+
184
+ capture = StdOutCapture()
185
+ capture.begin()
186
+ wp.launch(generic_print_kernel, dim=1, inputs=[v], adj_inputs=[adj_v], adjoint=True, device=device)
187
+ wp.synchronize_device(device)
188
+ s = capture.end()
189
+
190
+ # We skip the win32 comparison for now since the capture sometimes is an empty string
191
+ if sys.platform != "win32":
192
+ expected_forward = " ".join(str(int(x)) for x in v) + " "
193
+ expected_adjoint = " ".join(str(int(x)) for x in adj_v)
194
+ test.assertRegex(s, rf"{expected_forward}{os.linesep}adj: {expected_adjoint}{os.linesep}")
195
+
196
+ # matrix
197
+ mat_type = wp.types.matrix((dim, dim), scalar_type)
198
+ mat_data = np.arange(mat_type._length_, dtype=wp.dtype_to_numpy(scalar_type))
199
+ m = mat_type(mat_data)
200
+ adj_m = mat_type(mat_data[::-1])
201
+
202
+ capture = StdOutCapture()
203
+ capture.begin()
204
+ wp.launch(generic_print_kernel, dim=1, inputs=[m], adj_inputs=[adj_m], adjoint=True, device=device)
205
+ wp.synchronize_device(device)
206
+ s = capture.end()
207
+
208
+ # We skip the win32 comparison for now since the capture sometimes is an empty string
209
+ if sys.platform != "win32":
210
+ expected_forward = ""
211
+ expected_adjoint = ""
212
+ for row in range(dim):
213
+ if row == 0:
214
+ adj_prefix = "adj: "
215
+ else:
216
+ adj_prefix = " "
217
+ expected_forward += " ".join(str(int(x)) for x in m[row]) + f" {os.linesep}"
218
+ expected_adjoint += adj_prefix + " ".join(str(int(x)) for x in adj_m[row]) + f"{os.linesep}"
219
+ test.assertRegex(s, rf"{expected_forward}{expected_adjoint}")
220
+
221
+ # Booleans
222
+ capture = StdOutCapture()
223
+ capture.begin()
224
+ wp.launch(generic_print_kernel, dim=1, inputs=[True], adj_inputs=[False], adjoint=True, device=device)
225
+ wp.synchronize_device(device)
226
+ s = capture.end()
227
+
228
+ # We skip the win32 comparison for now since the capture sometimes is an empty string
229
+ if sys.platform != "win32":
230
+ test.assertRegex(s, rf"True{os.linesep}adj: False{os.linesep}")
231
+
232
+ # structs, not printable yet
233
+ capture = StdOutCapture()
234
+ capture.begin()
235
+ wp.launch(
236
+ generic_print_kernel, dim=1, inputs=[SimpleStruct()], adj_inputs=[SimpleStruct()], adjoint=True, device=device
237
+ )
238
+ wp.synchronize_device(device)
239
+ s = capture.end()
240
+
241
+ # We skip the win32 comparison for now since the capture sometimes is an empty string
242
+ if sys.platform != "win32":
243
+ test.assertRegex(
244
+ s, rf"<type without print implementation>{os.linesep}adj: <type without print implementation>{os.linesep}"
245
+ )
246
+
247
+ # arrays, not printable
248
+ capture = StdOutCapture()
249
+ capture.begin()
250
+ a = wp.ones(10, dtype=float, device=device)
251
+ adj_a = wp.zeros(10, dtype=float, device=device)
252
+ wp.launch(generic_print_kernel, dim=1, inputs=[a], adj_inputs=[adj_a], adjoint=True, device=device)
253
+ wp.synchronize_device(device)
254
+ s = capture.end()
255
+
256
+ # We skip the win32 comparison for now since the capture sometimes is an empty string
257
+ if sys.platform != "win32":
258
+ test.assertRegex(
259
+ s, rf"<type without print implementation>{os.linesep}adj: <type without print implementation>{os.linesep}"
260
+ )
261
+
262
+
129
263
  class TestPrint(unittest.TestCase):
130
264
  pass
131
265
 
@@ -134,6 +268,7 @@ devices = get_test_devices()
134
268
  add_function_test(TestPrint, "test_print", test_print, devices=devices, check_output=False)
135
269
  add_function_test(TestPrint, "test_print_numeric", test_print_numeric, devices=devices, check_output=False)
136
270
  add_function_test(TestPrint, "test_print_boolean", test_print_boolean, devices=devices, check_output=False)
271
+ add_function_test(TestPrint, "test_print_adjoint", test_print_adjoint, devices=devices, check_output=False)
137
272
 
138
273
 
139
274
  if __name__ == "__main__":
@@ -170,6 +170,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
170
170
  from warp.tests.test_sparse import TestSparse
171
171
  from warp.tests.test_spatial import TestSpatial
172
172
  from warp.tests.test_special_values import TestSpecialValues
173
+ from warp.tests.test_static import TestStatic
173
174
  from warp.tests.test_streams import TestStreams
174
175
  from warp.tests.test_struct import TestStruct
175
176
  from warp.tests.test_tape import TestTape
@@ -269,6 +270,7 @@ def default_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader)
269
270
  TestSparse,
270
271
  TestSpatial,
271
272
  TestSpecialValues,
273
+ TestStatic,
272
274
  TestStreams,
273
275
  TestStruct,
274
276
  TestTape,
@@ -329,6 +331,7 @@ def kit_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader):
329
331
  from warp.tests.test_rounding import TestRounding
330
332
  from warp.tests.test_runlength_encode import TestRunlengthEncode
331
333
  from warp.tests.test_sparse import TestSparse
334
+ from warp.tests.test_static import TestStatic
332
335
  from warp.tests.test_streams import TestStreams
333
336
  from warp.tests.test_tape import TestTape
334
337
  from warp.tests.test_transient_module import TestTransientModule
@@ -374,6 +377,7 @@ def kit_suite(test_loader: unittest.TestLoader = unittest.defaultTestLoader):
374
377
  TestRounding,
375
378
  TestRunlengthEncode,
376
379
  TestSparse,
380
+ TestStatic,
377
381
  TestStreams,
378
382
  TestTape,
379
383
  TestTransientModule,
warp/types.py CHANGED
@@ -1488,7 +1488,7 @@ def types_equal(a, b, match_generic=False):
1488
1488
 
1489
1489
  return True
1490
1490
 
1491
- if is_array(a) and type(a) is type(b):
1491
+ if is_array(a) and type(a) is type(b) and types_equal(a.dtype, b.dtype, match_generic=match_generic):
1492
1492
  return True
1493
1493
 
1494
1494
  # match NewStructInstance and Struct dtype
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: warp-lang
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: A Python framework for high-performance simulation and graphics programming
5
5
  Author-email: NVIDIA Corporation <mmacklin@nvidia.com>
6
6
  License: NVIDIA Software License
@@ -77,9 +77,9 @@ the `pip install` command, e.g.
77
77
 
78
78
  | Platform | Install Command |
79
79
  | --------------- | ----------------------------------------------------------------------------------------------------------------------------- |
80
- | Linux aarch64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.4.1/warp_lang-1.4.1+cu11-py3-none-manylinux2014_aarch64.whl` |
81
- | Linux x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.4.1/warp_lang-1.4.1+cu11-py3-none-manylinux2014_x86_64.whl` |
82
- | Windows x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.4.1/warp_lang-1.4.1+cu11-py3-none-win_amd64.whl` |
80
+ | Linux aarch64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.4.2/warp_lang-1.4.2+cu11-py3-none-manylinux2014_aarch64.whl` |
81
+ | Linux x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.4.2/warp_lang-1.4.2+cu11-py3-none-manylinux2014_x86_64.whl` |
82
+ | Windows x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.4.2/warp_lang-1.4.2+cu11-py3-none-win_amd64.whl` |
83
83
 
84
84
  The `--force-reinstall` option may need to be used to overwrite a previous installation.
85
85