warp-lang 1.2.2__py3-none-macosx_10_13_universal2.whl → 1.3.1__py3-none-macosx_10_13_universal2.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.
Files changed (193) hide show
  1. warp/__init__.py +8 -6
  2. warp/autograd.py +823 -0
  3. warp/bin/libwarp.dylib +0 -0
  4. warp/build.py +6 -2
  5. warp/builtins.py +1412 -888
  6. warp/codegen.py +503 -166
  7. warp/config.py +48 -18
  8. warp/context.py +400 -198
  9. warp/dlpack.py +8 -0
  10. warp/examples/assets/bunny.usd +0 -0
  11. warp/examples/benchmarks/benchmark_cloth_warp.py +1 -1
  12. warp/examples/benchmarks/benchmark_interop_torch.py +158 -0
  13. warp/examples/benchmarks/benchmark_launches.py +1 -1
  14. warp/examples/core/example_cupy.py +78 -0
  15. warp/examples/fem/example_apic_fluid.py +17 -36
  16. warp/examples/fem/example_burgers.py +9 -18
  17. warp/examples/fem/example_convection_diffusion.py +7 -17
  18. warp/examples/fem/example_convection_diffusion_dg.py +27 -47
  19. warp/examples/fem/example_deformed_geometry.py +11 -22
  20. warp/examples/fem/example_diffusion.py +7 -18
  21. warp/examples/fem/example_diffusion_3d.py +24 -28
  22. warp/examples/fem/example_diffusion_mgpu.py +7 -14
  23. warp/examples/fem/example_magnetostatics.py +190 -0
  24. warp/examples/fem/example_mixed_elasticity.py +111 -80
  25. warp/examples/fem/example_navier_stokes.py +30 -34
  26. warp/examples/fem/example_nonconforming_contact.py +290 -0
  27. warp/examples/fem/example_stokes.py +17 -32
  28. warp/examples/fem/example_stokes_transfer.py +12 -21
  29. warp/examples/fem/example_streamlines.py +350 -0
  30. warp/examples/fem/utils.py +936 -0
  31. warp/fabric.py +5 -2
  32. warp/fem/__init__.py +13 -3
  33. warp/fem/cache.py +161 -11
  34. warp/fem/dirichlet.py +37 -28
  35. warp/fem/domain.py +105 -14
  36. warp/fem/field/__init__.py +14 -3
  37. warp/fem/field/field.py +454 -11
  38. warp/fem/field/nodal_field.py +33 -18
  39. warp/fem/geometry/deformed_geometry.py +50 -15
  40. warp/fem/geometry/hexmesh.py +12 -24
  41. warp/fem/geometry/nanogrid.py +106 -31
  42. warp/fem/geometry/quadmesh_2d.py +6 -11
  43. warp/fem/geometry/tetmesh.py +103 -61
  44. warp/fem/geometry/trimesh_2d.py +98 -47
  45. warp/fem/integrate.py +231 -186
  46. warp/fem/operator.py +14 -9
  47. warp/fem/quadrature/pic_quadrature.py +35 -9
  48. warp/fem/quadrature/quadrature.py +119 -32
  49. warp/fem/space/basis_space.py +98 -22
  50. warp/fem/space/collocated_function_space.py +3 -1
  51. warp/fem/space/function_space.py +7 -2
  52. warp/fem/space/grid_2d_function_space.py +3 -3
  53. warp/fem/space/grid_3d_function_space.py +4 -4
  54. warp/fem/space/hexmesh_function_space.py +3 -2
  55. warp/fem/space/nanogrid_function_space.py +12 -14
  56. warp/fem/space/partition.py +45 -47
  57. warp/fem/space/restriction.py +19 -16
  58. warp/fem/space/shape/cube_shape_function.py +91 -3
  59. warp/fem/space/shape/shape_function.py +7 -0
  60. warp/fem/space/shape/square_shape_function.py +32 -0
  61. warp/fem/space/shape/tet_shape_function.py +11 -7
  62. warp/fem/space/shape/triangle_shape_function.py +10 -1
  63. warp/fem/space/topology.py +116 -42
  64. warp/fem/types.py +8 -1
  65. warp/fem/utils.py +301 -83
  66. warp/native/array.h +16 -0
  67. warp/native/builtin.h +0 -15
  68. warp/native/cuda_util.cpp +14 -6
  69. warp/native/exports.h +1348 -1308
  70. warp/native/quat.h +79 -0
  71. warp/native/rand.h +27 -4
  72. warp/native/sparse.cpp +83 -81
  73. warp/native/sparse.cu +381 -453
  74. warp/native/vec.h +64 -0
  75. warp/native/volume.cpp +40 -49
  76. warp/native/volume_builder.cu +2 -3
  77. warp/native/volume_builder.h +12 -17
  78. warp/native/warp.cu +3 -3
  79. warp/native/warp.h +69 -59
  80. warp/render/render_opengl.py +17 -9
  81. warp/sim/articulation.py +117 -17
  82. warp/sim/collide.py +35 -29
  83. warp/sim/model.py +123 -18
  84. warp/sim/render.py +3 -1
  85. warp/sparse.py +867 -203
  86. warp/stubs.py +312 -541
  87. warp/tape.py +29 -1
  88. warp/tests/disabled_kinematics.py +1 -1
  89. warp/tests/test_adam.py +1 -1
  90. warp/tests/test_arithmetic.py +1 -1
  91. warp/tests/test_array.py +58 -1
  92. warp/tests/test_array_reduce.py +1 -1
  93. warp/tests/test_async.py +1 -1
  94. warp/tests/test_atomic.py +1 -1
  95. warp/tests/test_bool.py +1 -1
  96. warp/tests/test_builtins_resolution.py +1 -1
  97. warp/tests/test_bvh.py +6 -1
  98. warp/tests/test_closest_point_edge_edge.py +1 -1
  99. warp/tests/test_codegen.py +91 -1
  100. warp/tests/test_compile_consts.py +1 -1
  101. warp/tests/test_conditional.py +1 -1
  102. warp/tests/test_copy.py +1 -1
  103. warp/tests/test_ctypes.py +1 -1
  104. warp/tests/test_dense.py +1 -1
  105. warp/tests/test_devices.py +1 -1
  106. warp/tests/test_dlpack.py +1 -1
  107. warp/tests/test_examples.py +33 -4
  108. warp/tests/test_fabricarray.py +5 -2
  109. warp/tests/test_fast_math.py +1 -1
  110. warp/tests/test_fem.py +213 -6
  111. warp/tests/test_fp16.py +1 -1
  112. warp/tests/test_func.py +1 -1
  113. warp/tests/test_future_annotations.py +90 -0
  114. warp/tests/test_generics.py +1 -1
  115. warp/tests/test_grad.py +1 -1
  116. warp/tests/test_grad_customs.py +1 -1
  117. warp/tests/test_grad_debug.py +247 -0
  118. warp/tests/test_hash_grid.py +6 -1
  119. warp/tests/test_implicit_init.py +354 -0
  120. warp/tests/test_import.py +1 -1
  121. warp/tests/test_indexedarray.py +1 -1
  122. warp/tests/test_intersect.py +1 -1
  123. warp/tests/test_jax.py +1 -1
  124. warp/tests/test_large.py +1 -1
  125. warp/tests/test_launch.py +1 -1
  126. warp/tests/test_lerp.py +1 -1
  127. warp/tests/test_linear_solvers.py +1 -1
  128. warp/tests/test_lvalue.py +1 -1
  129. warp/tests/test_marching_cubes.py +5 -2
  130. warp/tests/test_mat.py +34 -35
  131. warp/tests/test_mat_lite.py +2 -1
  132. warp/tests/test_mat_scalar_ops.py +1 -1
  133. warp/tests/test_math.py +1 -1
  134. warp/tests/test_matmul.py +20 -16
  135. warp/tests/test_matmul_lite.py +1 -1
  136. warp/tests/test_mempool.py +1 -1
  137. warp/tests/test_mesh.py +5 -2
  138. warp/tests/test_mesh_query_aabb.py +1 -1
  139. warp/tests/test_mesh_query_point.py +1 -1
  140. warp/tests/test_mesh_query_ray.py +1 -1
  141. warp/tests/test_mlp.py +1 -1
  142. warp/tests/test_model.py +1 -1
  143. warp/tests/test_module_hashing.py +77 -1
  144. warp/tests/test_modules_lite.py +1 -1
  145. warp/tests/test_multigpu.py +1 -1
  146. warp/tests/test_noise.py +1 -1
  147. warp/tests/test_operators.py +1 -1
  148. warp/tests/test_options.py +1 -1
  149. warp/tests/test_overwrite.py +542 -0
  150. warp/tests/test_peer.py +1 -1
  151. warp/tests/test_pinned.py +1 -1
  152. warp/tests/test_print.py +1 -1
  153. warp/tests/test_quat.py +15 -1
  154. warp/tests/test_rand.py +1 -1
  155. warp/tests/test_reload.py +1 -1
  156. warp/tests/test_rounding.py +1 -1
  157. warp/tests/test_runlength_encode.py +1 -1
  158. warp/tests/test_scalar_ops.py +95 -0
  159. warp/tests/test_sim_grad.py +1 -1
  160. warp/tests/test_sim_kinematics.py +1 -1
  161. warp/tests/test_smoothstep.py +1 -1
  162. warp/tests/test_sparse.py +82 -15
  163. warp/tests/test_spatial.py +1 -1
  164. warp/tests/test_special_values.py +2 -11
  165. warp/tests/test_streams.py +11 -1
  166. warp/tests/test_struct.py +1 -1
  167. warp/tests/test_tape.py +1 -1
  168. warp/tests/test_torch.py +194 -1
  169. warp/tests/test_transient_module.py +1 -1
  170. warp/tests/test_types.py +1 -1
  171. warp/tests/test_utils.py +1 -1
  172. warp/tests/test_vec.py +15 -63
  173. warp/tests/test_vec_lite.py +2 -1
  174. warp/tests/test_vec_scalar_ops.py +65 -1
  175. warp/tests/test_verify_fp.py +1 -1
  176. warp/tests/test_volume.py +28 -2
  177. warp/tests/test_volume_write.py +1 -1
  178. warp/tests/unittest_serial.py +1 -1
  179. warp/tests/unittest_suites.py +9 -1
  180. warp/tests/walkthrough_debug.py +1 -1
  181. warp/thirdparty/unittest_parallel.py +2 -5
  182. warp/torch.py +103 -41
  183. warp/types.py +341 -224
  184. warp/utils.py +11 -2
  185. {warp_lang-1.2.2.dist-info → warp_lang-1.3.1.dist-info}/METADATA +99 -46
  186. warp_lang-1.3.1.dist-info/RECORD +368 -0
  187. warp/examples/fem/bsr_utils.py +0 -378
  188. warp/examples/fem/mesh_utils.py +0 -133
  189. warp/examples/fem/plot_utils.py +0 -292
  190. warp_lang-1.2.2.dist-info/RECORD +0 -359
  191. {warp_lang-1.2.2.dist-info → warp_lang-1.3.1.dist-info}/LICENSE.md +0 -0
  192. {warp_lang-1.2.2.dist-info → warp_lang-1.3.1.dist-info}/WHEEL +0 -0
  193. {warp_lang-1.2.2.dist-info → warp_lang-1.3.1.dist-info}/top_level.txt +0 -0
