warp-lang 1.1.0__py3-none-macosx_10_13_universal2.whl → 1.2.0__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.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/bin/libwarp-clang.dylib +0 -0
- warp/bin/libwarp.dylib +0 -0
- warp/build.py +10 -37
- warp/build_dll.py +2 -2
- warp/builtins.py +274 -6
- warp/codegen.py +51 -4
- warp/config.py +2 -2
- warp/constants.py +4 -0
- warp/context.py +418 -203
- warp/examples/benchmarks/benchmark_api.py +0 -2
- warp/examples/benchmarks/benchmark_cloth_warp.py +0 -1
- warp/examples/benchmarks/benchmark_launches.py +0 -2
- warp/examples/core/example_dem.py +0 -2
- warp/examples/core/example_fluid.py +0 -2
- warp/examples/core/example_graph_capture.py +0 -2
- warp/examples/core/example_marching_cubes.py +0 -2
- warp/examples/core/example_mesh.py +0 -2
- warp/examples/core/example_mesh_intersect.py +0 -2
- warp/examples/core/example_nvdb.py +0 -2
- warp/examples/core/example_raycast.py +0 -2
- warp/examples/core/example_raymarch.py +0 -2
- warp/examples/core/example_render_opengl.py +0 -2
- warp/examples/core/example_sph.py +0 -2
- warp/examples/core/example_torch.py +0 -3
- warp/examples/core/example_wave.py +0 -2
- warp/examples/fem/example_apic_fluid.py +140 -115
- warp/examples/fem/example_burgers.py +262 -0
- warp/examples/fem/example_convection_diffusion.py +0 -2
- warp/examples/fem/example_convection_diffusion_dg.py +0 -2
- warp/examples/fem/example_deformed_geometry.py +0 -2
- warp/examples/fem/example_diffusion.py +0 -2
- warp/examples/fem/example_diffusion_3d.py +5 -4
- warp/examples/fem/example_diffusion_mgpu.py +0 -2
- warp/examples/fem/example_mixed_elasticity.py +0 -2
- warp/examples/fem/example_navier_stokes.py +0 -2
- warp/examples/fem/example_stokes.py +0 -2
- warp/examples/fem/example_stokes_transfer.py +0 -2
- warp/examples/optim/example_bounce.py +0 -2
- warp/examples/optim/example_cloth_throw.py +0 -2
- warp/examples/optim/example_diffray.py +0 -2
- warp/examples/optim/example_drone.py +0 -2
- warp/examples/optim/example_inverse_kinematics.py +0 -2
- warp/examples/optim/example_inverse_kinematics_torch.py +0 -2
- warp/examples/optim/example_spring_cage.py +0 -2
- warp/examples/optim/example_trajectory.py +0 -2
- warp/examples/optim/example_walker.py +0 -2
- warp/examples/sim/example_cartpole.py +0 -2
- warp/examples/sim/example_cloth.py +0 -2
- warp/examples/sim/example_granular.py +0 -2
- warp/examples/sim/example_granular_collision_sdf.py +0 -2
- warp/examples/sim/example_jacobian_ik.py +0 -2
- warp/examples/sim/example_particle_chain.py +0 -2
- warp/examples/sim/example_quadruped.py +0 -2
- warp/examples/sim/example_rigid_chain.py +0 -2
- warp/examples/sim/example_rigid_contact.py +0 -2
- warp/examples/sim/example_rigid_force.py +0 -2
- warp/examples/sim/example_rigid_gyroscopic.py +0 -2
- warp/examples/sim/example_rigid_soft_contact.py +0 -2
- warp/examples/sim/example_soft_body.py +0 -2
- warp/fem/__init__.py +1 -0
- warp/fem/cache.py +3 -1
- warp/fem/geometry/__init__.py +1 -0
- warp/fem/geometry/element.py +4 -0
- warp/fem/geometry/grid_3d.py +0 -4
- warp/fem/geometry/nanogrid.py +455 -0
- warp/fem/integrate.py +63 -9
- warp/fem/space/__init__.py +43 -158
- warp/fem/space/basis_space.py +34 -0
- warp/fem/space/collocated_function_space.py +1 -1
- warp/fem/space/grid_2d_function_space.py +13 -132
- warp/fem/space/grid_3d_function_space.py +16 -154
- warp/fem/space/hexmesh_function_space.py +37 -134
- warp/fem/space/nanogrid_function_space.py +202 -0
- warp/fem/space/quadmesh_2d_function_space.py +12 -119
- warp/fem/space/restriction.py +4 -1
- warp/fem/space/shape/__init__.py +77 -0
- warp/fem/space/shape/cube_shape_function.py +5 -15
- warp/fem/space/tetmesh_function_space.py +6 -76
- warp/fem/space/trimesh_2d_function_space.py +6 -76
- warp/native/array.h +12 -3
- warp/native/builtin.h +48 -5
- warp/native/bvh.cpp +14 -10
- warp/native/bvh.cu +23 -15
- warp/native/bvh.h +1 -0
- warp/native/clang/clang.cpp +2 -1
- warp/native/crt.cpp +11 -1
- warp/native/crt.h +18 -1
- warp/native/exports.h +187 -0
- warp/native/mat.h +47 -0
- warp/native/mesh.cpp +1 -1
- warp/native/mesh.cu +1 -2
- warp/native/nanovdb/GridHandle.h +366 -0
- warp/native/nanovdb/HostBuffer.h +590 -0
- warp/native/nanovdb/NanoVDB.h +3999 -2157
- warp/native/nanovdb/PNanoVDB.h +936 -99
- warp/native/quat.h +28 -1
- warp/native/rand.h +5 -1
- warp/native/vec.h +45 -1
- warp/native/volume.cpp +335 -103
- warp/native/volume.cu +39 -13
- warp/native/volume.h +725 -303
- warp/native/volume_builder.cu +381 -360
- warp/native/volume_builder.h +16 -1
- warp/native/volume_impl.h +61 -0
- warp/native/warp.cu +8 -2
- warp/native/warp.h +15 -7
- warp/render/render_opengl.py +191 -52
- warp/sim/integrator_featherstone.py +10 -3
- warp/sim/integrator_xpbd.py +16 -22
- warp/sparse.py +89 -27
- warp/stubs.py +83 -0
- warp/tests/assets/test_index_grid.nvdb +0 -0
- warp/tests/aux_test_dependent.py +0 -2
- warp/tests/aux_test_grad_customs.py +0 -2
- warp/tests/aux_test_reference.py +0 -2
- warp/tests/aux_test_reference_reference.py +0 -2
- warp/tests/aux_test_square.py +0 -2
- warp/tests/disabled_kinematics.py +0 -2
- warp/tests/test_adam.py +0 -2
- warp/tests/test_arithmetic.py +0 -36
- warp/tests/test_array.py +9 -11
- warp/tests/test_array_reduce.py +0 -2
- warp/tests/test_async.py +0 -2
- warp/tests/test_atomic.py +0 -2
- warp/tests/test_bool.py +58 -50
- warp/tests/test_builtins_resolution.py +0 -2
- warp/tests/test_bvh.py +0 -2
- warp/tests/test_closest_point_edge_edge.py +0 -1
- warp/tests/test_codegen.py +0 -4
- warp/tests/test_compile_consts.py +130 -10
- warp/tests/test_conditional.py +0 -2
- warp/tests/test_copy.py +0 -2
- warp/tests/test_ctypes.py +6 -8
- warp/tests/test_dense.py +0 -2
- warp/tests/test_devices.py +0 -2
- warp/tests/test_dlpack.py +9 -11
- warp/tests/test_examples.py +42 -39
- warp/tests/test_fabricarray.py +0 -3
- warp/tests/test_fast_math.py +0 -2
- warp/tests/test_fem.py +75 -54
- warp/tests/test_fp16.py +0 -2
- warp/tests/test_func.py +0 -2
- warp/tests/test_generics.py +27 -2
- warp/tests/test_grad.py +147 -8
- warp/tests/test_grad_customs.py +0 -2
- warp/tests/test_hash_grid.py +1 -3
- warp/tests/test_import.py +0 -2
- warp/tests/test_indexedarray.py +0 -2
- warp/tests/test_intersect.py +0 -2
- warp/tests/test_jax.py +0 -2
- warp/tests/test_large.py +11 -9
- warp/tests/test_launch.py +0 -2
- warp/tests/test_lerp.py +10 -54
- warp/tests/test_linear_solvers.py +3 -5
- warp/tests/test_lvalue.py +0 -2
- warp/tests/test_marching_cubes.py +0 -2
- warp/tests/test_mat.py +0 -2
- warp/tests/test_mat_lite.py +0 -2
- warp/tests/test_mat_scalar_ops.py +0 -2
- warp/tests/test_math.py +0 -2
- warp/tests/test_matmul.py +35 -37
- warp/tests/test_matmul_lite.py +29 -31
- warp/tests/test_mempool.py +0 -2
- warp/tests/test_mesh.py +0 -3
- warp/tests/test_mesh_query_aabb.py +0 -2
- warp/tests/test_mesh_query_point.py +0 -2
- warp/tests/test_mesh_query_ray.py +0 -2
- warp/tests/test_mlp.py +0 -2
- warp/tests/test_model.py +0 -2
- warp/tests/test_module_hashing.py +111 -0
- warp/tests/test_modules_lite.py +0 -3
- warp/tests/test_multigpu.py +0 -2
- warp/tests/test_noise.py +0 -4
- warp/tests/test_operators.py +0 -2
- warp/tests/test_options.py +0 -2
- warp/tests/test_peer.py +0 -2
- warp/tests/test_pinned.py +0 -2
- warp/tests/test_print.py +0 -2
- warp/tests/test_quat.py +0 -2
- warp/tests/test_rand.py +41 -5
- warp/tests/test_reload.py +0 -10
- warp/tests/test_rounding.py +0 -2
- warp/tests/test_runlength_encode.py +0 -2
- warp/tests/test_sim_grad.py +0 -2
- warp/tests/test_sim_kinematics.py +0 -2
- warp/tests/test_smoothstep.py +0 -2
- warp/tests/test_snippet.py +0 -2
- warp/tests/test_sparse.py +0 -2
- warp/tests/test_spatial.py +0 -2
- warp/tests/test_special_values.py +362 -0
- warp/tests/test_streams.py +0 -2
- warp/tests/test_struct.py +0 -2
- warp/tests/test_tape.py +0 -2
- warp/tests/test_torch.py +0 -2
- warp/tests/test_transient_module.py +0 -2
- warp/tests/test_types.py +0 -2
- warp/tests/test_utils.py +0 -2
- warp/tests/test_vec.py +0 -2
- warp/tests/test_vec_lite.py +0 -2
- warp/tests/test_vec_scalar_ops.py +0 -2
- warp/tests/test_verify_fp.py +0 -2
- warp/tests/test_volume.py +237 -13
- warp/tests/test_volume_write.py +86 -3
- warp/tests/unittest_serial.py +10 -9
- warp/tests/unittest_suites.py +6 -2
- warp/tests/unittest_utils.py +2 -171
- warp/tests/unused_test_misc.py +0 -2
- warp/tests/walkthrough_debug.py +1 -1
- warp/thirdparty/unittest_parallel.py +37 -40
- warp/types.py +514 -77
- {warp_lang-1.1.0.dist-info → warp_lang-1.2.0.dist-info}/METADATA +57 -30
- warp_lang-1.2.0.dist-info/RECORD +359 -0
- warp/examples/fem/example_convection_diffusion_dg0.py +0 -204
- warp/native/nanovdb/PNanoVDBWrite.h +0 -295
- warp_lang-1.1.0.dist-info/RECORD +0 -352
- {warp_lang-1.1.0.dist-info → warp_lang-1.2.0.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.1.0.dist-info → warp_lang-1.2.0.dist-info}/WHEEL +0 -0
- {warp_lang-1.1.0.dist-info → warp_lang-1.2.0.dist-info}/top_level.txt +0 -0
warp/tests/test_async.py
CHANGED
warp/tests/test_atomic.py
CHANGED
warp/tests/test_bool.py
CHANGED
|
@@ -12,8 +12,6 @@ import numpy as np
|
|
|
12
12
|
import warp as wp
|
|
13
13
|
from warp.tests.unittest_utils import *
|
|
14
14
|
|
|
15
|
-
wp.init()
|
|
16
|
-
|
|
17
15
|
TRUE_CONSTANT = wp.constant(True)
|
|
18
16
|
|
|
19
17
|
|
|
@@ -90,21 +88,23 @@ def test_bool_constant(test, device):
|
|
|
90
88
|
test.assertTrue(compile_constant_value.numpy()[0])
|
|
91
89
|
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
vec3bool = wp.vec(length=3, dtype=wp.bool)
|
|
92
|
+
bool_selector_vec = wp.constant(vec3bool([True, False, True]))
|
|
93
|
+
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
@wp.kernel
|
|
96
|
+
def sum_from_bool_vec(sum_array: wp.array(dtype=wp.int32)):
|
|
97
|
+
i = wp.tid()
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
if bool_selector_vec[0]:
|
|
100
|
+
sum_array[i] = sum_array[i] + 1
|
|
101
|
+
if bool_selector_vec[1]:
|
|
102
|
+
sum_array[i] = sum_array[i] + 2
|
|
103
|
+
if bool_selector_vec[2]:
|
|
104
|
+
sum_array[i] = sum_array[i] + 4
|
|
107
105
|
|
|
106
|
+
|
|
107
|
+
def test_bool_constant_vec(test, device):
|
|
108
108
|
result_array = wp.zeros(10, dtype=wp.int32, device=device)
|
|
109
109
|
|
|
110
110
|
wp.launch(sum_from_bool_vec, result_array.shape, inputs=[result_array], device=device)
|
|
@@ -112,23 +112,25 @@ def test_bool_constant_vec(test, device):
|
|
|
112
112
|
assert_np_equal(result_array.numpy(), np.full(result_array.shape, 5))
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
@wp.kernel
|
|
120
|
-
def sum_from_bool_mat(sum_array: wp.array(dtype=wp.int32)):
|
|
121
|
-
i = wp.tid()
|
|
122
|
-
|
|
123
|
-
if bool_selector_mat[0, 0]:
|
|
124
|
-
sum_array[i] = sum_array[i] + 1
|
|
125
|
-
if bool_selector_mat[0, 1]:
|
|
126
|
-
sum_array[i] = sum_array[i] + 2
|
|
127
|
-
if bool_selector_mat[1, 0]:
|
|
128
|
-
sum_array[i] = sum_array[i] + 4
|
|
129
|
-
if bool_selector_mat[1, 1]:
|
|
130
|
-
sum_array[i] = sum_array[i] + 8
|
|
115
|
+
mat22bool = wp.mat((2, 2), dtype=wp.bool)
|
|
116
|
+
bool_selector_mat = wp.constant(mat22bool([True, False, False, True]))
|
|
117
|
+
|
|
131
118
|
|
|
119
|
+
@wp.kernel
|
|
120
|
+
def sum_from_bool_mat(sum_array: wp.array(dtype=wp.int32)):
|
|
121
|
+
i = wp.tid()
|
|
122
|
+
|
|
123
|
+
if bool_selector_mat[0, 0]:
|
|
124
|
+
sum_array[i] = sum_array[i] + 1
|
|
125
|
+
if bool_selector_mat[0, 1]:
|
|
126
|
+
sum_array[i] = sum_array[i] + 2
|
|
127
|
+
if bool_selector_mat[1, 0]:
|
|
128
|
+
sum_array[i] = sum_array[i] + 4
|
|
129
|
+
if bool_selector_mat[1, 1]:
|
|
130
|
+
sum_array[i] = sum_array[i] + 8
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_bool_constant_mat(test, device):
|
|
132
134
|
result_array = wp.zeros(10, dtype=wp.int32, device=device)
|
|
133
135
|
|
|
134
136
|
wp.launch(sum_from_bool_mat, result_array.shape, inputs=[result_array], device=device)
|
|
@@ -136,8 +138,20 @@ def test_bool_constant_mat(test, device):
|
|
|
136
138
|
assert_np_equal(result_array.numpy(), np.full(result_array.shape, 9))
|
|
137
139
|
|
|
138
140
|
|
|
141
|
+
vec3bool_type = wp.types.vector(length=3, dtype=bool)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@wp.kernel
|
|
145
|
+
def test_bool_vec_anonymous_typing():
|
|
146
|
+
# Zero initialize
|
|
147
|
+
wp.expect_eq(vec3bool_type(), wp.vector(False, False, False))
|
|
148
|
+
# Scalar initialize
|
|
149
|
+
wp.expect_eq(vec3bool_type(True), wp.vector(True, True, True))
|
|
150
|
+
# Component-wise initialize
|
|
151
|
+
wp.expect_eq(vec3bool_type(True, False, True), wp.vector(True, False, True))
|
|
152
|
+
|
|
153
|
+
|
|
139
154
|
def test_bool_vec_typing(test, device):
|
|
140
|
-
vec3bool_type = wp.types.vector(length=3, dtype=bool)
|
|
141
155
|
# Zero initialize
|
|
142
156
|
vec3bool_z = vec3bool_type()
|
|
143
157
|
test.assertEqual(tuple(vec3bool_z), (False, False, False))
|
|
@@ -148,20 +162,23 @@ def test_bool_vec_typing(test, device):
|
|
|
148
162
|
vec3bool_c = vec3bool_type(True, False, True)
|
|
149
163
|
test.assertEqual(tuple(vec3bool_c), (True, False, True))
|
|
150
164
|
|
|
151
|
-
@wp.kernel
|
|
152
|
-
def test_bool_vec_anonymous_typing():
|
|
153
|
-
# Zero initialize
|
|
154
|
-
wp.expect_eq(vec3bool_type(), wp.vector(False, False, False))
|
|
155
|
-
# Scalar initialize
|
|
156
|
-
wp.expect_eq(vec3bool_type(True), wp.vector(True, True, True))
|
|
157
|
-
# Component-wise initialize
|
|
158
|
-
wp.expect_eq(vec3bool_type(True, False, True), wp.vector(True, False, True))
|
|
159
|
-
|
|
160
165
|
wp.launch(test_bool_vec_anonymous_typing, (1,), inputs=[], device=device)
|
|
161
166
|
|
|
162
167
|
|
|
168
|
+
mat22bool_type = wp.types.matrix((2, 2), dtype=bool)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@wp.kernel
|
|
172
|
+
def test_bool_mat_anonymous_typing():
|
|
173
|
+
# Zero initialize
|
|
174
|
+
wp.expect_eq(mat22bool_type(), wp.matrix(False, False, False, False, shape=(2, 2)))
|
|
175
|
+
# Scalar initialize
|
|
176
|
+
wp.expect_eq(mat22bool_type(True), wp.matrix(True, True, True, True, shape=(2, 2)))
|
|
177
|
+
# Component-wise initialize
|
|
178
|
+
wp.expect_eq(mat22bool_type(True, False, True, False), wp.matrix(True, False, True, False, shape=(2, 2)))
|
|
179
|
+
|
|
180
|
+
|
|
163
181
|
def test_bool_mat_typing(test, device):
|
|
164
|
-
mat22bool_type = wp.types.matrix((2, 2), dtype=bool)
|
|
165
182
|
# Zero initialize
|
|
166
183
|
mat22bool_z = mat22bool_type()
|
|
167
184
|
test.assertEqual(tuple(mat22bool_z), ((False, False), (False, False)))
|
|
@@ -172,15 +189,6 @@ def test_bool_mat_typing(test, device):
|
|
|
172
189
|
mat22bool_c = mat22bool_type(True, False, True, False)
|
|
173
190
|
test.assertEqual(tuple(mat22bool_c), ((True, False), (True, False)))
|
|
174
191
|
|
|
175
|
-
@wp.kernel
|
|
176
|
-
def test_bool_mat_anonymous_typing():
|
|
177
|
-
# Zero initialize
|
|
178
|
-
wp.expect_eq(mat22bool_type(), wp.matrix(False, False, False, False, shape=(2, 2)))
|
|
179
|
-
# Scalar initialize
|
|
180
|
-
wp.expect_eq(mat22bool_type(True), wp.matrix(True, True, True, True, shape=(2, 2)))
|
|
181
|
-
# Component-wise initialize
|
|
182
|
-
wp.expect_eq(mat22bool_type(True, False, True, False), wp.matrix(True, False, True, False, shape=(2, 2)))
|
|
183
|
-
|
|
184
192
|
wp.launch(test_bool_mat_anonymous_typing, (1,), inputs=[], device=device)
|
|
185
193
|
|
|
186
194
|
|
warp/tests/test_bvh.py
CHANGED
warp/tests/test_codegen.py
CHANGED
|
@@ -11,8 +11,6 @@ import warp as wp
|
|
|
11
11
|
import warp.tests.aux_test_compile_consts_dummy
|
|
12
12
|
from warp.tests.unittest_utils import *
|
|
13
13
|
|
|
14
|
-
wp.init()
|
|
15
|
-
|
|
16
14
|
LOCAL_ONE = wp.constant(1)
|
|
17
15
|
|
|
18
16
|
SQRT3_OVER_3 = wp.constant(0.57735026919)
|
|
@@ -27,7 +25,7 @@ class Foobar:
|
|
|
27
25
|
|
|
28
26
|
|
|
29
27
|
@wp.kernel
|
|
30
|
-
def
|
|
28
|
+
def test_bool():
|
|
31
29
|
if TEST_BOOL:
|
|
32
30
|
expect_eq(1.0, 1.0)
|
|
33
31
|
else:
|
|
@@ -35,7 +33,7 @@ def test_constants_bool():
|
|
|
35
33
|
|
|
36
34
|
|
|
37
35
|
@wp.kernel
|
|
38
|
-
def
|
|
36
|
+
def test_int(a: int):
|
|
39
37
|
if Foobar.ONE > 0:
|
|
40
38
|
a = 123 + Foobar.TWO + warp.tests.aux_test_compile_consts_dummy.MINUS_ONE
|
|
41
39
|
else:
|
|
@@ -44,7 +42,7 @@ def test_constants_int(a: int):
|
|
|
44
42
|
|
|
45
43
|
|
|
46
44
|
@wp.kernel
|
|
47
|
-
def
|
|
45
|
+
def test_float(x: float):
|
|
48
46
|
x = SQRT3_OVER_3
|
|
49
47
|
for i in range(3):
|
|
50
48
|
expect_eq(UNIT_VEC[i], x)
|
|
@@ -56,7 +54,7 @@ def test_constants_float(x: float):
|
|
|
56
54
|
expect_near(wp.float32(ONE_FP16), 1.0, 1e-6)
|
|
57
55
|
|
|
58
56
|
|
|
59
|
-
def
|
|
57
|
+
def test_closure_capture(test, device):
|
|
60
58
|
def make_closure_kernel(cst):
|
|
61
59
|
def closure_kernel_fn(expected: int):
|
|
62
60
|
wp.expect_eq(cst, expected)
|
|
@@ -70,6 +68,124 @@ def test_constant_closure_capture(test, device):
|
|
|
70
68
|
wp.launch(two_closure, dim=(1), inputs=[2], device=device)
|
|
71
69
|
|
|
72
70
|
|
|
71
|
+
def test_hash_global_capture(test, device):
|
|
72
|
+
"""Verifies that global variables are included in the module hash"""
|
|
73
|
+
|
|
74
|
+
a = 0
|
|
75
|
+
wp.launch(test_int, (1,), inputs=[a], device=device)
|
|
76
|
+
|
|
77
|
+
module_constants = wp.get_module(test_int.__module__).constants
|
|
78
|
+
|
|
79
|
+
# Ensure the expected constants and values are in the dictionary used in hashing
|
|
80
|
+
# Depending on what's been launched already, there might be additional constants present
|
|
81
|
+
test.assertEqual(module_constants["Foobar.ONE"], 1)
|
|
82
|
+
test.assertEqual(module_constants["Foobar.TWO"], 2)
|
|
83
|
+
test.assertEqual(module_constants["warp.tests.aux_test_compile_consts_dummy.MINUS_ONE"], -1)
|
|
84
|
+
test.assertEqual(module_constants["LOCAL_ONE"], 1)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_hash_redefine_kernel(test, device):
|
|
88
|
+
"""This test defines a second ``test_function`` so that the second launch returns the correct result."""
|
|
89
|
+
|
|
90
|
+
@wp.kernel
|
|
91
|
+
def test_function(data: wp.array(dtype=wp.float32)):
|
|
92
|
+
i = wp.tid()
|
|
93
|
+
data[i] = TEST_CONSTANT
|
|
94
|
+
|
|
95
|
+
TEST_CONSTANT = wp.constant(1.0)
|
|
96
|
+
|
|
97
|
+
test_array = wp.empty(1, dtype=wp.float32, device=device)
|
|
98
|
+
wp.launch(test_function, (1,), inputs=[test_array], device=device)
|
|
99
|
+
test.assertEqual(test_array.numpy()[0], 1.0)
|
|
100
|
+
|
|
101
|
+
module_hash_0 = wp.get_module(test_function.__module__).hash_module()
|
|
102
|
+
module_constants = wp.get_module(test_function.__module__).constants
|
|
103
|
+
test.assertEqual(module_constants["TEST_CONSTANT"], 1.0)
|
|
104
|
+
|
|
105
|
+
@wp.kernel
|
|
106
|
+
def test_function(data: wp.array(dtype=wp.float32)):
|
|
107
|
+
i = wp.tid()
|
|
108
|
+
data[i] = TEST_CONSTANT
|
|
109
|
+
|
|
110
|
+
TEST_CONSTANT = wp.constant(2.0)
|
|
111
|
+
|
|
112
|
+
wp.launch(test_function, (1,), inputs=[test_array], device=device)
|
|
113
|
+
test.assertEqual(test_array.numpy()[0], 2.0)
|
|
114
|
+
|
|
115
|
+
module_hash_1 = wp.get_module(test_function.__module__).hash_module()
|
|
116
|
+
module_constants = wp.get_module(test_function.__module__).constants
|
|
117
|
+
|
|
118
|
+
test.assertEqual(module_constants["TEST_CONSTANT"], 2.0)
|
|
119
|
+
test.assertNotEqual(module_hash_0, module_hash_1)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_hash_redefine_constant_only(test, device):
|
|
123
|
+
"""This test does not define a second ``test_function``, so the second launch does not invalidate the cache.
|
|
124
|
+
|
|
125
|
+
For now this is expected behavior, but we can verify that the content has is different.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
@wp.kernel
|
|
129
|
+
def test_function(data: wp.array(dtype=wp.float32)):
|
|
130
|
+
i = wp.tid()
|
|
131
|
+
data[i] = TEST_CONSTANT
|
|
132
|
+
|
|
133
|
+
TEST_CONSTANT = wp.constant(1.0)
|
|
134
|
+
|
|
135
|
+
test_array = wp.empty(1, dtype=wp.float32, device=device)
|
|
136
|
+
wp.launch(test_function, (1,), inputs=[test_array], device=device)
|
|
137
|
+
test.assertEqual(test_array.numpy()[0], 1.0)
|
|
138
|
+
|
|
139
|
+
module_hash_0 = wp.get_module(test_function.__module__).hash_module()
|
|
140
|
+
|
|
141
|
+
module_constants = wp.get_module(test_function.__module__).constants
|
|
142
|
+
test.assertEqual(module_constants["TEST_CONSTANT"], 1.0)
|
|
143
|
+
|
|
144
|
+
TEST_CONSTANT = wp.constant(2.0)
|
|
145
|
+
module_hash_1 = wp.get_module(test_function.__module__).hash_module(recompute_content_hash=True)
|
|
146
|
+
module_constants = wp.get_module(test_function.__module__).constants
|
|
147
|
+
test.assertEqual(module_constants["TEST_CONSTANT"], 2.0)
|
|
148
|
+
test.assertNotEqual(module_hash_0, module_hash_1, "Module hashes should be different if TEST_CONSTANT is changed.")
|
|
149
|
+
|
|
150
|
+
TEST_CONSTANT = wp.constant(1.0)
|
|
151
|
+
module_hash_2 = wp.get_module(test_function.__module__).hash_module(recompute_content_hash=True)
|
|
152
|
+
module_constants = wp.get_module(test_function.__module__).constants
|
|
153
|
+
test.assertEqual(module_constants["TEST_CONSTANT"], 1.0)
|
|
154
|
+
test.assertEqual(module_hash_0, module_hash_2, "Module hashes should be the same if TEST_CONSTANT is the same.")
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def test_hash_shadowed_var(test, device):
|
|
158
|
+
"""Tests to ensure shadowed variables are not mistakenly added to the module hash"""
|
|
159
|
+
|
|
160
|
+
TEST_CONSTANT_SHADOW_0 = wp.constant(1.0)
|
|
161
|
+
TEST_CONSTANT_SHADOW_1 = wp.constant(1.0)
|
|
162
|
+
TEST_CONSTANT_SHADOW_2 = wp.constant(1.0)
|
|
163
|
+
|
|
164
|
+
@wp.kernel
|
|
165
|
+
def test_function(data: wp.array(dtype=wp.float32)):
|
|
166
|
+
i = wp.tid()
|
|
167
|
+
TEST_CONSTANT_SHADOW_0 = 2.0
|
|
168
|
+
TEST_CONSTANT_SHADOW_1, TEST_CONSTANT_SHADOW_2 = 4.0, 8.0
|
|
169
|
+
data[i] = TEST_CONSTANT_SHADOW_0 + TEST_CONSTANT_SHADOW_1 + TEST_CONSTANT_SHADOW_2
|
|
170
|
+
|
|
171
|
+
test_array = wp.empty(1, dtype=wp.float32, device=device)
|
|
172
|
+
wp.launch(test_function, (1,), inputs=[test_array], device=device)
|
|
173
|
+
test.assertEqual(test_array.numpy()[0], 14.0)
|
|
174
|
+
|
|
175
|
+
module_hash_0 = wp.get_module(test_function.__module__).hash_module()
|
|
176
|
+
module_constants = wp.get_module(test_function.__module__).constants
|
|
177
|
+
|
|
178
|
+
test.assertFalse("TEST_CONSTANT_SHADOW_0" in module_constants, "Constant should not be in dictionary.")
|
|
179
|
+
test.assertFalse("TEST_CONSTANT_SHADOW_1" in module_constants, "Constant should not be in dictionary.")
|
|
180
|
+
test.assertFalse("TEST_CONSTANT_SHADOW_2" in module_constants, "Constant should not be in dictionary.")
|
|
181
|
+
|
|
182
|
+
TEST_CONSTANT_SHADOW_0 = wp.constant(0.0)
|
|
183
|
+
TEST_CONSTANT_SHADOW_1 = wp.constant(0.0)
|
|
184
|
+
TEST_CONSTANT_SHADOW_2 = wp.constant(0.0)
|
|
185
|
+
module_hash_1 = wp.get_module(test_function.__module__).hash_module(recompute_content_hash=True)
|
|
186
|
+
test.assertEqual(module_hash_0, module_hash_1, "Module hashes should be the same since all constants are shadowed.")
|
|
187
|
+
|
|
188
|
+
|
|
73
189
|
class TestConstants(unittest.TestCase):
|
|
74
190
|
def test_constant_math(self):
|
|
75
191
|
# test doing math with python defined constants in *python* scope
|
|
@@ -85,11 +201,15 @@ x = 0.0
|
|
|
85
201
|
|
|
86
202
|
devices = get_test_devices()
|
|
87
203
|
|
|
88
|
-
add_kernel_test(TestConstants,
|
|
89
|
-
add_kernel_test(TestConstants,
|
|
90
|
-
add_kernel_test(TestConstants,
|
|
204
|
+
add_kernel_test(TestConstants, test_bool, dim=1, inputs=[], devices=devices)
|
|
205
|
+
add_kernel_test(TestConstants, test_int, dim=1, inputs=[a], devices=devices)
|
|
206
|
+
add_kernel_test(TestConstants, test_float, dim=1, inputs=[x], devices=devices)
|
|
91
207
|
|
|
92
|
-
add_function_test(TestConstants, "
|
|
208
|
+
add_function_test(TestConstants, "test_closure_capture", test_closure_capture, devices=devices)
|
|
209
|
+
add_function_test(TestConstants, "test_hash_global_capture", test_hash_global_capture, devices=devices)
|
|
210
|
+
add_function_test(TestConstants, "test_hash_redefine_kernel", test_hash_redefine_kernel, devices=devices)
|
|
211
|
+
add_function_test(TestConstants, "test_hash_redefine_constant_only", test_hash_redefine_constant_only, devices=devices)
|
|
212
|
+
add_function_test(TestConstants, "test_hash_shadowed_var", test_hash_shadowed_var, devices=devices)
|
|
93
213
|
|
|
94
214
|
|
|
95
215
|
if __name__ == "__main__":
|
warp/tests/test_conditional.py
CHANGED
warp/tests/test_copy.py
CHANGED
warp/tests/test_ctypes.py
CHANGED
|
@@ -12,8 +12,6 @@ import numpy as np
|
|
|
12
12
|
import warp as wp
|
|
13
13
|
from warp.tests.unittest_utils import *
|
|
14
14
|
|
|
15
|
-
wp.init()
|
|
16
|
-
|
|
17
15
|
|
|
18
16
|
@wp.kernel
|
|
19
17
|
def add_vec2(dest: wp.array(dtype=wp.vec2), c: wp.vec2):
|
|
@@ -57,7 +55,7 @@ def test_vec2_arg(test, device, n):
|
|
|
57
55
|
wp.launch(add_vec2, dim=n, inputs=[dest, c], device=device)
|
|
58
56
|
|
|
59
57
|
# ensure type can round-trip from Python->GPU->Python
|
|
60
|
-
|
|
58
|
+
assert_np_equal(dest.numpy(), np.tile(c, (n, 1)))
|
|
61
59
|
|
|
62
60
|
|
|
63
61
|
def test_vec2_transform(test, device, n):
|
|
@@ -67,8 +65,8 @@ def test_vec2_transform(test, device, n):
|
|
|
67
65
|
m = np.array(((3.0, -1.0), (2.5, 4.0)))
|
|
68
66
|
|
|
69
67
|
wp.launch(transform_vec2, dim=n, inputs=[dest_right, dest_left, m, c], device=device)
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
assert_np_equal(dest_right.numpy(), np.tile(m @ c, (n, 1)))
|
|
69
|
+
assert_np_equal(dest_left.numpy(), np.tile(c @ m, (n, 1)))
|
|
72
70
|
|
|
73
71
|
|
|
74
72
|
def test_vec3_arg(test, device, n):
|
|
@@ -76,7 +74,7 @@ def test_vec3_arg(test, device, n):
|
|
|
76
74
|
c = np.array((1.0, 2.0, 3.0))
|
|
77
75
|
|
|
78
76
|
wp.launch(add_vec3, dim=n, inputs=[dest, c], device=device)
|
|
79
|
-
|
|
77
|
+
assert_np_equal(dest.numpy(), np.tile(c, (n, 1)))
|
|
80
78
|
|
|
81
79
|
|
|
82
80
|
def test_vec3_transform(test, device, n):
|
|
@@ -86,8 +84,8 @@ def test_vec3_transform(test, device, n):
|
|
|
86
84
|
m = np.array(((1.0, 2.0, 3.0), (4.0, 5.0, 6.0), (7.0, 8.0, 9.0)))
|
|
87
85
|
|
|
88
86
|
wp.launch(transform_vec3, dim=n, inputs=[dest_right, dest_left, m, c], device=device)
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
assert_np_equal(dest_right.numpy(), np.tile(m @ c, (n, 1)))
|
|
88
|
+
assert_np_equal(dest_left.numpy(), np.tile(c @ m, (n, 1)))
|
|
91
89
|
|
|
92
90
|
|
|
93
91
|
def test_transform_multiply(test, device, n):
|
warp/tests/test_dense.py
CHANGED
warp/tests/test_devices.py
CHANGED
warp/tests/test_dlpack.py
CHANGED
|
@@ -16,15 +16,13 @@ from warp.tests.unittest_utils import *
|
|
|
16
16
|
|
|
17
17
|
N = 1024 * 1024
|
|
18
18
|
|
|
19
|
-
wp.init()
|
|
20
|
-
|
|
21
19
|
|
|
22
20
|
def _jax_version():
|
|
23
21
|
try:
|
|
24
22
|
import jax
|
|
25
23
|
|
|
26
24
|
return jax.__version_info__
|
|
27
|
-
except ImportError:
|
|
25
|
+
except (ImportError, AttributeError):
|
|
28
26
|
return (0, 0, 0)
|
|
29
27
|
|
|
30
28
|
|
|
@@ -315,8 +313,8 @@ def test_dlpack_warp_to_jax(test, device):
|
|
|
315
313
|
|
|
316
314
|
test.assertEqual(a.ptr, j1.unsafe_buffer_pointer())
|
|
317
315
|
test.assertEqual(a.ptr, j2.unsafe_buffer_pointer())
|
|
318
|
-
test.assertEqual(a.device, wp.device_from_jax(j1.
|
|
319
|
-
test.assertEqual(a.device, wp.device_from_jax(j2.
|
|
316
|
+
test.assertEqual(a.device, wp.device_from_jax(list(j1.devices())[0]))
|
|
317
|
+
test.assertEqual(a.device, wp.device_from_jax(list(j2.devices())[0]))
|
|
320
318
|
test.assertEqual(a.shape, j1.shape)
|
|
321
319
|
test.assertEqual(a.shape, j2.shape)
|
|
322
320
|
|
|
@@ -352,8 +350,8 @@ def test_dlpack_warp_to_jax_v2(test, device):
|
|
|
352
350
|
|
|
353
351
|
test.assertEqual(a.ptr, j1.unsafe_buffer_pointer())
|
|
354
352
|
test.assertEqual(a.ptr, j2.unsafe_buffer_pointer())
|
|
355
|
-
test.assertEqual(a.device, wp.device_from_jax(j1.
|
|
356
|
-
test.assertEqual(a.device, wp.device_from_jax(j2.
|
|
353
|
+
test.assertEqual(a.device, wp.device_from_jax(list(j1.devices())[0]))
|
|
354
|
+
test.assertEqual(a.device, wp.device_from_jax(list(j2.devices())[0]))
|
|
357
355
|
test.assertEqual(a.shape, j1.shape)
|
|
358
356
|
test.assertEqual(a.shape, j2.shape)
|
|
359
357
|
|
|
@@ -387,8 +385,8 @@ def test_dlpack_jax_to_warp(test, device):
|
|
|
387
385
|
|
|
388
386
|
test.assertEqual(a1.ptr, j.unsafe_buffer_pointer())
|
|
389
387
|
test.assertEqual(a2.ptr, j.unsafe_buffer_pointer())
|
|
390
|
-
test.assertEqual(a1.device, wp.device_from_jax(j.
|
|
391
|
-
test.assertEqual(a2.device, wp.device_from_jax(j.
|
|
388
|
+
test.assertEqual(a1.device, wp.device_from_jax(list(j.devices())[0]))
|
|
389
|
+
test.assertEqual(a2.device, wp.device_from_jax(list(j.devices())[0]))
|
|
392
390
|
test.assertEqual(a1.shape, j.shape)
|
|
393
391
|
test.assertEqual(a2.shape, j.shape)
|
|
394
392
|
|
|
@@ -423,8 +421,8 @@ def test_dlpack_jax_to_warp_v2(test, device):
|
|
|
423
421
|
|
|
424
422
|
test.assertEqual(a1.ptr, j.unsafe_buffer_pointer())
|
|
425
423
|
test.assertEqual(a2.ptr, j.unsafe_buffer_pointer())
|
|
426
|
-
test.assertEqual(a1.device, wp.device_from_jax(j.
|
|
427
|
-
test.assertEqual(a2.device, wp.device_from_jax(j.
|
|
424
|
+
test.assertEqual(a1.device, wp.device_from_jax(list(j.devices())[0]))
|
|
425
|
+
test.assertEqual(a2.device, wp.device_from_jax(list(j.devices())[0]))
|
|
428
426
|
test.assertEqual(a1.shape, j.shape)
|
|
429
427
|
test.assertEqual(a2.shape, j.shape)
|
|
430
428
|
|