warp-lang 1.5.0__py3-none-win_amd64.whl → 1.6.0__py3-none-win_amd64.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.

Files changed (132) hide show
  1. warp/__init__.py +5 -0
  2. warp/autograd.py +414 -191
  3. warp/bin/warp-clang.dll +0 -0
  4. warp/bin/warp.dll +0 -0
  5. warp/build.py +40 -12
  6. warp/build_dll.py +13 -6
  7. warp/builtins.py +1124 -497
  8. warp/codegen.py +261 -136
  9. warp/config.py +1 -1
  10. warp/context.py +357 -119
  11. warp/examples/assets/square_cloth.usd +0 -0
  12. warp/examples/benchmarks/benchmark_gemm.py +27 -18
  13. warp/examples/benchmarks/benchmark_interop_paddle.py +3 -3
  14. warp/examples/benchmarks/benchmark_interop_torch.py +3 -3
  15. warp/examples/core/example_torch.py +18 -34
  16. warp/examples/fem/example_apic_fluid.py +1 -0
  17. warp/examples/fem/example_mixed_elasticity.py +1 -1
  18. warp/examples/optim/example_bounce.py +1 -1
  19. warp/examples/optim/example_cloth_throw.py +1 -1
  20. warp/examples/optim/example_diffray.py +4 -15
  21. warp/examples/optim/example_drone.py +1 -1
  22. warp/examples/optim/example_softbody_properties.py +392 -0
  23. warp/examples/optim/example_trajectory.py +1 -3
  24. warp/examples/optim/example_walker.py +5 -0
  25. warp/examples/sim/example_cartpole.py +0 -2
  26. warp/examples/sim/example_cloth.py +3 -1
  27. warp/examples/sim/example_cloth_self_contact.py +260 -0
  28. warp/examples/sim/example_granular_collision_sdf.py +4 -5
  29. warp/examples/sim/example_jacobian_ik.py +0 -2
  30. warp/examples/sim/example_quadruped.py +5 -2
  31. warp/examples/tile/example_tile_cholesky.py +79 -0
  32. warp/examples/tile/example_tile_convolution.py +2 -2
  33. warp/examples/tile/example_tile_fft.py +2 -2
  34. warp/examples/tile/example_tile_filtering.py +3 -3
  35. warp/examples/tile/example_tile_matmul.py +4 -4
  36. warp/examples/tile/example_tile_mlp.py +12 -12
  37. warp/examples/tile/example_tile_nbody.py +180 -0
  38. warp/examples/tile/example_tile_walker.py +319 -0
  39. warp/fem/geometry/geometry.py +0 -2
  40. warp/math.py +147 -0
  41. warp/native/array.h +12 -0
  42. warp/native/builtin.h +0 -1
  43. warp/native/bvh.cpp +149 -70
  44. warp/native/bvh.cu +287 -68
  45. warp/native/bvh.h +195 -85
  46. warp/native/clang/clang.cpp +5 -1
  47. warp/native/coloring.cpp +5 -1
  48. warp/native/cuda_util.cpp +91 -53
  49. warp/native/cuda_util.h +5 -0
  50. warp/native/exports.h +40 -40
  51. warp/native/intersect.h +17 -0
  52. warp/native/mat.h +41 -0
  53. warp/native/mathdx.cpp +19 -0
  54. warp/native/mesh.cpp +25 -8
  55. warp/native/mesh.cu +153 -101
  56. warp/native/mesh.h +482 -403
  57. warp/native/quat.h +40 -0
  58. warp/native/solid_angle.h +7 -0
  59. warp/native/sort.cpp +85 -0
  60. warp/native/sort.cu +34 -0
  61. warp/native/sort.h +3 -1
  62. warp/native/spatial.h +11 -0
  63. warp/native/tile.h +1187 -669
  64. warp/native/tile_reduce.h +8 -6
  65. warp/native/vec.h +41 -0
  66. warp/native/warp.cpp +8 -1
  67. warp/native/warp.cu +263 -40
  68. warp/native/warp.h +19 -5
  69. warp/optim/linear.py +22 -4
  70. warp/render/render_opengl.py +130 -64
  71. warp/sim/__init__.py +6 -1
  72. warp/sim/collide.py +270 -26
  73. warp/sim/import_urdf.py +8 -8
  74. warp/sim/integrator_euler.py +25 -7
  75. warp/sim/integrator_featherstone.py +154 -35
  76. warp/sim/integrator_vbd.py +842 -40
  77. warp/sim/model.py +134 -72
  78. warp/sparse.py +1 -1
  79. warp/stubs.py +265 -132
  80. warp/tape.py +28 -30
  81. warp/tests/aux_test_module_unload.py +15 -0
  82. warp/tests/{test_sim_grad.py → flaky_test_sim_grad.py} +104 -63
  83. warp/tests/test_array.py +74 -0
  84. warp/tests/test_assert.py +242 -0
  85. warp/tests/test_codegen.py +14 -61
  86. warp/tests/test_collision.py +2 -2
  87. warp/tests/test_coloring.py +12 -2
  88. warp/tests/test_examples.py +12 -1
  89. warp/tests/test_func.py +21 -4
  90. warp/tests/test_grad_debug.py +87 -2
  91. warp/tests/test_hash_grid.py +1 -1
  92. warp/tests/test_ipc.py +116 -0
  93. warp/tests/test_lerp.py +13 -87
  94. warp/tests/test_mat.py +138 -167
  95. warp/tests/test_math.py +47 -1
  96. warp/tests/test_matmul.py +17 -16
  97. warp/tests/test_matmul_lite.py +10 -15
  98. warp/tests/test_mesh.py +84 -60
  99. warp/tests/test_mesh_query_aabb.py +165 -0
  100. warp/tests/test_mesh_query_point.py +328 -286
  101. warp/tests/test_mesh_query_ray.py +134 -121
  102. warp/tests/test_mlp.py +2 -2
  103. warp/tests/test_operators.py +43 -0
  104. warp/tests/test_overwrite.py +47 -2
  105. warp/tests/test_quat.py +77 -0
  106. warp/tests/test_reload.py +29 -0
  107. warp/tests/test_sim_grad_bounce_linear.py +204 -0
  108. warp/tests/test_smoothstep.py +17 -83
  109. warp/tests/test_static.py +19 -3
  110. warp/tests/test_tape.py +25 -0
  111. warp/tests/test_tile.py +178 -191
  112. warp/tests/test_tile_load.py +356 -0
  113. warp/tests/test_tile_mathdx.py +61 -8
  114. warp/tests/test_tile_mlp.py +17 -17
  115. warp/tests/test_tile_reduce.py +24 -18
  116. warp/tests/test_tile_shared_memory.py +66 -17
  117. warp/tests/test_tile_view.py +165 -0
  118. warp/tests/test_torch.py +35 -0
  119. warp/tests/test_utils.py +36 -24
  120. warp/tests/test_vec.py +110 -0
  121. warp/tests/unittest_suites.py +29 -4
  122. warp/tests/unittest_utils.py +30 -13
  123. warp/thirdparty/unittest_parallel.py +2 -2
  124. warp/types.py +411 -101
  125. warp/utils.py +10 -7
  126. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/METADATA +92 -69
  127. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/RECORD +130 -119
  128. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/WHEEL +1 -1
  129. warp/examples/benchmarks/benchmark_tile.py +0 -179
  130. warp/native/tile_gemm.h +0 -341
  131. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/LICENSE.md +0 -0
  132. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/top_level.txt +0 -0
