warp-lang 1.7.1__py3-none-win_amd64.whl → 1.7.2__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.
- warp/bin/warp-clang.dll +0 -0
- warp/bin/warp.dll +0 -0
- warp/builtins.py +92 -56
- warp/codegen.py +31 -22
- warp/config.py +1 -1
- warp/context.py +106 -49
- warp/fem/cache.py +1 -1
- warp/jax_experimental/ffi.py +95 -66
- warp/native/builtin.h +91 -65
- warp/native/svd.h +59 -49
- warp/native/tile.h +46 -17
- warp/native/volume.cpp +2 -2
- warp/native/volume_builder.cu +33 -22
- warp/render/render_opengl.py +22 -17
- warp/render/render_usd.py +3 -3
- warp/sim/model.py +29 -21
- warp/sparse.py +1 -1
- warp/stubs.py +72 -24
- warp/tests/cuda/test_streams.py +1 -1
- warp/tests/sim/test_model.py +5 -3
- warp/tests/sim/test_sim_grad.py +1 -8
- warp/tests/test_array.py +8 -7
- warp/tests/test_atomic.py +181 -2
- warp/tests/test_builtins_resolution.py +38 -38
- warp/tests/test_fem.py +20 -6
- warp/tests/test_func.py +1 -1
- warp/tests/test_mat.py +46 -16
- warp/tests/test_struct.py +116 -0
- warp/tests/tile/test_tile.py +27 -0
- warp/tests/tile/test_tile_load.py +27 -0
- warp/types.py +42 -1
- {warp_lang-1.7.1.dist-info → warp_lang-1.7.2.dist-info}/METADATA +26 -16
- {warp_lang-1.7.1.dist-info → warp_lang-1.7.2.dist-info}/RECORD +36 -36
- {warp_lang-1.7.1.dist-info → warp_lang-1.7.2.dist-info}/WHEEL +1 -1
- {warp_lang-1.7.1.dist-info → warp_lang-1.7.2.dist-info}/licenses/LICENSE.md +0 -0
- {warp_lang-1.7.1.dist-info → warp_lang-1.7.2.dist-info}/top_level.txt +0 -0
warp/stubs.py
CHANGED
|
@@ -2248,145 +2248,193 @@ def where(arr: Array[Any], value_if_true: Any, value_if_false: Any) -> Any:
|
|
|
2248
2248
|
|
|
2249
2249
|
@over
|
|
2250
2250
|
def atomic_add(arr: Array[Any], i: Int, value: Any) -> Any:
|
|
2251
|
-
"""Atomically
|
|
2251
|
+
"""Atomically adds ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
|
|
2252
|
+
This function is automatically invoked when using the syntax ``arr[i] += value``.
|
|
2253
|
+
"""
|
|
2252
2254
|
...
|
|
2253
2255
|
|
|
2254
2256
|
|
|
2255
2257
|
@over
|
|
2256
2258
|
def atomic_add(arr: Array[Any], i: Int, j: Int, value: Any) -> Any:
|
|
2257
|
-
"""Atomically
|
|
2259
|
+
"""Atomically adds ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
|
|
2260
|
+
This function is automatically invoked when using the syntax ``arr[i,j] += value``.
|
|
2261
|
+
"""
|
|
2258
2262
|
...
|
|
2259
2263
|
|
|
2260
2264
|
|
|
2261
2265
|
@over
|
|
2262
2266
|
def atomic_add(arr: Array[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
|
|
2263
|
-
"""Atomically
|
|
2267
|
+
"""Atomically adds ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
|
|
2268
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k] += value``.
|
|
2269
|
+
"""
|
|
2264
2270
|
...
|
|
2265
2271
|
|
|
2266
2272
|
|
|
2267
2273
|
@over
|
|
2268
2274
|
def atomic_add(arr: Array[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
|
|
2269
|
-
"""Atomically
|
|
2275
|
+
"""Atomically adds ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
|
|
2276
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k,l] += value``.
|
|
2277
|
+
"""
|
|
2270
2278
|
...
|
|
2271
2279
|
|
|
2272
2280
|
|
|
2273
2281
|
@over
|
|
2274
2282
|
def atomic_add(arr: FabricArray[Any], i: Int, value: Any) -> Any:
|
|
2275
|
-
"""Atomically
|
|
2283
|
+
"""Atomically adds ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
|
|
2284
|
+
This function is automatically invoked when using the syntax ``arr[i] += value``.
|
|
2285
|
+
"""
|
|
2276
2286
|
...
|
|
2277
2287
|
|
|
2278
2288
|
|
|
2279
2289
|
@over
|
|
2280
2290
|
def atomic_add(arr: FabricArray[Any], i: Int, j: Int, value: Any) -> Any:
|
|
2281
|
-
"""Atomically
|
|
2291
|
+
"""Atomically adds ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
|
|
2292
|
+
This function is automatically invoked when using the syntax ``arr[i,j] += value``.
|
|
2293
|
+
"""
|
|
2282
2294
|
...
|
|
2283
2295
|
|
|
2284
2296
|
|
|
2285
2297
|
@over
|
|
2286
2298
|
def atomic_add(arr: FabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
|
|
2287
|
-
"""Atomically
|
|
2299
|
+
"""Atomically adds ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
|
|
2300
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k] += value``.
|
|
2301
|
+
"""
|
|
2288
2302
|
...
|
|
2289
2303
|
|
|
2290
2304
|
|
|
2291
2305
|
@over
|
|
2292
2306
|
def atomic_add(arr: FabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
|
|
2293
|
-
"""Atomically
|
|
2307
|
+
"""Atomically adds ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
|
|
2308
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k,l] += value``.
|
|
2309
|
+
"""
|
|
2294
2310
|
...
|
|
2295
2311
|
|
|
2296
2312
|
|
|
2297
2313
|
@over
|
|
2298
2314
|
def atomic_add(arr: IndexedFabricArray[Any], i: Int, value: Any) -> Any:
|
|
2299
|
-
"""Atomically
|
|
2315
|
+
"""Atomically adds ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
|
|
2316
|
+
This function is automatically invoked when using the syntax ``arr[i] += value``.
|
|
2317
|
+
"""
|
|
2300
2318
|
...
|
|
2301
2319
|
|
|
2302
2320
|
|
|
2303
2321
|
@over
|
|
2304
2322
|
def atomic_add(arr: IndexedFabricArray[Any], i: Int, j: Int, value: Any) -> Any:
|
|
2305
|
-
"""Atomically
|
|
2323
|
+
"""Atomically adds ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
|
|
2324
|
+
This function is automatically invoked when using the syntax ``arr[i,j] += value``.
|
|
2325
|
+
"""
|
|
2306
2326
|
...
|
|
2307
2327
|
|
|
2308
2328
|
|
|
2309
2329
|
@over
|
|
2310
2330
|
def atomic_add(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
|
|
2311
|
-
"""Atomically
|
|
2331
|
+
"""Atomically adds ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
|
|
2332
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k] += value``.
|
|
2333
|
+
"""
|
|
2312
2334
|
...
|
|
2313
2335
|
|
|
2314
2336
|
|
|
2315
2337
|
@over
|
|
2316
2338
|
def atomic_add(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
|
|
2317
|
-
"""Atomically
|
|
2339
|
+
"""Atomically adds ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
|
|
2340
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k,l] += value``.
|
|
2341
|
+
"""
|
|
2318
2342
|
...
|
|
2319
2343
|
|
|
2320
2344
|
|
|
2321
2345
|
@over
|
|
2322
2346
|
def atomic_sub(arr: Array[Any], i: Int, value: Any) -> Any:
|
|
2323
|
-
"""Atomically
|
|
2347
|
+
"""Atomically subtracts ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
|
|
2348
|
+
This function is automatically invoked when using the syntax ``arr[i] -= value``.
|
|
2349
|
+
"""
|
|
2324
2350
|
...
|
|
2325
2351
|
|
|
2326
2352
|
|
|
2327
2353
|
@over
|
|
2328
2354
|
def atomic_sub(arr: Array[Any], i: Int, j: Int, value: Any) -> Any:
|
|
2329
|
-
"""Atomically
|
|
2355
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
|
|
2356
|
+
This function is automatically invoked when using the syntax ``arr[i,j] -= value``.
|
|
2357
|
+
"""
|
|
2330
2358
|
...
|
|
2331
2359
|
|
|
2332
2360
|
|
|
2333
2361
|
@over
|
|
2334
2362
|
def atomic_sub(arr: Array[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
|
|
2335
|
-
"""Atomically
|
|
2363
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
|
|
2364
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k] -= value``.
|
|
2365
|
+
"""
|
|
2336
2366
|
...
|
|
2337
2367
|
|
|
2338
2368
|
|
|
2339
2369
|
@over
|
|
2340
2370
|
def atomic_sub(arr: Array[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
|
|
2341
|
-
"""Atomically
|
|
2371
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
|
|
2372
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k,l] -= value``.
|
|
2373
|
+
"""
|
|
2342
2374
|
...
|
|
2343
2375
|
|
|
2344
2376
|
|
|
2345
2377
|
@over
|
|
2346
2378
|
def atomic_sub(arr: FabricArray[Any], i: Int, value: Any) -> Any:
|
|
2347
|
-
"""Atomically
|
|
2379
|
+
"""Atomically subtracts ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
|
|
2380
|
+
This function is automatically invoked when using the syntax ``arr[i] -= value``.
|
|
2381
|
+
"""
|
|
2348
2382
|
...
|
|
2349
2383
|
|
|
2350
2384
|
|
|
2351
2385
|
@over
|
|
2352
2386
|
def atomic_sub(arr: FabricArray[Any], i: Int, j: Int, value: Any) -> Any:
|
|
2353
|
-
"""Atomically
|
|
2387
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
|
|
2388
|
+
This function is automatically invoked when using the syntax ``arr[i,j] -= value``.
|
|
2389
|
+
"""
|
|
2354
2390
|
...
|
|
2355
2391
|
|
|
2356
2392
|
|
|
2357
2393
|
@over
|
|
2358
2394
|
def atomic_sub(arr: FabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
|
|
2359
|
-
"""Atomically
|
|
2395
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
|
|
2396
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k] -= value``.
|
|
2397
|
+
"""
|
|
2360
2398
|
...
|
|
2361
2399
|
|
|
2362
2400
|
|
|
2363
2401
|
@over
|
|
2364
2402
|
def atomic_sub(arr: FabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
|
|
2365
|
-
"""Atomically
|
|
2403
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
|
|
2404
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k,l] -= value``.
|
|
2405
|
+
"""
|
|
2366
2406
|
...
|
|
2367
2407
|
|
|
2368
2408
|
|
|
2369
2409
|
@over
|
|
2370
2410
|
def atomic_sub(arr: IndexedFabricArray[Any], i: Int, value: Any) -> Any:
|
|
2371
|
-
"""Atomically
|
|
2411
|
+
"""Atomically subtracts ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
|
|
2412
|
+
This function is automatically invoked when using the syntax ``arr[i] -= value``.
|
|
2413
|
+
"""
|
|
2372
2414
|
...
|
|
2373
2415
|
|
|
2374
2416
|
|
|
2375
2417
|
@over
|
|
2376
2418
|
def atomic_sub(arr: IndexedFabricArray[Any], i: Int, j: Int, value: Any) -> Any:
|
|
2377
|
-
"""Atomically
|
|
2419
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
|
|
2420
|
+
This function is automatically invoked when using the syntax ``arr[i,j] -= value``.
|
|
2421
|
+
"""
|
|
2378
2422
|
...
|
|
2379
2423
|
|
|
2380
2424
|
|
|
2381
2425
|
@over
|
|
2382
2426
|
def atomic_sub(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
|
|
2383
|
-
"""Atomically
|
|
2427
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
|
|
2428
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k] -= value``.
|
|
2429
|
+
"""
|
|
2384
2430
|
...
|
|
2385
2431
|
|
|
2386
2432
|
|
|
2387
2433
|
@over
|
|
2388
2434
|
def atomic_sub(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
|
|
2389
|
-
"""Atomically
|
|
2435
|
+
"""Atomically subtracts ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
|
|
2436
|
+
This function is automatically invoked when using the syntax ``arr[i,j,k,l] -= value``.
|
|
2437
|
+
"""
|
|
2390
2438
|
...
|
|
2391
2439
|
|
|
2392
2440
|
|
warp/tests/cuda/test_streams.py
CHANGED
warp/tests/sim/test_model.py
CHANGED
|
@@ -150,7 +150,9 @@ class TestModel(unittest.TestCase):
|
|
|
150
150
|
assert builder.joint_count == 8
|
|
151
151
|
assert builder.body_count == 8
|
|
152
152
|
assert builder.articulation_count == 3
|
|
153
|
-
add_three_cubes(builder, parent_body=b4)
|
|
153
|
+
lb = add_three_cubes(builder, parent_body=b4)
|
|
154
|
+
# add shape with no mass (e.g. visual only shape)
|
|
155
|
+
builder.add_shape_sphere(lb, density=0.0)
|
|
154
156
|
|
|
155
157
|
builder.collapse_fixed_joints()
|
|
156
158
|
|
|
@@ -158,8 +160,8 @@ class TestModel(unittest.TestCase):
|
|
|
158
160
|
assert builder.articulation_count == 2
|
|
159
161
|
assert builder.articulation_start == [0, 1]
|
|
160
162
|
assert builder.joint_type == [wp.sim.JOINT_REVOLUTE, wp.sim.JOINT_FREE]
|
|
161
|
-
assert builder.shape_count ==
|
|
162
|
-
assert builder.shape_body == [-1, -1, -1, -1, -1, -1, 0, 1, 1, 1, 1]
|
|
163
|
+
assert builder.shape_count == 12
|
|
164
|
+
assert builder.shape_body == [-1, -1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1]
|
|
163
165
|
assert builder.body_count == 2
|
|
164
166
|
assert builder.body_com[0] == wp.vec3(1.0, 2.0, 3.0)
|
|
165
167
|
assert builder.body_com[1] == wp.vec3(0.25, 0.25, 0.25)
|
warp/tests/sim/test_sim_grad.py
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
import platform
|
|
17
16
|
import unittest
|
|
18
17
|
|
|
19
18
|
import numpy as np
|
|
@@ -104,9 +103,6 @@ def test_sphere_pushing_on_rails(
|
|
|
104
103
|
static_contacts=True,
|
|
105
104
|
print_grad=False,
|
|
106
105
|
):
|
|
107
|
-
if platform.system() == "Darwin":
|
|
108
|
-
test.skipTest("Crashes on Mac runners")
|
|
109
|
-
|
|
110
106
|
# Two spheres on a rail (prismatic or D6 joint), one is pushed, the other is passive.
|
|
111
107
|
# The absolute distance to a target is measured and gradients are compared for
|
|
112
108
|
# a push that is too far and too close.
|
|
@@ -161,9 +157,6 @@ def test_sphere_pushing_on_rails(
|
|
|
161
157
|
model.joint_attach_ke = 32000.0 * 16
|
|
162
158
|
model.joint_attach_kd = 500.0 * 4
|
|
163
159
|
|
|
164
|
-
model.shape_geo.scale.requires_grad = False
|
|
165
|
-
model.shape_geo.thickness.requires_grad = False
|
|
166
|
-
|
|
167
160
|
if static_contacts:
|
|
168
161
|
wp.sim.eval_fk(model, model.joint_q, model.joint_qd, None, model)
|
|
169
162
|
model.rigid_contact_margin = 10.0
|
|
@@ -272,7 +265,7 @@ def test_sphere_pushing_on_rails(
|
|
|
272
265
|
gradcheck(rollout, [action_too_close], device=device, eps=0.2, tol=tol, print_grad=print_grad)
|
|
273
266
|
|
|
274
267
|
|
|
275
|
-
devices = get_test_devices()
|
|
268
|
+
devices = get_test_devices(mode="basic")
|
|
276
269
|
|
|
277
270
|
|
|
278
271
|
class TestSimGradients(unittest.TestCase):
|
warp/tests/test_array.py
CHANGED
|
@@ -2803,7 +2803,7 @@ def test_alloc_strides(test, device):
|
|
|
2803
2803
|
|
|
2804
2804
|
def test_casting(test, device):
|
|
2805
2805
|
idxs = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
|
|
2806
|
-
idxs = wp.array(idxs, device=device).reshape((-1, 3))
|
|
2806
|
+
idxs = wp.array(idxs, device=device, dtype=wp.int32).reshape((-1, 3))
|
|
2807
2807
|
idxs = wp.array(idxs, shape=idxs.shape[0], dtype=wp.vec3i, device=device)
|
|
2808
2808
|
assert idxs.dtype is wp.vec3i
|
|
2809
2809
|
assert idxs.shape == (4,)
|
|
@@ -2846,25 +2846,25 @@ def test_array_len(test, device):
|
|
|
2846
2846
|
|
|
2847
2847
|
def test_cuda_interface_conversion(test, device):
|
|
2848
2848
|
class MyArrayInterface:
|
|
2849
|
-
def __init__(self, data):
|
|
2850
|
-
self.data = np.array(data)
|
|
2849
|
+
def __init__(self, data, npdtype):
|
|
2850
|
+
self.data = np.array(data, dtype=npdtype)
|
|
2851
2851
|
self.__array_interface__ = self.data.__array_interface__
|
|
2852
2852
|
self.__cuda_array_interface__ = self.data.__array_interface__
|
|
2853
2853
|
self.__len__ = self.data.__len__
|
|
2854
2854
|
|
|
2855
|
-
array = MyArrayInterface((1, 2, 3))
|
|
2855
|
+
array = MyArrayInterface((1, 2, 3), np.int8)
|
|
2856
2856
|
wp_array = wp.array(array, dtype=wp.int8, device=device)
|
|
2857
2857
|
assert wp_array.ptr != 0
|
|
2858
2858
|
|
|
2859
|
-
array = MyArrayInterface((1, 2, 3))
|
|
2859
|
+
array = MyArrayInterface((1, 2, 3), np.float32)
|
|
2860
2860
|
wp_array = wp.array(array, dtype=wp.float32, device=device)
|
|
2861
2861
|
assert wp_array.ptr != 0
|
|
2862
2862
|
|
|
2863
|
-
array = MyArrayInterface((1, 2, 3))
|
|
2863
|
+
array = MyArrayInterface((1, 2, 3), np.float32)
|
|
2864
2864
|
wp_array = wp.array(array, dtype=wp.vec3, device=device)
|
|
2865
2865
|
assert wp_array.ptr != 0
|
|
2866
2866
|
|
|
2867
|
-
array = MyArrayInterface((1, 2, 3, 4))
|
|
2867
|
+
array = MyArrayInterface((1, 2, 3, 4), np.float32)
|
|
2868
2868
|
wp_array = wp.array(array, dtype=wp.mat22, device=device)
|
|
2869
2869
|
assert wp_array.ptr != 0
|
|
2870
2870
|
|
|
@@ -2883,6 +2883,7 @@ add_function_test(TestArray, "test_shape", test_shape, devices=devices)
|
|
|
2883
2883
|
add_function_test(TestArray, "test_negative_shape", test_negative_shape, devices=devices)
|
|
2884
2884
|
add_function_test(TestArray, "test_flatten", test_flatten, devices=devices)
|
|
2885
2885
|
add_function_test(TestArray, "test_reshape", test_reshape, devices=devices)
|
|
2886
|
+
|
|
2886
2887
|
add_function_test(TestArray, "test_slicing", test_slicing, devices=devices)
|
|
2887
2888
|
add_function_test(TestArray, "test_transpose", test_transpose, devices=devices)
|
|
2888
2889
|
add_function_test(TestArray, "test_view", test_view, devices=devices)
|
warp/tests/test_atomic.py
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
import re
|
|
16
17
|
import unittest
|
|
17
18
|
|
|
18
19
|
import numpy as np
|
|
@@ -32,8 +33,8 @@ def make_atomic_test(type):
|
|
|
32
33
|
tid = wp.tid()
|
|
33
34
|
|
|
34
35
|
wp.atomic_add(out_add, 0, val[tid])
|
|
35
|
-
wp.atomic_min(out_min, 0, val[tid])
|
|
36
|
-
wp.atomic_max(out_max, 0, val[tid])
|
|
36
|
+
wp.atomic_min(out_min, wp.uint32(0), val[tid])
|
|
37
|
+
wp.atomic_max(out_max, wp.int64(0), val[tid])
|
|
37
38
|
|
|
38
39
|
# register a custom kernel (no decorator) function
|
|
39
40
|
# this lets us register the same function definition
|
|
@@ -130,6 +131,102 @@ test_atomic_mat33 = make_atomic_test(wp.mat33)
|
|
|
130
131
|
test_atomic_mat44 = make_atomic_test(wp.mat44)
|
|
131
132
|
|
|
132
133
|
|
|
134
|
+
def test_atomic_add_supported_dtypes(test, device, dtype):
|
|
135
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
136
|
+
|
|
137
|
+
@wp.kernel
|
|
138
|
+
def kernel(arr: wp.array(dtype=dtype)):
|
|
139
|
+
wp.atomic_add(arr, 0, dtype(scalar_type(0)))
|
|
140
|
+
|
|
141
|
+
arr = wp.zeros(1, dtype=dtype, device=device)
|
|
142
|
+
wp.launch(kernel, dim=1, outputs=(arr,), device=device)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_atomic_min_supported_dtypes(test, device, dtype):
|
|
146
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
147
|
+
|
|
148
|
+
@wp.kernel
|
|
149
|
+
def kernel(arr: wp.array(dtype=dtype)):
|
|
150
|
+
wp.atomic_min(arr, 0, dtype(scalar_type(0)))
|
|
151
|
+
|
|
152
|
+
arr = wp.zeros(1, dtype=dtype, device=device)
|
|
153
|
+
wp.launch(kernel, dim=1, outputs=(arr,), device=device)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def test_atomic_max_supported_dtypes(test, device, dtype):
|
|
157
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
158
|
+
|
|
159
|
+
@wp.kernel
|
|
160
|
+
def kernel(arr: wp.array(dtype=dtype)):
|
|
161
|
+
wp.atomic_max(arr, 0, dtype(scalar_type(0)))
|
|
162
|
+
|
|
163
|
+
arr = wp.zeros(1, dtype=dtype, device=device)
|
|
164
|
+
wp.launch(kernel, dim=1, outputs=(arr,), device=device)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def test_atomic_add_unsupported_dtypes(test, device, dtype):
|
|
168
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
169
|
+
|
|
170
|
+
dtype_str = re.escape(wp.types.type_repr(dtype))
|
|
171
|
+
scalar_type_str = wp.types.type_repr(scalar_type)
|
|
172
|
+
|
|
173
|
+
@wp.kernel
|
|
174
|
+
def kernel(arr: wp.array(dtype=dtype)):
|
|
175
|
+
wp.atomic_add(arr, 0, dtype(scalar_type(0)))
|
|
176
|
+
|
|
177
|
+
arr = wp.zeros(1, dtype=dtype, device=device)
|
|
178
|
+
with test.assertRaisesRegex(
|
|
179
|
+
RuntimeError,
|
|
180
|
+
(
|
|
181
|
+
r"atomic_add\(\) operations only work on arrays with \[u\]int32, \[u\]int64, float16, float32, or float64 "
|
|
182
|
+
rf"as the underlying scalar types, but got {dtype_str} \(with scalar type {scalar_type_str}\)$"
|
|
183
|
+
),
|
|
184
|
+
):
|
|
185
|
+
wp.launch(kernel, dim=1, outputs=(arr,), device=device)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def test_atomic_min_unsupported_dtypes(test, device, dtype):
|
|
189
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
190
|
+
|
|
191
|
+
dtype_str = re.escape(wp.types.type_repr(dtype))
|
|
192
|
+
scalar_type_str = wp.types.type_repr(scalar_type)
|
|
193
|
+
|
|
194
|
+
@wp.kernel
|
|
195
|
+
def kernel(arr: wp.array(dtype=dtype)):
|
|
196
|
+
wp.atomic_min(arr, 0, dtype(scalar_type(0)))
|
|
197
|
+
|
|
198
|
+
arr = wp.zeros(1, dtype=dtype, device=device)
|
|
199
|
+
with test.assertRaisesRegex(
|
|
200
|
+
RuntimeError,
|
|
201
|
+
(
|
|
202
|
+
r"atomic_min\(\) operations only work on arrays with \[u\]int32, \[u\]int64, float32, or float64 "
|
|
203
|
+
rf"as the underlying scalar types, but got {dtype_str} \(with scalar type {scalar_type_str}\)$"
|
|
204
|
+
),
|
|
205
|
+
):
|
|
206
|
+
wp.launch(kernel, dim=1, outputs=(arr,), device=device)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def test_atomic_max_unsupported_dtypes(test, device, dtype):
|
|
210
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
211
|
+
|
|
212
|
+
dtype_str = re.escape(wp.types.type_repr(dtype))
|
|
213
|
+
scalar_type_str = wp.types.type_repr(scalar_type)
|
|
214
|
+
|
|
215
|
+
@wp.kernel
|
|
216
|
+
def kernel(arr: wp.array(dtype=dtype)):
|
|
217
|
+
wp.atomic_max(arr, 0, dtype(scalar_type(0)))
|
|
218
|
+
|
|
219
|
+
arr = wp.zeros(1, dtype=dtype, device=device)
|
|
220
|
+
with test.assertRaisesRegex(
|
|
221
|
+
RuntimeError,
|
|
222
|
+
(
|
|
223
|
+
r"atomic_max\(\) operations only work on arrays with \[u\]int32, \[u\]int64, float32, or float64 "
|
|
224
|
+
rf"as the underlying scalar types, but got {dtype_str} \(with scalar type {scalar_type_str}\)$"
|
|
225
|
+
),
|
|
226
|
+
):
|
|
227
|
+
wp.launch(kernel, dim=1, outputs=(arr,), device=device)
|
|
228
|
+
|
|
229
|
+
|
|
133
230
|
devices = get_test_devices()
|
|
134
231
|
|
|
135
232
|
|
|
@@ -147,6 +244,88 @@ add_function_test(TestAtomic, "test_atomic_mat22", test_atomic_mat22, devices=de
|
|
|
147
244
|
add_function_test(TestAtomic, "test_atomic_mat33", test_atomic_mat33, devices=devices)
|
|
148
245
|
add_function_test(TestAtomic, "test_atomic_mat44", test_atomic_mat44, devices=devices)
|
|
149
246
|
|
|
247
|
+
for dtype in (
|
|
248
|
+
wp.int32,
|
|
249
|
+
wp.uint32,
|
|
250
|
+
wp.int64,
|
|
251
|
+
wp.uint64,
|
|
252
|
+
wp.float16,
|
|
253
|
+
wp.float32,
|
|
254
|
+
wp.float64,
|
|
255
|
+
wp.vec3i,
|
|
256
|
+
wp.vec3ui,
|
|
257
|
+
wp.vec3l,
|
|
258
|
+
wp.vec3ul,
|
|
259
|
+
wp.vec3h,
|
|
260
|
+
wp.vec3f,
|
|
261
|
+
wp.vec3d,
|
|
262
|
+
):
|
|
263
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
264
|
+
|
|
265
|
+
add_function_test(
|
|
266
|
+
TestAtomic,
|
|
267
|
+
f"test_atomic_add_supported_dtypes_{dtype.__name__}",
|
|
268
|
+
test_atomic_add_supported_dtypes,
|
|
269
|
+
devices=devices,
|
|
270
|
+
dtype=dtype,
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
if scalar_type is not wp.float16:
|
|
274
|
+
add_function_test(
|
|
275
|
+
TestAtomic,
|
|
276
|
+
f"test_atomic_min_supported_dtypes_{dtype.__name__}",
|
|
277
|
+
test_atomic_min_supported_dtypes,
|
|
278
|
+
devices=devices,
|
|
279
|
+
dtype=dtype,
|
|
280
|
+
)
|
|
281
|
+
add_function_test(
|
|
282
|
+
TestAtomic,
|
|
283
|
+
f"test_atomic_max_supported_dtypes_{dtype.__name__}",
|
|
284
|
+
test_atomic_max_supported_dtypes,
|
|
285
|
+
devices=devices,
|
|
286
|
+
dtype=dtype,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
for dtype in (
|
|
291
|
+
wp.int8,
|
|
292
|
+
wp.uint8,
|
|
293
|
+
wp.int16,
|
|
294
|
+
wp.uint16,
|
|
295
|
+
wp.float16,
|
|
296
|
+
wp.vec3b,
|
|
297
|
+
wp.vec3ub,
|
|
298
|
+
wp.vec3s,
|
|
299
|
+
wp.vec3us,
|
|
300
|
+
wp.vec3h,
|
|
301
|
+
):
|
|
302
|
+
scalar_type = getattr(dtype, "_wp_scalar_type_", dtype)
|
|
303
|
+
|
|
304
|
+
if scalar_type is not wp.float16:
|
|
305
|
+
add_function_test(
|
|
306
|
+
TestAtomic,
|
|
307
|
+
f"test_atomic_add_unsupported_dtypes_{dtype.__name__}",
|
|
308
|
+
test_atomic_add_unsupported_dtypes,
|
|
309
|
+
devices=devices,
|
|
310
|
+
dtype=dtype,
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
add_function_test(
|
|
314
|
+
TestAtomic,
|
|
315
|
+
f"test_atomic_min_unsupported_dtypes_{dtype.__name__}",
|
|
316
|
+
test_atomic_min_unsupported_dtypes,
|
|
317
|
+
devices=devices,
|
|
318
|
+
dtype=dtype,
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
add_function_test(
|
|
322
|
+
TestAtomic,
|
|
323
|
+
f"test_atomic_max_unsupported_dtypes_{dtype.__name__}",
|
|
324
|
+
test_atomic_max_unsupported_dtypes,
|
|
325
|
+
devices=devices,
|
|
326
|
+
dtype=dtype,
|
|
327
|
+
)
|
|
328
|
+
|
|
150
329
|
|
|
151
330
|
if __name__ == "__main__":
|
|
152
331
|
wp.clear_kernel_cache()
|