warp/tape.py CHANGED
@@ -165,7 +165,7 @@ class Tape:
165
165
 
166
166
  Args:
167
167
  backward (Callable): A callable Python object (can be any function) that will be executed in the backward pass.
168
- arrays (list): A list of arrays that are used by the function for gradient tracking.
168
+ arrays (list): A list of arrays that are used by the backward function. The tape keeps track of these to be able to zero their gradients in Tape.zero()
169
169
  """
170
170
  self.launches.append(backward)
171
171
 
@@ -197,6 +197,24 @@ class Tape:
197
197
  else:
198
198
  self.scopes.append((len(self.launches), None, None))
199
199
 
200
+ def _check_kernel_array_access(self, kernel, args):
201
+ """Detect illegal inter-kernel write after read access patterns during launch capture"""
202
+ adj = kernel.adj
203
+ kernel_name = adj.fun_name
204
+ filename = adj.filename
205
+ lineno = adj.fun_lineno
206
+
207
+ for i, arg in enumerate(args):
208
+ if isinstance(arg, wp.array):
209
+ arg_name = adj.args[i].label
210
+
211
+ # we check write condition first because we allow (write --> read) within the same kernel
212
+ if adj.args[i].is_write:
213
+ arg.mark_write(arg_name=arg_name, kernel_name=kernel_name, filename=filename, lineno=lineno)
214
+
215
+ if adj.args[i].is_read:
216
+ arg.mark_read()
217
+
200
218
  # returns the adjoint of a kernel parameter
201
219
  def get_adjoint(self, a):
202
220
  if not wp.types.is_array(a) and not isinstance(a, wp.codegen.StructInstance):
@@ -237,6 +255,8 @@ class Tape:
237
255
  self.launches = []
238
256
  self.scopes = []
239
257
  self.zero()
258
+ if wp.config.verify_autograd_array_access:
259
+ self._reset_array_read_flags()
240
260
 
241
261
  def zero(self):
242
262
  """