warp/tests/test_mesh.py CHANGED
@@ -88,21 +88,27 @@ def read_indices_kernel(
88
88
 
89
89
 
90
90
  def test_mesh_read_properties(test, device):
91
- points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
92
- indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
93
- mesh = wp.Mesh(points=points, indices=indices)
91
+ if device.is_cpu:
92
+ constructors = ["sah", "median"]
93
+ else:
94
+ constructors = ["sah", "median", "lbvh"]
94
95
 
95
- assert mesh.points.size == POINT_COUNT
96
- assert mesh.indices.size == VERTEX_COUNT
97
- assert int(mesh.indices.size / 3) == FACE_COUNT
96
+ for constructor in constructors:
97
+ points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
98
+ indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
99
+ mesh = wp.Mesh(points=points, indices=indices, bvh_constructor=constructor)
98
100
 
99
- out_points = wp.empty(POINT_COUNT, dtype=wp.vec3, device=device)
100
- wp.launch(read_points_kernel, dim=POINT_COUNT, inputs=[mesh.id], outputs=[out_points], device=device)
101
- assert_np_equal(out_points.numpy(), np.array(POINT_POSITIONS))
101
+ assert mesh.points.size == POINT_COUNT
102
+ assert mesh.indices.size == VERTEX_COUNT
103
+ assert int(mesh.indices.size / 3) == FACE_COUNT
102
104
 
103
- out_indices = wp.empty(VERTEX_COUNT, dtype=int, device=device)
104
- wp.launch(read_indices_kernel, dim=FACE_COUNT, inputs=[mesh.id], outputs=[out_indices], device=device)
105
- assert_np_equal(out_indices.numpy(), np.array(RIGHT_HANDED_FACE_VERTEX_INDICES))
105
+ out_points = wp.empty(POINT_COUNT, dtype=wp.vec3, device=device)
106
+ wp.launch(read_points_kernel, dim=POINT_COUNT, inputs=[mesh.id], outputs=[out_points], device=device)
107
+ assert_np_equal(out_points.numpy(), np.array(POINT_POSITIONS))
108
+
109
+ out_indices = wp.empty(VERTEX_COUNT, dtype=int, device=device)
110
+ wp.launch(read_indices_kernel, dim=FACE_COUNT, inputs=[mesh.id], outputs=[out_indices], device=device)
111
+ assert_np_equal(out_indices.numpy(), np.array(RIGHT_HANDED_FACE_VERTEX_INDICES))
106
112
 
107
113
 
108
114
  @wp.kernel(enable_backward=False)
@@ -127,17 +133,23 @@ def query_point_kernel(
127
133
 
128
134
 
129
135
  def test_mesh_query_point(test, device):
130
- points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
136
+ if device.is_cpu:
137
+ constructors = ["sah", "median"]
138
+ else:
139
+ constructors = ["sah", "median", "lbvh"]
131
140
 
132
- indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
133
- mesh = wp.Mesh(points=points, indices=indices)
134
- expected_sign = -1.0
135
- wp.launch(query_point_kernel, dim=1, inputs=[mesh.id, expected_sign], device=device)
141
+ for constructor in constructors:
142
+ points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
136
143
 
137
- indices = wp.array(LEFT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
138
- mesh = wp.Mesh(points=points, indices=indices)
139
- expected_sign = 1.0
140
- wp.launch(query_point_kernel, dim=1, inputs=[mesh.id, expected_sign], device=device)
144
+ indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
145
+ mesh = wp.Mesh(points=points, indices=indices, bvh_constructor=constructor)
146
+ expected_sign = -1.0
147
+ wp.launch(query_point_kernel, dim=1, inputs=[mesh.id, expected_sign], device=device)
148
+
149
+ indices = wp.array(LEFT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
150
+ mesh = wp.Mesh(points=points, indices=indices)
151
+ expected_sign = 1.0
152
+ wp.launch(query_point_kernel, dim=1, inputs=[mesh.id, expected_sign], device=device)
141
153
 
142
154
 
143
155
  @wp.kernel(enable_backward=False)
@@ -179,53 +191,65 @@ def query_ray_kernel(
179
191
 
180
192
 
181
193
  def test_mesh_query_ray(test, device):
182
- points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
183
-
184
- indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
185
- mesh = wp.Mesh(points=points, indices=indices)
186
- expected_sign = -1.0
187
- wp.launch(
188
- query_ray_kernel,
189
- dim=1,
190
- inputs=[
191
- mesh.id,
192
- expected_sign,
193
- ],
194
- device=device,
195
- )
194
+ if device.is_cpu:
195
+ constructors = ["sah", "median"]
196
+ else:
197
+ constructors = ["sah", "median", "lbvh"]
196
198
 
197
- indices = wp.array(LEFT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
198
- mesh = wp.Mesh(points=points, indices=indices)
199
- expected_sign = 1.0
200
- wp.launch(
201
- query_ray_kernel,
202
- dim=1,
203
- inputs=[
204
- mesh.id,
205
- expected_sign,
206
- ],
207
- device=device,
208
- )
199
+ for constructor in constructors:
200
+ points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
201
+
202
+ indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
203
+ mesh = wp.Mesh(points=points, indices=indices, bvh_constructor=constructor)
204
+ expected_sign = -1.0
205
+ wp.launch(
206
+ query_ray_kernel,
207
+ dim=1,
208
+ inputs=[
209
+ mesh.id,
210
+ expected_sign,
211
+ ],
212
+ device=device,
213
+ )
214
+
215
+ indices = wp.array(LEFT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
216
+ mesh = wp.Mesh(points=points, indices=indices)
217
+ expected_sign = 1.0
218
+ wp.launch(
219
+ query_ray_kernel,
220
+ dim=1,
221
+ inputs=[
222
+ mesh.id,
223
+ expected_sign,
224
+ ],
225
+ device=device,
226
+ )
209
227
 
210
228
 
211
229
  def test_mesh_refit_graph(test, device):
212
- points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
230
+ if device.is_cpu:
231
+ constructors = ["sah", "median"]
232
+ else:
233
+ constructors = ["sah", "median", "lbvh"]
213
234
 
214
- indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
215
- mesh = wp.Mesh(points=points, indices=indices)
235
+ for constructor in constructors:
236
+ points = wp.array(POINT_POSITIONS, dtype=wp.vec3, device=device)
237
+
238
+ indices = wp.array(RIGHT_HANDED_FACE_VERTEX_INDICES, dtype=int, device=device)
239
+ mesh = wp.Mesh(points=points, indices=indices, bvh_constructor=constructor)
216
240
 
217
- wp.capture_begin(device, force_module_load=False)
218
- try:
219
- mesh.refit()
220
- finally:
221
- graph = wp.capture_end(device)
241
+ wp.capture_begin(device, force_module_load=False)
242
+ try:
243
+ mesh.refit()
244
+ finally:
245
+ graph = wp.capture_end(device)
222
246
 
223
- # replay
224
- num_iters = 10
225
- for _ in range(num_iters):
226
- wp.capture_launch(graph)
247
+ # replay
248
+ num_iters = 10
249
+ for _ in range(num_iters):
250
+ wp.capture_launch(graph)
227
251
 
228
- wp.synchronize_device(device)
252
+ wp.synchronize_device(device)
229
253
 
230
254
 
231
255
  def test_mesh_exceptions(test, device):
@@ -5,11 +5,13 @@
5
5
  # distribution of this software and related documentation without an express
6
6
  # license agreement from NVIDIA CORPORATION is strictly prohibited.
7
7
 
8
+ import os
8
9
  import unittest
9
10
 
10
11
  import numpy as np
11
12
 
12
13
  import warp as wp
14
+ import warp.examples
13
15
  from warp.tests.unittest_utils import *
14
16
 
15
17
 
@@ -192,6 +194,162 @@ def test_mesh_query_aabb_count_nonoverlap(test, device):
192
194
  test.assertTrue(c == 1)
193
195
 
194
196
 
197
+ @wp.kernel
198
+ def compute_num_contact_with_checksums(
199
+ lowers: wp.array(dtype=wp.vec3),
200
+ uppers: wp.array(dtype=wp.vec3),
201
+ mesh_id: wp.uint64,
202
+ counts: wp.array(dtype=int),
203
+ check_sums: wp.array(dtype=int),
204
+ ):
205
+ face_index = int(0)
206
+ face_u = float(0.0)
207
+ face_v = float(0.0)
208
+ sign = float(0.0)
209
+
210
+ tid = wp.tid()
211
+
212
+ upper = uppers[tid]
213
+ lower = lowers[tid]
214
+
215
+ query = wp.mesh_query_aabb(mesh_id, lower, upper)
216
+ count = int(0)
217
+
218
+ check_sum = int(0)
219
+ for _index in query:
220
+ check_sum = check_sum ^ _index
221
+ count = count + 1
222
+
223
+ counts[tid] = count
224
+ check_sums[tid] = check_sum
225
+
226
+
227
+ @wp.func
228
+ def intersect_aabb_aabb(a_lower: wp.vec3, a_upper: wp.vec3, b_lower: wp.vec3, b_upper: wp.vec3):
229
+ if (
230
+ a_lower[0] > b_upper[0]
231
+ or a_lower[1] > b_upper[1]
232
+ or a_lower[2] > b_upper[2]
233
+ or a_upper[0] < b_lower[0]
234
+ or a_upper[1] < b_lower[1]
235
+ or a_upper[2] < b_lower[2]
236
+ ):
237
+ return False
238
+ else:
239
+ return True
240
+
241
+
242
+ @wp.kernel
243
+ def compute_num_contact_with_checksums_brutal(
244
+ lowers: wp.array(dtype=wp.vec3),
245
+ uppers: wp.array(dtype=wp.vec3),
246
+ mesh_points: wp.array(dtype=wp.vec3),
247
+ mesh_indices: wp.array(dtype=int),
248
+ counts: wp.array(dtype=int),
249
+ check_sums: wp.array(dtype=int),
250
+ ):
251
+ tid = wp.tid()
252
+
253
+ upper = uppers[tid]
254
+ lower = lowers[tid]
255
+
256
+ check_sum = int(0)
257
+ count = int(0)
258
+ num_faces = mesh_indices.shape[0] / 3
259
+
260
+ for face in range(num_faces):
261
+ i = mesh_indices[face * 3 + 0]
262
+ j = mesh_indices[face * 3 + 1]
263
+ k = mesh_indices[face * 3 + 2]
264
+
265
+ x0 = mesh_points[i] # point zero
266
+ x1 = mesh_points[j] # point one
267
+ x2 = mesh_points[k] # point two
268
+
269
+ tri_lower = min_vec3(min_vec3(x0, x1), x2)
270
+ tri_upper = max_vec3(max_vec3(x0, x1), x2)
271
+
272
+ if intersect_aabb_aabb(lower, upper, tri_lower, tri_upper):
273
+ check_sum = check_sum ^ face
274
+ count = count + 1
275
+
276
+ counts[tid] = count
277
+ check_sums[tid] = check_sum
278
+
279
+
280
+ def load_mesh():
281
+ from pxr import Usd, UsdGeom
282
+
283
+ usd_stage = Usd.Stage.Open(os.path.join(wp.examples.get_asset_directory(), "bunny.usd"))
284
+ usd_geom = UsdGeom.Mesh(usd_stage.GetPrimAtPath("/root/bunny"))
285
+
286
+ vertices = np.array(usd_geom.GetPointsAttr().Get())
287
+ faces = np.array(usd_geom.GetFaceVertexIndicesAttr().Get())
288
+
289
+ return vertices, faces
290
+
291
+
292
+ @unittest.skipUnless(USD_AVAILABLE, "Requires usd-core")
293
+ def test_mesh_query_aabb_count_overlap_with_checksum(test, device):
294
+ if device.is_cpu:
295
+ constructors = ["sah", "median"]
296
+ else:
297
+ constructors = ["sah", "median", "lbvh"]
298
+
299
+ points, indices = load_mesh()
300
+ points_wp = wp.array(points, dtype=wp.vec3, device=device)
301
+ indices_wp = wp.array(indices, dtype=int, device=device)
302
+
303
+ for constructor in constructors:
304
+ m = wp.Mesh(points=points_wp, indices=indices_wp, bvh_constructor=constructor)
305
+
306
+ num_test_bounds = 10000
307
+ test_bound_relative_size = 0.01
308
+
309
+ world_min = np.min(points, axis=0)
310
+ world_max = np.max(points, axis=0)
311
+
312
+ world_center = 0.5 * (world_min + world_max)
313
+ world_size = world_max - world_min
314
+
315
+ rng = np.random.default_rng(123)
316
+
317
+ centers = (
318
+ rng.uniform(-0.5, 0.5, size=num_test_bounds * 3).reshape(num_test_bounds, 3) * world_size + world_center
319
+ )
320
+ diffs = (
321
+ 0.5 * test_bound_relative_size * rng.random(num_test_bounds * 3).reshape(num_test_bounds, 3) * world_size
322
+ )
323
+
324
+ lowers = wp.array(centers - diffs, dtype=wp.vec3, device=device)
325
+ uppers = wp.array(centers + diffs, dtype=wp.vec3, device=device)
326
+
327
+ counts = wp.empty(n=num_test_bounds, dtype=int, device=device)
328
+ checksums = wp.empty(n=num_test_bounds, dtype=int, device=device)
329
+
330
+ wp.launch(
331
+ kernel=compute_num_contact_with_checksums,
332
+ dim=num_test_bounds,
333
+ inputs=[lowers, uppers, m.id],
334
+ outputs=[counts, checksums],
335
+ device=device,
336
+ )
337
+
338
+ counts_brutal = wp.empty(n=num_test_bounds, dtype=int, device=device)
339
+ checksums_brutal = wp.empty(n=num_test_bounds, dtype=int, device=device)
340
+
341
+ wp.launch(
342
+ kernel=compute_num_contact_with_checksums_brutal,
343
+ dim=num_test_bounds,
344
+ inputs=[lowers, uppers, points_wp, indices_wp],
345
+ outputs=[counts_brutal, checksums_brutal],
346
+ device=device,
347
+ )
348
+
349
+ assert_array_equal(counts, counts_brutal)
350
+ assert_array_equal(checksums, checksums_brutal)
351
+
352
+
195
353
  devices = get_test_devices()
196
354
 
197
355
 
@@ -220,6 +378,13 @@ add_function_test(
220
378
  test_mesh_query_aabb_count_nonoverlap,
221
379
  devices=devices,
222
380
  )
381
+ add_function_test(
382
+ TestMeshQueryAABBMethods,
383
+ "test_mesh_query_aabb_count_overlap_with_checksum",
384
+ test_mesh_query_aabb_count_overlap_with_checksum,
385
+ devices=devices,
386
+ )
387
+
223
388
 
224
389
  if __name__ == "__main__":
225
390
  wp.clear_kernel_cache()