warp-lang 1.4.0__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
@@ -503,6 +503,76 @@ def test_error_mutating_constant_in_dynamic_loop(test, device):
503
503
  ):
504
504
  wp.launch(dynamic_loop_kernel, dim=1, inputs=[3, inputs], device=device)
505
505
 
506
+ # the following nested loop must not raise an error
507
+ const_a = 7
508
+ const_b = 5
509
+
510
+ @wp.kernel
511
+ def mixed_dyn_static_loop_kernel(dyn_a: int, dyn_b: int, dyn_c: int, output: wp.array(dtype=float, ndim=2)):
512
+ tid = wp.tid()
513
+ for i in range(const_a + 1):
514
+ for j in range(dyn_a + 1):
515
+ for k in range(dyn_b + 1):
516
+ for l in range(const_b + 1):
517
+ for m in range(dyn_c + 1):
518
+ coeff = i + j + k + l + m
519
+ output[tid, coeff] = 1.0
520
+
521
+ dyn_a, dyn_b, dyn_c = 3, 4, 5
522
+ num_threads = 10
523
+ output = wp.empty([num_threads, const_a + const_b + dyn_a + dyn_b + dyn_c + 1], dtype=float, device=device)
524
+ wp.launch(
525
+ mixed_dyn_static_loop_kernel,
526
+ num_threads,
527
+ inputs=[
528
+ dyn_a,
529
+ dyn_b,
530
+ dyn_c,
531
+ ],
532
+ outputs=[output],
533
+ device=device,
534
+ )
535
+ assert_np_equal(output.numpy(), np.ones([num_threads, const_a + const_b + dyn_a + dyn_b + dyn_c + 1]))
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
+
506
576
 
507
577
  @wp.kernel
508
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_fem.py CHANGED
@@ -28,6 +28,9 @@ from warp.fem.utils import (
28
28
  )
29
29
  from warp.tests.unittest_utils import *
30
30
 
31
+ vec6f = wp.vec(length=6, dtype=float)
32
+ mat66f = wp.mat(shape=(6, 6), dtype=float)
33
+
31
34
 
32
35
  @integrand
33
36
  def linear_form(s: Sample, u: Field):
@@ -1507,7 +1510,7 @@ def test_implicit_fields(test, device):
1507
1510
 
1508
1511
  @wp.kernel
1509
1512
  def test_qr_eigenvalues():
1510
- tol = 1.0e-6
1513
+ tol = 1.0e-8
1511
1514
 
1512
1515
  # zero
1513
1516
  Zero = wp.mat33(0.0)
@@ -1546,6 +1549,19 @@ def test_qr_eigenvalues():
1546
1549
  Err4 = wp.transpose(P4) * wp.diag(D4) * P4 - Rank4
1547
1550
  wp.expect_near(wp.ddot(Err4, Err4), 0.0, tol)
1548
1551
 
1552
+ # test robustness to low requested tolerance
1553
+ Rank6 = mat66f(
1554
+ vec6f(0.00171076, 0.0, 0.0, 0.0, 0.0, 0.0),
1555
+ vec6f(0.0, 0.00169935, 6.14367e-06, -3.52589e-05, 3.02397e-05, -1.53458e-11),
1556
+ vec6f(0.0, 6.14368e-06, 0.00172217, 2.03568e-05, 1.74589e-05, -2.92627e-05),
1557
+ vec6f(0.0, -3.52589e-05, 2.03568e-05, 0.00172178, 2.53422e-05, 3.02397e-05),
1558
+ vec6f(0.0, 3.02397e-05, 1.74589e-05, 2.53422e-05, 0.00171114, 3.52589e-05),
1559
+ vec6f(0.0, 6.42993e-12, -2.92627e-05, 3.02397e-05, 3.52589e-05, 0.00169935),
1560
+ )
1561
+ D6, P6 = symmetric_eigenvalues_qr(Rank6, 0.0)
1562
+ Err6 = wp.transpose(P6) * wp.diag(D6) * P6 - Rank6
1563
+ wp.expect_near(wp.ddot(Err6, Err6), 0.0, 1.0e-13)
1564
+
1549
1565
 
1550
1566
  @wp.kernel
1551
1567
  def test_qr_inverse():
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_model.py CHANGED
@@ -157,6 +157,19 @@ class TestModel(unittest.TestCase):
157
157
  assert builder.body_mass == [1.0, 4.0]
158
158
  assert builder.body_inv_mass == [1.0, 0.25]
159
159
 
160
+ # create another builder, test add_builder function
161
+ builder2 = ModelBuilder()
162
+ builder2.add_builder(builder)
163
+ assert builder2.articulation_count == builder.articulation_count
164
+ assert builder2.joint_count == builder.joint_count
165
+ assert builder2.body_count == builder.body_count
166
+ assert builder2.shape_count == builder.shape_count
167
+ assert builder2.articulation_start == builder.articulation_start
168
+ # add the same builder again
169
+ builder2.add_builder(builder)
170
+ assert builder2.articulation_count == 2 * builder.articulation_count
171
+ assert builder2.articulation_start == [0, 1, 2, 3]
172
+
160
173
 
161
174
  if __name__ == "__main__":
162
175
  wp.clear_kernel_cache()