warp-lang 1.5.0__py3-none-win_amd64.whl → 1.5.1__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 +59 -28
- warp/codegen.py +21 -17
- warp/config.py +1 -1
- warp/context.py +59 -35
- warp/examples/sim/example_cloth.py +3 -1
- warp/fem/geometry/geometry.py +0 -2
- warp/native/coloring.cpp +5 -1
- warp/native/cuda_util.cpp +56 -53
- warp/native/tile.h +2 -5
- warp/render/render_opengl.py +7 -6
- warp/sim/import_urdf.py +8 -8
- warp/sim/model.py +23 -19
- warp/sparse.py +1 -1
- warp/stubs.py +23 -23
- warp/tests/test_coloring.py +12 -2
- warp/tests/test_examples.py +3 -1
- warp/tests/test_func.py +21 -4
- warp/tests/test_lerp.py +13 -87
- warp/tests/test_matmul.py +6 -9
- warp/tests/test_matmul_lite.py +6 -11
- warp/tests/test_overwrite.py +45 -0
- warp/tests/test_smoothstep.py +17 -83
- warp/tests/test_static.py +3 -3
- warp/tests/test_tile.py +44 -0
- warp/tests/unittest_utils.py +0 -2
- warp/types.py +2 -2
- warp/utils.py +1 -2
- {warp_lang-1.5.0.dist-info → warp_lang-1.5.1.dist-info}/METADATA +28 -29
- {warp_lang-1.5.0.dist-info → warp_lang-1.5.1.dist-info}/RECORD +34 -34
- {warp_lang-1.5.0.dist-info → warp_lang-1.5.1.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.5.0.dist-info → warp_lang-1.5.1.dist-info}/WHEEL +0 -0
- {warp_lang-1.5.0.dist-info → warp_lang-1.5.1.dist-info}/top_level.txt +0 -0
warp/tests/test_lerp.py
CHANGED
|
@@ -31,66 +31,14 @@ class TestData:
|
|
|
31
31
|
|
|
32
32
|
TEST_DATA = {
|
|
33
33
|
wp.float32: (
|
|
34
|
-
TestData(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
t=0.75,
|
|
38
|
-
expected=4.0,
|
|
39
|
-
expected_adj_a=0.25,
|
|
40
|
-
expected_adj_b=0.75,
|
|
41
|
-
expected_adj_t=4.0,
|
|
42
|
-
),
|
|
43
|
-
TestData(
|
|
44
|
-
a=-2.0,
|
|
45
|
-
b=5.0,
|
|
46
|
-
t=0.25,
|
|
47
|
-
expected=-0.25,
|
|
48
|
-
expected_adj_a=0.75,
|
|
49
|
-
expected_adj_b=0.25,
|
|
50
|
-
expected_adj_t=7.0,
|
|
51
|
-
),
|
|
52
|
-
TestData(
|
|
53
|
-
a=1.23,
|
|
54
|
-
b=2.34,
|
|
55
|
-
t=0.5,
|
|
56
|
-
expected=1.785,
|
|
57
|
-
expected_adj_a=0.5,
|
|
58
|
-
expected_adj_b=0.5,
|
|
59
|
-
expected_adj_t=1.11,
|
|
60
|
-
),
|
|
61
|
-
),
|
|
62
|
-
wp.vec2: (
|
|
63
|
-
TestData(
|
|
64
|
-
a=[1, 2],
|
|
65
|
-
b=[3, 4],
|
|
66
|
-
t=0.5,
|
|
67
|
-
expected=[2, 3],
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
|
-
wp.vec3: (
|
|
71
|
-
TestData(
|
|
72
|
-
a=[1, 2, 3],
|
|
73
|
-
b=[3, 4, 5],
|
|
74
|
-
t=0.5,
|
|
75
|
-
expected=[2, 3, 4],
|
|
76
|
-
),
|
|
77
|
-
),
|
|
78
|
-
wp.vec4: (
|
|
79
|
-
TestData(
|
|
80
|
-
a=[1, 2, 3, 4],
|
|
81
|
-
b=[3, 4, 5, 6],
|
|
82
|
-
t=0.5,
|
|
83
|
-
expected=[2, 3, 4, 5],
|
|
84
|
-
),
|
|
85
|
-
),
|
|
86
|
-
wp.mat22: (
|
|
87
|
-
TestData(
|
|
88
|
-
a=[[1, 2], [2, 1]],
|
|
89
|
-
b=[[3, 4], [4, 3]],
|
|
90
|
-
t=0.5,
|
|
91
|
-
expected=[[2, 3], [3, 2]],
|
|
92
|
-
),
|
|
34
|
+
TestData(a=1.0, b=5.0, t=0.75, expected=4.0, expected_adj_a=0.25, expected_adj_b=0.75, expected_adj_t=4.0),
|
|
35
|
+
TestData(a=-2.0, b=5.0, t=0.25, expected=-0.25, expected_adj_a=0.75, expected_adj_b=0.25, expected_adj_t=7.0),
|
|
36
|
+
TestData(a=1.23, b=2.34, t=0.5, expected=1.785, expected_adj_a=0.5, expected_adj_b=0.5, expected_adj_t=1.11),
|
|
93
37
|
),
|
|
38
|
+
wp.vec2: (TestData(a=[1, 2], b=[3, 4], t=0.5, expected=[2, 3]),),
|
|
39
|
+
wp.vec3: (TestData(a=[1, 2, 3], b=[3, 4, 5], t=0.5, expected=[2, 3, 4]),),
|
|
40
|
+
wp.vec4: (TestData(a=[1, 2, 3, 4], b=[3, 4, 5, 6], t=0.5, expected=[2, 3, 4, 5]),),
|
|
41
|
+
wp.mat22: (TestData(a=[[1, 2], [2, 1]], b=[[3, 4], [4, 3]], t=0.5, expected=[[2, 3], [3, 2]]),),
|
|
94
42
|
wp.mat33: (
|
|
95
43
|
TestData(
|
|
96
44
|
a=[[1, 2, 3], [3, 1, 2], [2, 3, 1]],
|
|
@@ -107,30 +55,9 @@ TEST_DATA = {
|
|
|
107
55
|
expected=[[2, 3, 4, 5], [5, 2, 3, 4], [4, 5, 2, 3], [3, 4, 5, 2]],
|
|
108
56
|
),
|
|
109
57
|
),
|
|
110
|
-
wp.quat: (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
b=[3, 4, 5, 6],
|
|
114
|
-
t=0.5,
|
|
115
|
-
expected=[2, 3, 4, 5],
|
|
116
|
-
),
|
|
117
|
-
),
|
|
118
|
-
wp.transform: (
|
|
119
|
-
TestData(
|
|
120
|
-
a=[1, 2, 3, 4, 5, 6, 7],
|
|
121
|
-
b=[3, 4, 5, 6, 7, 8, 9],
|
|
122
|
-
t=0.5,
|
|
123
|
-
expected=[2, 3, 4, 5, 6, 7, 8],
|
|
124
|
-
),
|
|
125
|
-
),
|
|
126
|
-
wp.spatial_vector: (
|
|
127
|
-
TestData(
|
|
128
|
-
a=[1, 2, 3, 4, 5, 6],
|
|
129
|
-
b=[3, 4, 5, 6, 7, 8],
|
|
130
|
-
t=0.5,
|
|
131
|
-
expected=[2, 3, 4, 5, 6, 7],
|
|
132
|
-
),
|
|
133
|
-
),
|
|
58
|
+
wp.quat: (TestData(a=[1, 2, 3, 4], b=[3, 4, 5, 6], t=0.5, expected=[2, 3, 4, 5]),),
|
|
59
|
+
wp.transform: (TestData(a=[1, 2, 3, 4, 5, 6, 7], b=[3, 4, 5, 6, 7, 8, 9], t=0.5, expected=[2, 3, 4, 5, 6, 7, 8]),),
|
|
60
|
+
wp.spatial_vector: (TestData(a=[1, 2, 3, 4, 5, 6], b=[3, 4, 5, 6, 7, 8], t=0.5, expected=[2, 3, 4, 5, 6, 7]),),
|
|
134
61
|
wp.spatial_matrix: (
|
|
135
62
|
TestData(
|
|
136
63
|
a=[
|
|
@@ -175,12 +102,12 @@ def test_lerp(test, device):
|
|
|
175
102
|
|
|
176
103
|
return fn
|
|
177
104
|
|
|
178
|
-
for data_type in TEST_DATA:
|
|
105
|
+
for data_type, test_data_set in TEST_DATA.items():
|
|
179
106
|
kernel_fn = make_kernel_fn(data_type)
|
|
180
107
|
kernel = wp.Kernel(func=kernel_fn, key=f"test_lerp_{data_type.__name__}_kernel")
|
|
181
108
|
|
|
182
109
|
with test.subTest(data_type=data_type):
|
|
183
|
-
for test_data in
|
|
110
|
+
for test_data in test_data_set:
|
|
184
111
|
a = wp.array([test_data.a], dtype=data_type, device=device, requires_grad=True)
|
|
185
112
|
b = wp.array([test_data.b], dtype=data_type, device=device, requires_grad=True)
|
|
186
113
|
t = wp.array([test_data.t], dtype=float, device=device, requires_grad=True)
|
|
@@ -188,8 +115,7 @@ def test_lerp(test, device):
|
|
|
188
115
|
[0] * wp.types.type_length(data_type), dtype=data_type, device=device, requires_grad=True
|
|
189
116
|
)
|
|
190
117
|
|
|
191
|
-
|
|
192
|
-
with tape:
|
|
118
|
+
with wp.Tape() as tape:
|
|
193
119
|
wp.launch(kernel, dim=1, inputs=[a, b, t, out], device=device)
|
|
194
120
|
|
|
195
121
|
assert_np_equal(out.numpy(), np.array([test_data.expected]), tol=1e-6)
|
warp/tests/test_matmul.py
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
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 itertools
|
|
8
9
|
import unittest
|
|
9
10
|
from typing import Any
|
|
10
11
|
|
|
@@ -105,19 +106,15 @@ class gemm_test_bed_runner:
|
|
|
105
106
|
assert_np_equal(C.grad.numpy(), adj_C_np)
|
|
106
107
|
|
|
107
108
|
def run(self):
|
|
108
|
-
Ms = [
|
|
109
|
-
Ns = [
|
|
110
|
-
Ks = [
|
|
109
|
+
Ms = [16, 32, 64]
|
|
110
|
+
Ns = [16, 32, 64]
|
|
111
|
+
Ks = [16, 32, 64]
|
|
111
112
|
batch_counts = [1, 4]
|
|
112
113
|
betas = [0.0, 1.0]
|
|
113
114
|
alpha = 1.0
|
|
114
115
|
|
|
115
|
-
for batch_count in batch_counts:
|
|
116
|
-
|
|
117
|
-
for n in Ns:
|
|
118
|
-
for k in Ks:
|
|
119
|
-
for beta in betas:
|
|
120
|
-
self.run_and_verify(m, n, k, batch_count, alpha, beta)
|
|
116
|
+
for batch_count, m, n, k, beta in itertools.product(batch_counts, Ms, Ns, Ks, betas):
|
|
117
|
+
self.run_and_verify(m, n, k, batch_count, alpha, beta)
|
|
121
118
|
|
|
122
119
|
|
|
123
120
|
class gemm_test_bed_runner_transpose:
|
warp/tests/test_matmul_lite.py
CHANGED
|
@@ -102,19 +102,14 @@ class gemm_test_bed_runner:
|
|
|
102
102
|
assert_np_equal(C.grad.numpy(), adj_C_np)
|
|
103
103
|
|
|
104
104
|
def run(self):
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
m = 8
|
|
106
|
+
n = 16
|
|
107
|
+
k = 32
|
|
108
|
+
batch_count = 1
|
|
109
|
+
beta = 1.0
|
|
110
110
|
alpha = 1.0
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
for m in Ms:
|
|
114
|
-
for n in Ns:
|
|
115
|
-
for k in Ks:
|
|
116
|
-
for beta in betas:
|
|
117
|
-
self.run_and_verify(m, n, k, batch_count, alpha, beta)
|
|
112
|
+
self.run_and_verify(m, n, k, batch_count, alpha, beta)
|
|
118
113
|
|
|
119
114
|
|
|
120
115
|
class gemm_test_bed_runner_transpose:
|
warp/tests/test_overwrite.py
CHANGED
|
@@ -507,6 +507,50 @@ def test_kernel_read_func_write(test, device):
|
|
|
507
507
|
wp.config.verify_autograd_array_access = saved_verify_autograd_array_access_setting
|
|
508
508
|
|
|
509
509
|
|
|
510
|
+
@wp.func
|
|
511
|
+
def atomic_func(
|
|
512
|
+
a: wp.array(dtype=wp.int32),
|
|
513
|
+
b: wp.array(dtype=wp.int32),
|
|
514
|
+
c: wp.array(dtype=wp.int32),
|
|
515
|
+
d: wp.array(dtype=wp.int32),
|
|
516
|
+
i: int,
|
|
517
|
+
):
|
|
518
|
+
wp.atomic_add(a, i, 1)
|
|
519
|
+
wp.atomic_sub(b, i, 1)
|
|
520
|
+
wp.atomic_min(c, i, 1)
|
|
521
|
+
wp.atomic_max(d, i, 3)
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
@wp.kernel(enable_backward=False)
|
|
525
|
+
def atomic_kernel(
|
|
526
|
+
a: wp.array(dtype=wp.int32), b: wp.array(dtype=wp.int32), c: wp.array(dtype=wp.int32), d: wp.array(dtype=wp.int32)
|
|
527
|
+
):
|
|
528
|
+
i = wp.tid()
|
|
529
|
+
atomic_func(a, b, c, d, i)
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
# atomic operations should mark arrays as WRITE
|
|
533
|
+
def test_atomic_operations(test, device):
|
|
534
|
+
saved_verify_autograd_array_access_setting = wp.config.verify_autograd_array_access
|
|
535
|
+
try:
|
|
536
|
+
wp.config.verify_autograd_array_access = True
|
|
537
|
+
|
|
538
|
+
a = wp.array((1, 2, 3), dtype=wp.int32, device=device)
|
|
539
|
+
b = wp.array((1, 2, 3), dtype=wp.int32, device=device)
|
|
540
|
+
c = wp.array((1, 2, 3), dtype=wp.int32, device=device)
|
|
541
|
+
d = wp.array((1, 2, 3), dtype=wp.int32, device=device)
|
|
542
|
+
|
|
543
|
+
wp.launch(atomic_kernel, dim=a.shape, inputs=(a, b, c, d), device=device)
|
|
544
|
+
|
|
545
|
+
test.assertEqual(atomic_kernel.adj.args[0].is_write, True)
|
|
546
|
+
test.assertEqual(atomic_kernel.adj.args[1].is_write, True)
|
|
547
|
+
test.assertEqual(atomic_kernel.adj.args[2].is_write, True)
|
|
548
|
+
test.assertEqual(atomic_kernel.adj.args[3].is_write, True)
|
|
549
|
+
|
|
550
|
+
finally:
|
|
551
|
+
wp.config.verify_autograd_array_access = saved_verify_autograd_array_access_setting
|
|
552
|
+
|
|
553
|
+
|
|
510
554
|
class TestOverwrite(unittest.TestCase):
|
|
511
555
|
pass
|
|
512
556
|
|
|
@@ -535,6 +579,7 @@ add_function_test(TestOverwrite, "test_reset", test_reset, devices=devices)
|
|
|
535
579
|
add_function_test(TestOverwrite, "test_copy", test_copy, devices=devices)
|
|
536
580
|
add_function_test(TestOverwrite, "test_matmul", test_matmul, devices=devices)
|
|
537
581
|
add_function_test(TestOverwrite, "test_batched_matmul", test_batched_matmul, devices=devices)
|
|
582
|
+
add_function_test(TestOverwrite, "test_atomic_operations", test_atomic_operations, devices=devices)
|
|
538
583
|
|
|
539
584
|
# Some warning are only issued during codegen, and codegen only runs on cuda_0 in the MGPU case.
|
|
540
585
|
cuda_device = get_cuda_test_devices(mode="basic")
|
warp/tests/test_smoothstep.py
CHANGED
|
@@ -31,15 +31,7 @@ class TestData:
|
|
|
31
31
|
|
|
32
32
|
TEST_DATA = {
|
|
33
33
|
wp.float32: (
|
|
34
|
-
TestData(
|
|
35
|
-
a=1.0,
|
|
36
|
-
b=2.0,
|
|
37
|
-
t=1.5,
|
|
38
|
-
expected=0.5,
|
|
39
|
-
expected_adj_a=-0.75,
|
|
40
|
-
expected_adj_b=-0.75,
|
|
41
|
-
expected_adj_t=1.5,
|
|
42
|
-
),
|
|
34
|
+
TestData(a=1.0, b=2.0, t=1.5, expected=0.5, expected_adj_a=-0.75, expected_adj_b=-0.75, expected_adj_t=1.5),
|
|
43
35
|
TestData(
|
|
44
36
|
a=-1.0,
|
|
45
37
|
b=2.0,
|
|
@@ -49,24 +41,8 @@ TEST_DATA = {
|
|
|
49
41
|
expected_adj_b=-0.09375,
|
|
50
42
|
expected_adj_t=0.375,
|
|
51
43
|
),
|
|
52
|
-
TestData(
|
|
53
|
-
|
|
54
|
-
b=1.0,
|
|
55
|
-
t=9.9,
|
|
56
|
-
expected=1.0,
|
|
57
|
-
expected_adj_a=0.0,
|
|
58
|
-
expected_adj_b=0.0,
|
|
59
|
-
expected_adj_t=0.0,
|
|
60
|
-
),
|
|
61
|
-
TestData(
|
|
62
|
-
a=0.0,
|
|
63
|
-
b=1.0,
|
|
64
|
-
t=-9.9,
|
|
65
|
-
expected=0.0,
|
|
66
|
-
expected_adj_a=0.0,
|
|
67
|
-
expected_adj_b=0.0,
|
|
68
|
-
expected_adj_t=0.0,
|
|
69
|
-
),
|
|
44
|
+
TestData(a=0.0, b=1.0, t=9.9, expected=1.0, expected_adj_a=0.0, expected_adj_b=0.0, expected_adj_t=0.0),
|
|
45
|
+
TestData(a=0.0, b=1.0, t=-9.9, expected=0.0, expected_adj_a=0.0, expected_adj_b=0.0, expected_adj_t=0.0),
|
|
70
46
|
),
|
|
71
47
|
}
|
|
72
48
|
|
|
@@ -83,72 +59,30 @@ def test_smoothstep(test, device):
|
|
|
83
59
|
|
|
84
60
|
return fn
|
|
85
61
|
|
|
86
|
-
for data_type in TEST_DATA:
|
|
62
|
+
for data_type, test_data_set in TEST_DATA.items():
|
|
87
63
|
kernel_fn = make_kernel_fn(data_type)
|
|
88
64
|
kernel = wp.Kernel(
|
|
89
65
|
func=kernel_fn,
|
|
90
66
|
key=f"test_smoothstep{data_type.__name__}_kernel",
|
|
91
67
|
)
|
|
92
68
|
|
|
93
|
-
for test_data in
|
|
94
|
-
a = wp.array(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
device=device,
|
|
104
|
-
requires_grad=True,
|
|
105
|
-
)
|
|
106
|
-
t = wp.array(
|
|
107
|
-
[test_data.t],
|
|
108
|
-
dtype=float,
|
|
109
|
-
device=device,
|
|
110
|
-
requires_grad=True,
|
|
111
|
-
)
|
|
112
|
-
out = wp.array(
|
|
113
|
-
[0] * wp.types.type_length(data_type),
|
|
114
|
-
dtype=data_type,
|
|
115
|
-
device=device,
|
|
116
|
-
requires_grad=True,
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
tape = wp.Tape()
|
|
120
|
-
with tape:
|
|
121
|
-
wp.launch(
|
|
122
|
-
kernel,
|
|
123
|
-
dim=1,
|
|
124
|
-
inputs=[a, b, t, out],
|
|
125
|
-
device=device,
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
assert_np_equal(
|
|
129
|
-
out.numpy(),
|
|
130
|
-
np.array([test_data.expected]),
|
|
131
|
-
tol=1e-6,
|
|
132
|
-
)
|
|
69
|
+
for test_data in test_data_set:
|
|
70
|
+
a = wp.array([test_data.a], dtype=data_type, device=device, requires_grad=True)
|
|
71
|
+
b = wp.array([test_data.b], dtype=data_type, device=device, requires_grad=True)
|
|
72
|
+
t = wp.array([test_data.t], dtype=float, device=device, requires_grad=True)
|
|
73
|
+
out = wp.array([0] * wp.types.type_length(data_type), dtype=data_type, device=device, requires_grad=True)
|
|
74
|
+
|
|
75
|
+
with wp.Tape() as tape:
|
|
76
|
+
wp.launch(kernel, dim=1, inputs=[a, b, t, out], device=device)
|
|
77
|
+
|
|
78
|
+
assert_np_equal(out.numpy(), np.array([test_data.expected]), tol=1e-6)
|
|
133
79
|
|
|
134
80
|
if test_data.check_backwards():
|
|
135
81
|
tape.backward(out)
|
|
136
82
|
|
|
137
|
-
assert_np_equal(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
tol=1e-6,
|
|
141
|
-
)
|
|
142
|
-
assert_np_equal(
|
|
143
|
-
tape.gradients[b].numpy(),
|
|
144
|
-
np.array([test_data.expected_adj_b]),
|
|
145
|
-
tol=1e-6,
|
|
146
|
-
)
|
|
147
|
-
assert_np_equal(
|
|
148
|
-
tape.gradients[t].numpy(),
|
|
149
|
-
np.array([test_data.expected_adj_t]),
|
|
150
|
-
tol=1e-6,
|
|
151
|
-
)
|
|
83
|
+
assert_np_equal(tape.gradients[a].numpy(), np.array([test_data.expected_adj_a]), tol=1e-6)
|
|
84
|
+
assert_np_equal(tape.gradients[b].numpy(), np.array([test_data.expected_adj_b]), tol=1e-6)
|
|
85
|
+
assert_np_equal(tape.gradients[t].numpy(), np.array([test_data.expected_adj_t]), tol=1e-6)
|
|
152
86
|
|
|
153
87
|
|
|
154
88
|
devices = get_test_devices()
|
warp/tests/test_static.py
CHANGED
|
@@ -281,20 +281,20 @@ def test_function_lookup(test, device):
|
|
|
281
281
|
|
|
282
282
|
outputs = wp.empty(2, dtype=wp.float32)
|
|
283
283
|
|
|
284
|
-
for
|
|
284
|
+
for _op, op_func in op_handlers.items():
|
|
285
285
|
|
|
286
286
|
@wp.kernel
|
|
287
287
|
def operate(input: wp.array(dtype=inputs.dtype, ndim=2), output: wp.array(dtype=wp.float32)):
|
|
288
288
|
tid = wp.tid()
|
|
289
289
|
a, b = input[tid, 0], input[tid, 1]
|
|
290
290
|
# retrieve the right function to use for the captured dtype variable
|
|
291
|
-
output[tid] = wp.static(
|
|
291
|
+
output[tid] = wp.static(op_func)(a, b) # noqa: B023
|
|
292
292
|
|
|
293
293
|
wp.launch(operate, dim=2, inputs=[inputs], outputs=[outputs])
|
|
294
294
|
outputs_np = outputs.numpy()
|
|
295
295
|
inputs_np = inputs.numpy()
|
|
296
296
|
for i in range(len(outputs_np)):
|
|
297
|
-
test.assertEqual(outputs_np[i],
|
|
297
|
+
test.assertEqual(outputs_np[i], op_func(float(inputs_np[i][0]), float(inputs_np[i][1])))
|
|
298
298
|
|
|
299
299
|
|
|
300
300
|
def count_ssa_occurrences(kernel: wp.Kernel, ssas: List[str]) -> Dict[str, int]:
|
warp/tests/test_tile.py
CHANGED
|
@@ -398,6 +398,49 @@ def test_tile_sum(test, device):
|
|
|
398
398
|
assert_np_equal(input_wp.grad.numpy(), np.ones_like(input) * 0.5)
|
|
399
399
|
|
|
400
400
|
|
|
401
|
+
def test_tile_sum_launch(test, device):
|
|
402
|
+
batch_count = 56
|
|
403
|
+
|
|
404
|
+
M = TILE_M
|
|
405
|
+
N = TILE_N
|
|
406
|
+
|
|
407
|
+
rng = np.random.default_rng(42)
|
|
408
|
+
input = rng.random((batch_count, M, N), dtype=np.float32)
|
|
409
|
+
|
|
410
|
+
input_wp = wp.array(input, requires_grad=True, device=device)
|
|
411
|
+
output_wp = wp.zeros(batch_count, requires_grad=True, device=device)
|
|
412
|
+
|
|
413
|
+
cmd = wp.launch_tiled(
|
|
414
|
+
tile_sum_kernel,
|
|
415
|
+
dim=[batch_count],
|
|
416
|
+
inputs=[input_wp, output_wp],
|
|
417
|
+
block_dim=TILE_DIM,
|
|
418
|
+
device=device,
|
|
419
|
+
record_cmd=True,
|
|
420
|
+
)
|
|
421
|
+
cmd.launch()
|
|
422
|
+
|
|
423
|
+
sum_wp = output_wp.numpy()
|
|
424
|
+
|
|
425
|
+
for i in range(batch_count):
|
|
426
|
+
sum_np = np.sum(input[i]) * 0.5
|
|
427
|
+
test.assertAlmostEqual(sum_wp[i], sum_np, places=5)
|
|
428
|
+
|
|
429
|
+
output_wp.grad.fill_(1.0)
|
|
430
|
+
|
|
431
|
+
wp.launch_tiled(
|
|
432
|
+
tile_sum_kernel,
|
|
433
|
+
dim=[batch_count],
|
|
434
|
+
inputs=[input_wp, output_wp],
|
|
435
|
+
adj_inputs=[input_wp.grad, output_wp.grad],
|
|
436
|
+
block_dim=TILE_DIM,
|
|
437
|
+
device=device,
|
|
438
|
+
adjoint=True,
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
assert_np_equal(input_wp.grad.numpy(), np.ones_like(input) * 0.5)
|
|
442
|
+
|
|
443
|
+
|
|
401
444
|
@wp.kernel
|
|
402
445
|
def tile_extract_kernel(input: wp.array2d(dtype=float), output: wp.array2d(dtype=float)):
|
|
403
446
|
# output tile index
|
|
@@ -688,6 +731,7 @@ add_function_test(TestTile, "test_tile_transpose", test_tile_transpose, devices=
|
|
|
688
731
|
add_function_test(TestTile, "test_tile_transpose_matmul", test_tile_transpose_matmul, devices=devices)
|
|
689
732
|
add_function_test(TestTile, "test_tile_operators", test_tile_operators, devices=devices)
|
|
690
733
|
add_function_test(TestTile, "test_tile_sum", test_tile_sum, devices=devices)
|
|
734
|
+
add_function_test(TestTile, "test_tile_sum_launch", test_tile_sum_launch, devices=devices)
|
|
691
735
|
add_function_test(TestTile, "test_tile_extract", test_tile_extract, devices=devices)
|
|
692
736
|
add_function_test(TestTile, "test_tile_broadcast_add", test_tile_broadcast_add, devices=devices)
|
|
693
737
|
add_function_test(TestTile, "test_tile_broadcast_grad", test_tile_broadcast_grad, devices=devices)
|
warp/tests/unittest_utils.py
CHANGED
|
@@ -58,7 +58,6 @@ def get_selected_cuda_test_devices(mode: Optional[str] = None):
|
|
|
58
58
|
"""
|
|
59
59
|
|
|
60
60
|
if mode is None:
|
|
61
|
-
global test_mode
|
|
62
61
|
mode = test_mode
|
|
63
62
|
|
|
64
63
|
if mode == "basic":
|
|
@@ -98,7 +97,6 @@ def get_test_devices(mode: Optional[str] = None):
|
|
|
98
97
|
"all": Returns all available devices.
|
|
99
98
|
"""
|
|
100
99
|
if mode is None:
|
|
101
|
-
global test_mode
|
|
102
100
|
mode = test_mode
|
|
103
101
|
|
|
104
102
|
devices = []
|
warp/types.py
CHANGED
|
@@ -343,8 +343,8 @@ def matrix(shape, dtype):
|
|
|
343
343
|
f"Invalid argument in matrix constructor, expected row of length {self._shape_[1]}, got {row}"
|
|
344
344
|
)
|
|
345
345
|
offset = i * self._shape_[1]
|
|
346
|
-
for
|
|
347
|
-
super().__setitem__(offset +
|
|
346
|
+
for j in range(self._shape_[1]):
|
|
347
|
+
super().__setitem__(offset + j, mat_t.scalar_import(row[j]))
|
|
348
348
|
else:
|
|
349
349
|
raise ValueError(
|
|
350
350
|
f"Invalid number of arguments in matrix constructor, expected {self._length_} elements, got {num_args}"
|
warp/utils.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: warp-lang
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.1
|
|
4
4
|
Summary: A Python framework for high-performance simulation and graphics programming
|
|
5
5
|
Author-email: NVIDIA Corporation <mmacklin@nvidia.com>
|
|
6
6
|
License: NVIDIA Software License
|
|
@@ -78,9 +78,9 @@ the `pip install` command, e.g.
|
|
|
78
78
|
|
|
79
79
|
| Platform | Install Command |
|
|
80
80
|
| --------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
81
|
-
| Linux aarch64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.5.
|
|
82
|
-
| Linux x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.5.
|
|
83
|
-
| Windows x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.5.
|
|
81
|
+
| Linux aarch64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.5.1/warp_lang-1.5.1+cu11-py3-none-manylinux2014_aarch64.whl` |
|
|
82
|
+
| Linux x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.5.1/warp_lang-1.5.1+cu11-py3-none-manylinux2014_x86_64.whl` |
|
|
83
|
+
| Windows x86-64 | `pip install https://github.com/NVIDIA/warp/releases/download/v1.5.1/warp_lang-1.5.1+cu11-py3-none-win_amd64.whl` |
|
|
84
84
|
|
|
85
85
|
The `--force-reinstall` option may need to be used to overwrite a previous installation.
|
|
86
86
|
|
|
@@ -143,6 +143,30 @@ wp.launch(kernel=length,
|
|
|
143
143
|
print(lengths)
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
+
## Running Notebooks
|
|
147
|
+
|
|
148
|
+
A few notebooks are available in the [notebooks](./notebooks/) directory to provide an overview over the key features available in Warp.
|
|
149
|
+
|
|
150
|
+
To run these notebooks, ``jupyterlab`` is required to be installed using:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
pip install jupyterlab
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
From there, opening the notebooks can be done with the following command:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
jupyter lab ./notebooks
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
* [Warp Core Tutorial: Basics](./notebooks/core_01_basics.ipynb) [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_01_basics.ipynb)
|
|
163
|
+
* [Warp Core Tutorial: Generics](./notebooks/core_02_generics.ipynb) [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_02_generics.ipynb)
|
|
164
|
+
* [Warp Core Tutorial: Points](./notebooks/core_03_points.ipynb) [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_03_points.ipynb)
|
|
165
|
+
* [Warp Core Tutorial: Meshes](./notebooks/core_04_meshes.ipynb) [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_04_meshes.ipynb)
|
|
166
|
+
* [Warp Core Tutorial: Volumes](./notebooks/core_05_volumes.ipynb) [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_05_volumes.ipynb)
|
|
167
|
+
* [Warp PyTorch Tutorial: Basics](./notebooks/pytorch_01_basics.ipynb) [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/pytorch_01_basics.ipynb)
|
|
168
|
+
* [Warp PyTorch Tutorial: Custom Operators](./notebooks/pytorch_02_custom_operators.ipynb) [](https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/pytorch_02_custom_operators.ipynb)
|
|
169
|
+
|
|
146
170
|
## Running Examples
|
|
147
171
|
|
|
148
172
|
The [warp/examples](./warp/examples/) directory contains a number of scripts categorized under subdirectories
|
|
@@ -330,31 +354,6 @@ python -m warp.tests
|
|
|
330
354
|
</tbody>
|
|
331
355
|
</table>
|
|
332
356
|
|
|
333
|
-
## Running Notebooks
|
|
334
|
-
|
|
335
|
-
A few notebooks are available in the [notebooks](./notebooks/) directory to provide an overview over the key features available in Warp.
|
|
336
|
-
|
|
337
|
-
To run these notebooks, ``jupyterlab`` is required to be installed using:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
```text
|
|
341
|
-
pip install jupyterlab
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
From there, opening the notebooks can be done with the following command:
|
|
345
|
-
|
|
346
|
-
```text
|
|
347
|
-
jupyter lab ./notebooks
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
- [Warp Core Tutorial: Basics](https://github.com/NVIDIA/warp/tree/main/warp/notebooks/core_01_basics.ipynb) <a target="_blank" href="https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/core_01_basics.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
|
351
|
-
- [Warp Core Tutorial: Generics](https://github.com/NVIDIA/warp/tree/main/warp/notebooks/core_02_generics.ipynb) <a target="_blank" href="https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/notebooks/core_02_generics.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
|
352
|
-
- [Warp Core Tutorial: Points](https://github.com/NVIDIA/warp/tree/main/warp/notebooks/core_03_points.ipynb) <a target="_blank" href="https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/notebooks/core_03_points.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
|
353
|
-
- [Warp Core Tutorial: Meshes](https://github.com/NVIDIA/warp/tree/main/warp/notebooks/core_04_meshes.ipynb) <a target="_blank" href="https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/notebooks/core_04_meshes.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
|
354
|
-
- [Warp Core Tutorial: Volumes](https://github.com/NVIDIA/warp/tree/main/warp/notebooks/core_05_volumes.ipynb) <a target="_blank" href="https://colab.research.google.com/github/NVIDIA/warp/blob/main/notebooks/notebooks/core_05_volumes.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
357
|
## Building
|
|
359
358
|
|
|
360
359
|
For developers who want to build the library themselves, the following tools are required:
|