warp-lang 1.3.3__py3-none-manylinux2014_aarch64.whl → 1.4.0__py3-none-manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/__init__.py +6 -0
- warp/autograd.py +59 -6
- warp/bin/warp.so +0 -0
- warp/build_dll.py +8 -10
- warp/builtins.py +126 -4
- warp/codegen.py +435 -53
- warp/config.py +1 -1
- warp/context.py +678 -403
- warp/dlpack.py +2 -0
- warp/examples/benchmarks/benchmark_cloth.py +10 -0
- warp/examples/core/example_render_opengl.py +12 -10
- warp/examples/fem/example_adaptive_grid.py +251 -0
- warp/examples/fem/example_apic_fluid.py +1 -1
- warp/examples/fem/example_diffusion_3d.py +2 -2
- warp/examples/fem/example_magnetostatics.py +1 -1
- warp/examples/fem/example_streamlines.py +1 -0
- warp/examples/fem/utils.py +23 -4
- warp/examples/sim/example_cloth.py +50 -6
- warp/fem/__init__.py +2 -0
- warp/fem/adaptivity.py +493 -0
- warp/fem/field/field.py +2 -1
- warp/fem/field/nodal_field.py +18 -26
- warp/fem/field/test.py +4 -4
- warp/fem/field/trial.py +4 -4
- warp/fem/geometry/__init__.py +1 -0
- warp/fem/geometry/adaptive_nanogrid.py +843 -0
- warp/fem/geometry/nanogrid.py +55 -28
- warp/fem/space/__init__.py +1 -1
- warp/fem/space/nanogrid_function_space.py +69 -35
- warp/fem/utils.py +113 -107
- warp/jax_experimental.py +28 -15
- warp/native/array.h +0 -1
- warp/native/builtin.h +103 -6
- warp/native/bvh.cu +2 -0
- warp/native/cuda_util.cpp +14 -0
- warp/native/cuda_util.h +2 -0
- warp/native/error.cpp +4 -2
- warp/native/exports.h +99 -17
- warp/native/mat.h +97 -0
- warp/native/mesh.cpp +36 -0
- warp/native/mesh.cu +51 -0
- warp/native/mesh.h +1 -0
- warp/native/quat.h +43 -0
- warp/native/spatial.h +6 -0
- warp/native/vec.h +74 -0
- warp/native/warp.cpp +2 -1
- warp/native/warp.cu +10 -3
- warp/native/warp.h +8 -1
- warp/paddle.py +382 -0
- warp/sim/__init__.py +1 -0
- warp/sim/collide.py +519 -0
- warp/sim/integrator_euler.py +18 -5
- warp/sim/integrator_featherstone.py +5 -5
- warp/sim/integrator_vbd.py +1026 -0
- warp/sim/model.py +49 -23
- warp/stubs.py +459 -0
- warp/tape.py +2 -0
- warp/tests/aux_test_dependent.py +1 -0
- warp/tests/aux_test_name_clash1.py +32 -0
- warp/tests/aux_test_name_clash2.py +32 -0
- warp/tests/aux_test_square.py +1 -0
- warp/tests/test_array.py +188 -0
- warp/tests/test_async.py +3 -3
- warp/tests/test_atomic.py +6 -0
- warp/tests/test_closest_point_edge_edge.py +93 -1
- warp/tests/test_codegen.py +62 -15
- warp/tests/test_codegen_instancing.py +1457 -0
- warp/tests/test_collision.py +486 -0
- warp/tests/test_compile_consts.py +3 -28
- warp/tests/test_dlpack.py +170 -0
- warp/tests/test_examples.py +22 -8
- warp/tests/test_fast_math.py +10 -4
- warp/tests/test_fem.py +64 -0
- warp/tests/test_func.py +46 -0
- warp/tests/test_implicit_init.py +49 -0
- warp/tests/test_jax.py +58 -0
- warp/tests/test_mat.py +84 -0
- warp/tests/test_mesh_query_point.py +188 -0
- warp/tests/test_module_hashing.py +40 -0
- warp/tests/test_multigpu.py +3 -3
- warp/tests/test_overwrite.py +8 -0
- warp/tests/test_paddle.py +852 -0
- warp/tests/test_print.py +89 -0
- warp/tests/test_quat.py +111 -0
- warp/tests/test_reload.py +31 -1
- warp/tests/test_scalar_ops.py +2 -0
- warp/tests/test_static.py +412 -0
- warp/tests/test_streams.py +64 -3
- warp/tests/test_struct.py +4 -4
- warp/tests/test_torch.py +24 -0
- warp/tests/test_triangle_closest_point.py +137 -0
- warp/tests/test_types.py +1 -1
- warp/tests/test_vbd.py +386 -0
- warp/tests/test_vec.py +143 -0
- warp/tests/test_vec_scalar_ops.py +139 -0
- warp/tests/unittest_suites.py +12 -0
- warp/tests/unittest_utils.py +9 -5
- warp/thirdparty/dlpack.py +3 -1
- warp/types.py +150 -28
- warp/utils.py +37 -14
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/METADATA +10 -8
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/RECORD +105 -93
- warp/tests/test_point_triangle_closest_point.py +0 -143
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/WHEEL +0 -0
- {warp_lang-1.3.3.dist-info → warp_lang-1.4.0.dist-info}/top_level.txt +0 -0
warp/tests/test_print.py
CHANGED
|
@@ -20,6 +20,30 @@ def test_print_kernel():
|
|
|
20
20
|
wp.printf("this is an int %d\n", 123)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
@wp.kernel
|
|
24
|
+
def test_print_numeric_kernel(value: int):
|
|
25
|
+
# signed ints
|
|
26
|
+
wp.print(wp.int8(value))
|
|
27
|
+
wp.print(wp.int16(value))
|
|
28
|
+
wp.print(wp.int32(value))
|
|
29
|
+
wp.print(wp.int64(value))
|
|
30
|
+
# unsigned ints
|
|
31
|
+
wp.print(wp.uint8(value))
|
|
32
|
+
wp.print(wp.uint16(value))
|
|
33
|
+
wp.print(wp.uint32(value))
|
|
34
|
+
wp.print(wp.uint64(value))
|
|
35
|
+
# floats
|
|
36
|
+
wp.print(wp.float16(value))
|
|
37
|
+
wp.print(wp.float32(value))
|
|
38
|
+
wp.print(wp.float64(value))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@wp.kernel
|
|
42
|
+
def test_print_boolean_kernel(value: wp.bool):
|
|
43
|
+
wp.print(value)
|
|
44
|
+
wp.print(not value)
|
|
45
|
+
|
|
46
|
+
|
|
23
47
|
def test_print(test, device):
|
|
24
48
|
wp.load_module(device=device)
|
|
25
49
|
capture = StdOutCapture()
|
|
@@ -39,12 +63,77 @@ def test_print(test, device):
|
|
|
39
63
|
)
|
|
40
64
|
|
|
41
65
|
|
|
66
|
+
def test_print_numeric(test, device):
|
|
67
|
+
wp.load_module(device=device)
|
|
68
|
+
|
|
69
|
+
capture = StdOutCapture()
|
|
70
|
+
capture.begin()
|
|
71
|
+
wp.launch(kernel=test_print_numeric_kernel, dim=1, inputs=[17], device=device)
|
|
72
|
+
wp.synchronize_device(device)
|
|
73
|
+
s = capture.end()
|
|
74
|
+
|
|
75
|
+
# We skip the win32 comparison for now since the capture sometimes is an empty string
|
|
76
|
+
if sys.platform != "win32":
|
|
77
|
+
test.assertRegex(
|
|
78
|
+
s,
|
|
79
|
+
rf"17{os.linesep}"
|
|
80
|
+
rf"17{os.linesep}"
|
|
81
|
+
rf"17{os.linesep}"
|
|
82
|
+
rf"17{os.linesep}"
|
|
83
|
+
rf"17{os.linesep}"
|
|
84
|
+
rf"17{os.linesep}"
|
|
85
|
+
rf"17{os.linesep}"
|
|
86
|
+
rf"17{os.linesep}"
|
|
87
|
+
rf"17{os.linesep}"
|
|
88
|
+
rf"17{os.linesep}"
|
|
89
|
+
rf"17{os.linesep}",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
capture = StdOutCapture()
|
|
93
|
+
capture.begin()
|
|
94
|
+
wp.launch(kernel=test_print_numeric_kernel, dim=1, inputs=[-1], device=device)
|
|
95
|
+
wp.synchronize_device(device)
|
|
96
|
+
s = capture.end()
|
|
97
|
+
|
|
98
|
+
# We skip the win32 comparison for now since the capture sometimes is an empty string
|
|
99
|
+
if sys.platform != "win32":
|
|
100
|
+
test.assertRegex(
|
|
101
|
+
s,
|
|
102
|
+
rf"-1{os.linesep}"
|
|
103
|
+
rf"-1{os.linesep}"
|
|
104
|
+
rf"-1{os.linesep}"
|
|
105
|
+
rf"-1{os.linesep}"
|
|
106
|
+
rf"255{os.linesep}"
|
|
107
|
+
rf"65535{os.linesep}"
|
|
108
|
+
rf"4294967295{os.linesep}"
|
|
109
|
+
rf"18446744073709551615{os.linesep}"
|
|
110
|
+
rf"-1{os.linesep}"
|
|
111
|
+
rf"-1{os.linesep}"
|
|
112
|
+
rf"-1{os.linesep}",
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_print_boolean(test, device):
|
|
117
|
+
wp.load_module(device=device)
|
|
118
|
+
capture = StdOutCapture()
|
|
119
|
+
capture.begin()
|
|
120
|
+
wp.launch(kernel=test_print_boolean_kernel, dim=1, inputs=[True], device=device)
|
|
121
|
+
wp.synchronize_device(device)
|
|
122
|
+
s = capture.end()
|
|
123
|
+
|
|
124
|
+
# We skip the win32 comparison for now since the capture sometimes is an empty string
|
|
125
|
+
if sys.platform != "win32":
|
|
126
|
+
test.assertRegex(s, rf"True{os.linesep}False{os.linesep}")
|
|
127
|
+
|
|
128
|
+
|
|
42
129
|
class TestPrint(unittest.TestCase):
|
|
43
130
|
pass
|
|
44
131
|
|
|
45
132
|
|
|
46
133
|
devices = get_test_devices()
|
|
47
134
|
add_function_test(TestPrint, "test_print", test_print, devices=devices, check_output=False)
|
|
135
|
+
add_function_test(TestPrint, "test_print_numeric", test_print_numeric, devices=devices, check_output=False)
|
|
136
|
+
add_function_test(TestPrint, "test_print_boolean", test_print_boolean, devices=devices, check_output=False)
|
|
48
137
|
|
|
49
138
|
|
|
50
139
|
if __name__ == "__main__":
|
warp/tests/test_quat.py
CHANGED
|
@@ -1886,6 +1886,110 @@ def test_quat_identity(test, device, dtype, register_kernels=False):
|
|
|
1886
1886
|
############################################################
|
|
1887
1887
|
|
|
1888
1888
|
|
|
1889
|
+
def test_quat_assign(test, device, dtype, register_kernels=False):
|
|
1890
|
+
np_type = np.dtype(dtype)
|
|
1891
|
+
wp_type = wp.types.np_dtype_to_warp_type[np_type]
|
|
1892
|
+
|
|
1893
|
+
quat = wp.types.quaternion(dtype=wp_type)
|
|
1894
|
+
|
|
1895
|
+
def quattest_read_write_store(x: wp.array(dtype=wp_type), a: wp.array(dtype=quat)):
|
|
1896
|
+
tid = wp.tid()
|
|
1897
|
+
|
|
1898
|
+
t = a[tid]
|
|
1899
|
+
t[0] = x[tid]
|
|
1900
|
+
a[tid] = t
|
|
1901
|
+
|
|
1902
|
+
def quattest_in_register(x: wp.array(dtype=wp_type), a: wp.array(dtype=quat)):
|
|
1903
|
+
tid = wp.tid()
|
|
1904
|
+
|
|
1905
|
+
g = wp_type(0.0)
|
|
1906
|
+
q = a[tid]
|
|
1907
|
+
g = q[0] + wp_type(2.0) * q[1] + wp_type(3.0) * q[2] + wp_type(4.0) * q[3]
|
|
1908
|
+
x[tid] = g
|
|
1909
|
+
|
|
1910
|
+
def quattest_in_register_overwrite(x: wp.array(dtype=quat), a: wp.array(dtype=quat)):
|
|
1911
|
+
tid = wp.tid()
|
|
1912
|
+
|
|
1913
|
+
f = quat()
|
|
1914
|
+
a_quat = a[tid]
|
|
1915
|
+
f = a_quat
|
|
1916
|
+
f[1] = wp_type(3.0)
|
|
1917
|
+
|
|
1918
|
+
x[tid] = f
|
|
1919
|
+
|
|
1920
|
+
def quattest_component(x: wp.array(dtype=quat), y: wp.array(dtype=wp_type)):
|
|
1921
|
+
i = wp.tid()
|
|
1922
|
+
|
|
1923
|
+
a = quat()
|
|
1924
|
+
a.x = wp_type(1.0) * y[i]
|
|
1925
|
+
a.y = wp_type(2.0) * y[i]
|
|
1926
|
+
a.z = wp_type(3.0) * y[i]
|
|
1927
|
+
a.w = wp_type(4.0) * y[i]
|
|
1928
|
+
x[i] = a
|
|
1929
|
+
|
|
1930
|
+
kernel_read_write_store = getkernel(quattest_read_write_store, suffix=dtype.__name__)
|
|
1931
|
+
kernel_in_register = getkernel(quattest_in_register, suffix=dtype.__name__)
|
|
1932
|
+
kernel_in_register_overwrite = getkernel(quattest_in_register_overwrite, suffix=dtype.__name__)
|
|
1933
|
+
kernel_component = getkernel(quattest_component, suffix=dtype.__name__)
|
|
1934
|
+
|
|
1935
|
+
if register_kernels:
|
|
1936
|
+
return
|
|
1937
|
+
|
|
1938
|
+
a = wp.ones(1, dtype=quat, device=device, requires_grad=True)
|
|
1939
|
+
x = wp.full(1, value=2.0, dtype=wp_type, device=device, requires_grad=True)
|
|
1940
|
+
|
|
1941
|
+
tape = wp.Tape()
|
|
1942
|
+
with tape:
|
|
1943
|
+
wp.launch(kernel_read_write_store, dim=1, inputs=[x, a], device=device)
|
|
1944
|
+
|
|
1945
|
+
tape.backward(grads={a: wp.ones_like(a, requires_grad=False)})
|
|
1946
|
+
|
|
1947
|
+
assert_np_equal(a.numpy(), np.array([[2.0, 1.0, 1.0, 1.0]], dtype=np_type))
|
|
1948
|
+
assert_np_equal(x.grad.numpy(), np.array([1.0], dtype=np_type))
|
|
1949
|
+
|
|
1950
|
+
tape.reset()
|
|
1951
|
+
|
|
1952
|
+
a = wp.ones(1, dtype=quat, device=device, requires_grad=True)
|
|
1953
|
+
x = wp.zeros(1, dtype=wp_type, device=device, requires_grad=True)
|
|
1954
|
+
|
|
1955
|
+
with tape:
|
|
1956
|
+
wp.launch(kernel_in_register, dim=1, inputs=[x, a], device=device)
|
|
1957
|
+
|
|
1958
|
+
tape.backward(grads={x: wp.ones_like(x, requires_grad=False)})
|
|
1959
|
+
|
|
1960
|
+
assert_np_equal(x.numpy(), np.array([10.0], dtype=np_type))
|
|
1961
|
+
assert_np_equal(a.grad.numpy(), np.array([[1.0, 2.0, 3.0, 4.0]], dtype=np_type))
|
|
1962
|
+
|
|
1963
|
+
tape.reset()
|
|
1964
|
+
|
|
1965
|
+
x = wp.zeros(1, dtype=quat, requires_grad=True)
|
|
1966
|
+
y = wp.ones(1, dtype=wp_type, requires_grad=True)
|
|
1967
|
+
|
|
1968
|
+
tape = wp.Tape()
|
|
1969
|
+
with tape:
|
|
1970
|
+
wp.launch(kernel_component, dim=1, inputs=[x, y])
|
|
1971
|
+
|
|
1972
|
+
tape.backward(grads={x: wp.ones_like(x, requires_grad=False)})
|
|
1973
|
+
|
|
1974
|
+
assert_np_equal(x.numpy(), np.array([[1.0, 2.0, 3.0, 4.0]], dtype=np_type))
|
|
1975
|
+
assert_np_equal(y.grad.numpy(), np.array([10.0], dtype=np_type))
|
|
1976
|
+
|
|
1977
|
+
x = wp.zeros(1, dtype=quat, device=device, requires_grad=True)
|
|
1978
|
+
a = wp.ones(1, dtype=quat, device=device, requires_grad=True)
|
|
1979
|
+
|
|
1980
|
+
tape = wp.Tape()
|
|
1981
|
+
with tape:
|
|
1982
|
+
wp.launch(kernel_in_register_overwrite, dim=1, inputs=[x, a], device=device)
|
|
1983
|
+
|
|
1984
|
+
tape.backward(grads={x: wp.ones_like(x, requires_grad=False)})
|
|
1985
|
+
|
|
1986
|
+
assert_np_equal(x.numpy(), np.array([[1.0, 3.0, 1.0, 1.0]], dtype=np_type))
|
|
1987
|
+
assert_np_equal(a.grad.numpy(), np.array([[1.0, 0.0, 1.0, 1.0]], dtype=np_type))
|
|
1988
|
+
|
|
1989
|
+
|
|
1990
|
+
############################################################
|
|
1991
|
+
|
|
1992
|
+
|
|
1889
1993
|
def test_quat_euler_conversion(test, device, dtype, register_kernels=False):
|
|
1890
1994
|
rng = np.random.default_rng(123)
|
|
1891
1995
|
N = 3
|
|
@@ -2088,6 +2192,13 @@ for dtype in np_float_types:
|
|
|
2088
2192
|
devices=devices,
|
|
2089
2193
|
dtype=dtype,
|
|
2090
2194
|
)
|
|
2195
|
+
add_function_test_register_kernel(
|
|
2196
|
+
TestQuat,
|
|
2197
|
+
f"test_quat_assign_{dtype.__name__}",
|
|
2198
|
+
test_quat_assign,
|
|
2199
|
+
devices=devices,
|
|
2200
|
+
dtype=dtype,
|
|
2201
|
+
)
|
|
2091
2202
|
add_function_test(
|
|
2092
2203
|
TestQuat, f"test_py_arithmetic_ops_{dtype.__name__}", test_py_arithmetic_ops, devices=None, dtype=dtype
|
|
2093
2204
|
)
|
warp/tests/test_reload.py
CHANGED
|
@@ -64,6 +64,32 @@ def test_redefine(test, device):
|
|
|
64
64
|
assert_np_equal(np.arange(0, n, 1) * 2.0, y.numpy())
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
def test_redefine_command(test, device):
|
|
68
|
+
# Test whether executable modules are retained correctly.
|
|
69
|
+
# A module can have multiple executable versions in use if something
|
|
70
|
+
# still holds a reference to them.
|
|
71
|
+
|
|
72
|
+
@wp.kernel
|
|
73
|
+
def k(value: int):
|
|
74
|
+
wp.expect_eq(value, 17)
|
|
75
|
+
|
|
76
|
+
# record a command
|
|
77
|
+
cmd1 = wp.launch(k, dim=1, inputs=[17], device=device, record_cmd=True)
|
|
78
|
+
cmd1.launch()
|
|
79
|
+
|
|
80
|
+
# redefine the kernel, triggering module reload
|
|
81
|
+
@wp.kernel
|
|
82
|
+
def k(value: int):
|
|
83
|
+
wp.expect_eq(value, 42)
|
|
84
|
+
|
|
85
|
+
# re-record the command
|
|
86
|
+
cmd2 = wp.launch(k, dim=1, inputs=[42], device=device, record_cmd=True)
|
|
87
|
+
cmd2.launch()
|
|
88
|
+
|
|
89
|
+
# previous command should still work
|
|
90
|
+
cmd1.launch()
|
|
91
|
+
|
|
92
|
+
|
|
67
93
|
square_two = """import warp as wp
|
|
68
94
|
|
|
69
95
|
|
|
@@ -79,6 +105,7 @@ def kern(expect: float):
|
|
|
79
105
|
|
|
80
106
|
def run(expect, device):
|
|
81
107
|
wp.launch(kern, dim=1, inputs=[expect], device=device)
|
|
108
|
+
wp.synchronize_device(device)
|
|
82
109
|
"""
|
|
83
110
|
|
|
84
111
|
square_four = """import warp as wp
|
|
@@ -96,6 +123,7 @@ def kern(expect: float):
|
|
|
96
123
|
|
|
97
124
|
def run(expect, device):
|
|
98
125
|
wp.launch(kern, dim=1, inputs=[expect], device=device)
|
|
126
|
+
wp.synchronize_device(device)
|
|
99
127
|
"""
|
|
100
128
|
|
|
101
129
|
|
|
@@ -222,9 +250,11 @@ class TestReload(unittest.TestCase):
|
|
|
222
250
|
|
|
223
251
|
|
|
224
252
|
add_function_test(TestReload, "test_redefine", test_redefine, devices=devices)
|
|
253
|
+
add_function_test(TestReload, "test_redefine_command", test_redefine_command, devices=devices)
|
|
225
254
|
add_function_test(TestReload, "test_reload", test_reload, devices=devices)
|
|
226
255
|
add_function_test(TestReload, "test_reload_class", test_reload_class, devices=devices)
|
|
227
|
-
|
|
256
|
+
# TODO: test_reload_references sometimes has issues running on cuda:1
|
|
257
|
+
add_function_test(TestReload, "test_reload_references", test_reload_references, devices=get_test_devices("basic"))
|
|
228
258
|
add_function_test(
|
|
229
259
|
TestReload, "test_graph_launch_after_module_reload", test_graph_launch_after_module_reload, devices=cuda_devices
|
|
230
260
|
)
|
warp/tests/test_scalar_ops.py
CHANGED
|
@@ -50,12 +50,14 @@ def test_py_arithmetic_ops(test, device, dtype):
|
|
|
50
50
|
test.assertAlmostEqual(-a, make_scalar(-1))
|
|
51
51
|
test.assertAlmostEqual(a + wptype(5), make_scalar(6))
|
|
52
52
|
test.assertAlmostEqual(a - wptype(5), make_scalar(-4))
|
|
53
|
+
test.assertAlmostEqual(a % wptype(2), make_scalar(1))
|
|
53
54
|
|
|
54
55
|
a = wptype(2)
|
|
55
56
|
test.assertAlmostEqual(a * wptype(2), make_scalar(4))
|
|
56
57
|
test.assertAlmostEqual(wptype(2) * a, make_scalar(4))
|
|
57
58
|
test.assertAlmostEqual(a / wptype(2), make_scalar(1))
|
|
58
59
|
test.assertAlmostEqual(wptype(24) / a, make_scalar(12))
|
|
60
|
+
test.assertAlmostEqual(a % wptype(2), make_scalar(0))
|
|
59
61
|
|
|
60
62
|
|
|
61
63
|
def test_py_math_ops(test, device, dtype):
|