@@ -251,6 +271,14 @@ class Tape:
251
271
  else:
252
272
  g.zero_()
253
273
 
274
+ def _reset_array_read_flags(self):
275
+ """
276
+ Reset all recorded array read flags to False
277
+ """
278
+ for a in self.gradients:
279
+ if isinstance(a, wp.array):
280
+ a.mark_init()
281
+
254
282
  def visualize(
255
283
  self,
256
284
  filename: str = None,
@@ -233,5 +233,5 @@ add_function_test(
233
233
 
234
234
 
235
235
  if __name__ == "__main__":
236
- wp.build.clear_kernel_cache()
236
+ wp.clear_kernel_cache()
237
237
  unittest.main(verbosity=2, failfast=False)
warp/tests/test_adam.py CHANGED
@@ -151,5 +151,5 @@ add_function_test(TestAdam, "test_adam_solve_two_inputs", test_adam_solve_two_in
151
151
 
152
152
 
153
153
  if __name__ == "__main__":
154
- wp.build.clear_kernel_cache()
154
+ wp.clear_kernel_cache()
155
155
  unittest.main(verbosity=2)
@@ -1084,5 +1084,5 @@ for dtype in np_scalar_types:
1084
1084
 
1085
1085
 
1086
1086
  if __name__ == "__main__":
1087
- wp.build.clear_kernel_cache()
1087
+ wp.clear_kernel_cache()
1088
1088
  unittest.main(verbosity=2, failfast=False)
warp/tests/test_array.py CHANGED
@@ -2328,6 +2328,60 @@ def test_array_from_cai(test, device):
2328
2328
  assert_np_equal(arr_warp.numpy(), np.array([[2, 1, 1], [1, 0, 0], [1, 0, 0]]))
2329
2329
 
2330
2330
 
2331
+ @wp.kernel
2332
+ def inc_scalar(a: wp.array(dtype=float)):
2333
+ tid = wp.tid()
2334
+ a[tid] = a[tid] + 1.0
2335
+
2336
+
2337
+ @wp.kernel
2338
+ def inc_vector(a: wp.array(dtype=wp.vec3f)):
2339
+ tid = wp.tid()
2340
+ a[tid] = a[tid] + wp.vec3f(1.0)
2341
+
2342
+
2343
+ @wp.kernel
2344
+ def inc_matrix(a: wp.array(dtype=wp.mat22f)):
2345
+ tid = wp.tid()
2346
+ a[tid] = a[tid] + wp.mat22f(1.0)
2347
+
2348
+
2349
+ def test_direct_from_numpy(test, device):
2350
+ """Pass NumPy arrays to Warp kernels directly"""
2351
+
2352
+ n = 12
2353
+
2354
+ s = np.arange(n, dtype=np.float32)
2355
+ v = np.arange(n, dtype=np.float32).reshape((n // 3, 3))
2356
+ m = np.arange(n, dtype=np.float32).reshape((n // 4, 2, 2))
2357
+
2358
+ wp.launch(inc_scalar, dim=n, inputs=[s], device=device)
2359
+ wp.launch(inc_vector, dim=n // 3, inputs=[v], device=device)
2360
+ wp.launch(inc_matrix, dim=n // 4, inputs=[m], device=device)
2361
+
2362
+ expected = np.arange(1, n + 1, dtype=np.float32)
2363
+
2364
+ assert_np_equal(s, expected)
2365
+ assert_np_equal(v.reshape(n), expected)
2366
+ assert_np_equal(m.reshape(n), expected)
2367
+
2368
+
2369
+ @wp.kernel
2370
+ def kernel_array_from_ptr(
2371
+ ptr: wp.uint64,
2372
+ ):
2373
+ arr = wp.array(ptr=ptr, shape=(2, 3), dtype=wp.float32)
2374
+ arr[0, 0] = 1.0
2375
+ arr[0, 1] = 2.0
2376
+ arr[0, 2] = 3.0
2377
+
2378
+
2379
+ def test_kernel_array_from_ptr(test, device):
2380
+ arr = wp.zeros(shape=(2, 3), dtype=wp.float32, device=device)
2381
+ wp.launch(kernel_array_from_ptr, dim=(1,), inputs=(arr.ptr,), device=device)
2382
+ assert_np_equal(arr.numpy(), np.array(((1.0, 2.0, 3.0), (0.0, 0.0, 0.0))))
2383
+
2384
+
2331
2385
  devices = get_test_devices()
2332
2386
 
2333
2387
 
@@ -2386,6 +2440,9 @@ add_function_test(TestArray, "test_array_of_structs_from_numpy", test_array_of_s
2386
2440
  add_function_test(TestArray, "test_array_of_structs_roundtrip", test_array_of_structs_roundtrip, devices=devices)
2387
2441
  add_function_test(TestArray, "test_array_from_numpy", test_array_from_numpy, devices=devices)
2388
2442
 
2443
+ add_function_test(TestArray, "test_direct_from_numpy", test_direct_from_numpy, devices=["cpu"])
2444
+ add_function_test(TestArray, "test_kernel_array_from_ptr", test_kernel_array_from_ptr, devices=devices)
2445
+
2389
2446
  try:
2390
2447
  import torch
2391
2448
 
@@ -2411,5 +2468,5 @@ except Exception as e:
2411
2468
 
2412
2469
 
2413
2470
  if __name__ == "__main__":
2414
- wp.build.clear_kernel_cache()
2471
+ wp.clear_kernel_cache()
2415
2472
  unittest.main(verbosity=2)
@@ -144,5 +144,5 @@ add_function_test(TestArrayReduce, "test_array_inner_empty", test_array_inner_em
144
144
 
145
145
 
146
146
  if __name__ == "__main__":
147
- wp.build.clear_kernel_cache()
147
+ wp.clear_kernel_cache()
148
148
  unittest.main(verbosity=2)
warp/tests/test_async.py CHANGED
@@ -662,5 +662,5 @@ for src_type, src_ctor in array_constructors.items():
662
662
  # value_offset=0))
663
663
 
664
664
  if __name__ == "__main__":
665
- wp.build.clear_kernel_cache()
665
+ wp.clear_kernel_cache()
666
666
  unittest.main(verbosity=2)
warp/tests/test_atomic.py CHANGED
@@ -135,5 +135,5 @@ add_function_test(TestAtomic, "test_atomic_mat44", test_atomic_mat44, devices=de
135
135
 
136
136
 
137
137
  if __name__ == "__main__":
138
- wp.build.clear_kernel_cache()
138
+ wp.clear_kernel_cache()
139
139
  unittest.main(verbosity=2)
warp/tests/test_bool.py CHANGED
@@ -208,5 +208,5 @@ add_function_test(TestBool, "test_bool_mat_typing", test_bool_mat_typing, device
208
208
 
209
209
 
210
210
  if __name__ == "__main__":
211
- wp.build.clear_kernel_cache()
211
+ wp.clear_kernel_cache()
212
212
  unittest.main(verbosity=2)
@@ -1286,5 +1286,5 @@ for dtype in wp.types.float_types:
1286
1286
 
1287
1287
 
1288
1288
  if __name__ == "__main__":
1289
- wp.build.clear_kernel_cache()
1289
+ wp.clear_kernel_cache()
1290
1290
  unittest.main(verbosity=2)
warp/tests/test_bvh.py CHANGED
@@ -153,10 +153,15 @@ class TestBvh(unittest.TestCase):
153
153
 
154
154
  wp.Kernel(func=kernel_fn)
155
155
 
156
+ def test_bvh_new_del(self):
157
+ # test the scenario in which a bvh is created but not initialized before gc
158
+ instance = wp.Bvh.__new__(wp.Bvh)
159
+ instance.__del__()
160
+
156
161
 
157
162
  add_function_test(TestBvh, "test_bvh_aabb", test_bvh_query_aabb, devices=devices)
158
163
  add_function_test(TestBvh, "test_bvh_ray", test_bvh_query_ray, devices=devices)
159
164
 
160
165
  if __name__ == "__main__":
161
- wp.build.clear_kernel_cache()
166
+ wp.clear_kernel_cache()
162
167
  unittest.main(verbosity=2)
@@ -223,5 +223,5 @@ add_function_test(
223
223
 
224
224
 
225
225
  if __name__ == "__main__":
226
- wp.build.clear_kernel_cache()
226
+ wp.clear_kernel_cache()
227
227
  unittest.main(verbosity=2)
@@ -425,6 +425,88 @@ def test_error_global_var(test, device):
425
425
  wp.launch(kernel, dim=out.shape, inputs=(), outputs=(out,))
426
426
 
427
427
 
428
+ def test_error_collection_construct(test, device):
429
+ def kernel_1_fn():
430
+ x = [1.0, 2.0, 3.0]
431
+
432
+ def kernel_2_fn():
433
+ x = (1.0, 2.0, 3.0)
434
+
435
+ def kernel_3_fn():
436
+ x = {"a": 1.0, "b": 2.0, "c": 3.0}
437
+
438
+ def kernel_4_fn():
439
+ wp.length((1.0, 2.0, 3.0))
440
+
441
+ kernel = wp.Kernel(func=kernel_1_fn)
442
+ with test.assertRaisesRegex(
443
+ RuntimeError,
444
+ r"List constructs are not supported in kernels. Use vectors like `wp.vec3\(\)` for small collections instead.",
445
+ ):
446
+ wp.launch(kernel, dim=1)
447
+
448
+ kernel = wp.Kernel(func=kernel_2_fn)
449
+ with test.assertRaisesRegex(
450
+ RuntimeError,
451
+ r"Tuple constructs are not supported in kernels. Use vectors like `wp.vec3\(\)` for small collections instead.",
452
+ ):
453
+ wp.launch(kernel, dim=1)
454
+
455
+ kernel = wp.Kernel(func=kernel_3_fn)
456
+ with test.assertRaisesRegex(
457
+ RuntimeError,
458
+ r"Construct `ast.Dict` not supported in kernels.",
459
+ ):
460
+ wp.launch(kernel, dim=1)
461
+
462
+ kernel = wp.Kernel(func=kernel_4_fn)
463
+ with test.assertRaisesRegex(
464
+ RuntimeError,
465
+ r"Tuple constructs are not supported in kernels. Use vectors like `wp.vec3\(\)` instead.",
466
+ ):
467
+ wp.launch(kernel, dim=1)
468
+
469
+
470
+ def test_error_unmatched_arguments(test, device):
471
+ def kernel_1_fn():
472
+ a = 1 * 1.0
473
+
474
+ def kernel_2_fn():
475
+ x = wp.dot(wp.vec2(1.0, 2.0), wp.vec2h(wp.float16(1.0), wp.float16(2.0)))
476
+
477
+ kernel = wp.Kernel(func=kernel_1_fn)
478
+ with test.assertRaisesRegex(
479
+ RuntimeError,
480
+ r"Input types must be the same, got \['int32', 'float32'\]",
481
+ ):
482
+ wp.launch(kernel, dim=1)
483
+
484
+ kernel = wp.Kernel(func=kernel_2_fn)
485
+ with test.assertRaisesRegex(
486
+ RuntimeError,
487
+ r"Input types must be exactly the same, got \[\"vector\(length=2, dtype=<class 'warp.types.float32'>\)\", \"vector\(length=2, dtype=<class 'warp.types.float16'>\)\"\]",
488
+ ):
489
+ wp.launch(kernel, dim=1)
490
+
491
+
492
+ @wp.kernel
493
+ def test_call_syntax():
494
+ expected_pow = 16.0
495
+ wp.expect_eq(wp.pow(2.0, 4.0), expected_pow)
496
+ wp.expect_eq(wp.pow(x=2.0, y=4.0), expected_pow)
497
+ wp.expect_eq(wp.pow(2.0, y=4.0), expected_pow)
498
+ wp.expect_eq(wp.pow(y=4.0, x=2.0), expected_pow)
499
+
500
+ expected_matrix = wp.mat44(2.0, 0.0, 0.0, 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 0.0, 4.0, 3.0, 0.0, 0.0, 0.0, 1.0)
501
+ pos = wp.vec3(1.0, 2.0, 3.0)
502
+ rot = wp.quat(0.0, 0.0, 0.0, 1.0)
503
+ scale = wp.vec3(2.0, 3.0, 4.0)
504
+ wp.expect_eq(wp.matrix(pos, rot, scale, wp.float32), expected_matrix)
505
+ wp.expect_eq(wp.matrix(pos=pos, rot=rot, scale=scale, dtype=wp.float32), expected_matrix)
506
+ wp.expect_eq(wp.matrix(pos, rot, scale, dtype=wp.float32), expected_matrix)
507
+ wp.expect_eq(wp.matrix(rot=rot, pos=pos, dtype=wp.float32, scale=scale), expected_matrix)
508
+
509
+
428
510
  class TestCodeGen(unittest.TestCase):
429
511
  pass
430
512
 
@@ -555,8 +637,16 @@ add_kernel_test(TestCodeGen, name="test_continue_unroll", kernel=test_continue_u
555
637
  add_function_test(TestCodeGen, func=test_unresolved_func, name="test_unresolved_func", devices=devices)
556
638
  add_function_test(TestCodeGen, func=test_unresolved_symbol, name="test_unresolved_symbol", devices=devices)
557
639
  add_function_test(TestCodeGen, func=test_error_global_var, name="test_error_global_var", devices=devices)
640
+ add_function_test(
641
+ TestCodeGen, func=test_error_collection_construct, name="test_error_collection_construct", devices=devices
642
+ )
643
+ add_function_test(
644
+ TestCodeGen, func=test_error_unmatched_arguments, name="test_error_unmatched_arguments", devices=devices
645
+ )
646
+
647
+ add_kernel_test(TestCodeGen, name="test_call_syntax", kernel=test_call_syntax, dim=1, devices=devices)
558
648
 
559
649
 
560
650
  if __name__ == "__main__":
561
- wp.build.clear_kernel_cache()
651
+ wp.clear_kernel_cache()
562
652
  unittest.main(verbosity=2, failfast=True)
@@ -213,5 +213,5 @@ add_function_test(TestConstants, "test_hash_shadowed_var", test_hash_shadowed_va
213
213
 
214
214
 
215
215
  if __name__ == "__main__":
216
- wp.build.clear_kernel_cache()
216
+ wp.clear_kernel_cache()
217
217
  unittest.main(verbosity=2)
@@ -240,5 +240,5 @@ add_function_test(TestConditional, "test_conditional_unequal_types", test_condit
240
240
 
241
241
 
242
242
  if __name__ == "__main__":
243
- wp.build.clear_kernel_cache()
243
+ wp.clear_kernel_cache()
244
244
  unittest.main(verbosity=2)
warp/tests/test_copy.py CHANGED
@@ -226,5 +226,5 @@ add_function_test(TestCopy, "test_copy_adjoint", test_copy_adjoint, devices=devi
226
226
 
227
227
 
228
228
  if __name__ == "__main__":
229
- wp.build.clear_kernel_cache()
229
+ wp.clear_kernel_cache()
230
230
  unittest.main(verbosity=2)
warp/tests/test_ctypes.py CHANGED
@@ -626,5 +626,5 @@ add_function_test(TestCTypes, "test_vector_array", test_vector_array, devices=de
626
626
 
627
627
 
628
628
  if __name__ == "__main__":
629
- wp.build.clear_kernel_cache()
629
+ wp.clear_kernel_cache()
630
630
  unittest.main(verbosity=2)
warp/tests/test_dense.py CHANGED
@@ -61,5 +61,5 @@ add_function_test(TestDense, "test_dense_compilation", test_dense_compilation, d
61
61
 
62
62
 
63
63
  if __name__ == "__main__":
64
- wp.build.clear_kernel_cache()
64
+ wp.clear_kernel_cache()
65
65
  unittest.main(verbosity=2)
@@ -85,5 +85,5 @@ add_function_test(TestDevices, "test_devices_can_access_self", test_devices_can_
85
85
 
86
86
 
87
87
  if __name__ == "__main__":
88
- wp.build.clear_kernel_cache()
88
+ wp.clear_kernel_cache()
89
89
  unittest.main(verbosity=2)
warp/tests/test_dlpack.py CHANGED
@@ -524,5 +524,5 @@ except Exception as e:
524
524
 
525
525
 
526
526
  if __name__ == "__main__":
527
- wp.build.clear_kernel_cache()
527
+ wp.clear_kernel_cache()
528
528
  unittest.main(verbosity=2)
@@ -148,9 +148,12 @@ def add_example_test(
148
148
 
149
149
  command.extend(_build_command_line_options(options))
150
150
 
151
+ # Set the test timeout in seconds
152
+ test_timeout = options.pop("test_timeout", 300)
153
+
151
154
  # with wp.ScopedTimer(f"{name}_{sanitize_identifier(device)}"):
152
155
  # Run the script as a subprocess
153
- result = subprocess.run(command, capture_output=True, text=True, env=env_vars)
156
+ result = subprocess.run(command, capture_output=True, text=True, env=env_vars, timeout=test_timeout)
154
157
 
155
158
  # Check the return code (0 is standard for success)
156
159
  test.assertEqual(
@@ -223,6 +226,7 @@ add_example_test(
223
226
  name="core.example_torch",
224
227
  devices=test_devices,
225
228
  test_options={"headless": True, "num_frames": 1000, "torch_required": True},
229
+ test_options_cpu={"test_timeout": 600},
226
230
  )
227
231
  add_example_test(TestCoreExamples, name="core.example_wave", devices=test_devices)
228
232
 
@@ -232,7 +236,11 @@ class TestOptimExamples(unittest.TestCase):
232
236
 
233
237
 
234
238
  add_example_test(
235
- TestOptimExamples, name="optim.example_bounce", devices=test_devices, test_options_cpu={"train_iters": 3}
239
+ TestOptimExamples,
240
+ name="optim.example_bounce",
241
+ devices=test_devices,
242
+ test_options_cpu={"train_iters": 3},
243
+ test_options_cuda={"test_timeout": 600},
236
244
  )
237
245
  add_example_test(
238
246
  TestOptimExamples,
@@ -283,7 +291,9 @@ class TestSimExamples(unittest.TestCase):
283
291
  pass
284
292
 
285
293
 
286
- add_example_test(TestSimExamples, name="sim.example_cartpole", devices=test_devices)
294
+ add_example_test(
295
+ TestSimExamples, name="sim.example_cartpole", devices=test_devices, test_options_cuda={"test_timeout": 600}
296
+ )
287
297
  add_example_test(
288
298
  TestSimExamples,
289
299
  name="sim.example_cloth",
@@ -373,6 +383,7 @@ add_example_test(
373
383
  name="fem.example_convection_diffusion_dg",
374
384
  devices=test_devices,
375
385
  test_options={"resolution": 20, "num_frames": 25, "mesh": "quad", "headless": True},
386
+ test_options_cpu={"test_timeout": 600},
376
387
  )
377
388
  add_example_test(
378
389
  TestFemExamples,
@@ -395,9 +406,27 @@ add_example_test(
395
406
  devices=test_devices,
396
407
  test_options={"num_frames": 101, "resolution": 10, "tri_mesh": True, "headless": True},
397
408
  )
409
+ add_example_test(
410
+ TestFemExamples,
411
+ name="fem.example_streamlines",
412
+ devices=test_devices,
413
+ test_options={"headless": True},
414
+ )
415
+ add_example_test(
416
+ TestFemExamples,
417
+ name="fem.example_magnetostatics",
418
+ devices=test_devices,
419
+ test_options={"headless": True, "resolution": 16},
420
+ )
421
+ add_example_test(
422
+ TestFemExamples,
423
+ name="fem.example_nonconforming_contact",
424
+ devices=test_devices,
425
+ test_options={"headless": True, "resolution": 16, "num_steps": 2},
426
+ )
398
427
 
399
428
  if __name__ == "__main__":
400
429
  # force rebuild of all kernels
401
- wp.build.clear_kernel_cache()
430
+ wp.clear_kernel_cache()
402
431
 
403
432
  unittest.main(verbosity=2, failfast=True)
@@ -931,7 +931,10 @@ devices = get_test_devices()
931
931
 
932
932
 
933
933
  class TestFabricArray(unittest.TestCase):
934
- pass
934
+ def test_fabricarray_new_del(self):
935
+ # test the scenario in which a fabricarray is created but not initialized before gc
936
+ instance = wp.fabricarray.__new__(wp.fabricarray)
937
+ instance.__del__()
935
938
 
936
939
 
937
940
  # fabric arrays
@@ -948,5 +951,5 @@ add_function_test(TestFabricArray, "test_fabricarrayarray", test_fabricarrayarra
948
951
 
949
952
 
950
953
  if __name__ == "__main__":
951
- wp.build.clear_kernel_cache()
954
+ wp.clear_kernel_cache()
952
955
  unittest.main(verbosity=2)
@@ -56,5 +56,5 @@ add_function_test(TestFastMath, "test_fast_math_disabled", test_fast_math_disabl
56
56
 
57
57
 
58
58
  if __name__ == "__main__":
59
- wp.build.clear_kernel_cache()
59
+ wp.clear_kernel_cache()
60
60
  unittest.main(verbosity=2)