warp-lang 1.0.0b5__py3-none-manylinux2014_x86_64.whl → 1.0.0b6__py3-none-manylinux2014_x86_64.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.
- docs/conf.py +3 -4
- examples/env/env_ant.py +1 -1
- examples/env/env_cartpole.py +1 -1
- examples/env/env_humanoid.py +1 -1
- examples/example_dem.py +28 -26
- examples/example_diffray.py +37 -30
- examples/example_fluid.py +7 -3
- examples/example_jacobian_ik.py +1 -1
- examples/example_mesh_intersect.py +10 -7
- examples/example_nvdb.py +3 -3
- examples/example_render_opengl.py +19 -10
- examples/example_sim_cartpole.py +9 -5
- examples/example_sim_cloth.py +29 -25
- examples/example_sim_fk_grad.py +2 -2
- examples/example_sim_fk_grad_torch.py +3 -3
- examples/example_sim_grad_bounce.py +11 -8
- examples/example_sim_grad_cloth.py +12 -9
- examples/example_sim_granular.py +2 -2
- examples/example_sim_granular_collision_sdf.py +13 -13
- examples/example_sim_neo_hookean.py +3 -3
- examples/example_sim_particle_chain.py +2 -2
- examples/example_sim_quadruped.py +8 -5
- examples/example_sim_rigid_chain.py +8 -5
- examples/example_sim_rigid_contact.py +13 -10
- examples/example_sim_rigid_fem.py +2 -2
- examples/example_sim_rigid_gyroscopic.py +2 -2
- examples/example_sim_rigid_kinematics.py +1 -1
- examples/example_sim_trajopt.py +3 -2
- examples/fem/example_apic_fluid.py +5 -7
- examples/fem/example_diffusion_mgpu.py +18 -16
- warp/__init__.py +3 -2
- warp/bin/warp.so +0 -0
- warp/build_dll.py +29 -9
- warp/builtins.py +206 -7
- warp/codegen.py +58 -38
- warp/config.py +3 -1
- warp/context.py +234 -128
- warp/fem/__init__.py +2 -2
- warp/fem/cache.py +2 -1
- warp/fem/field/nodal_field.py +18 -17
- warp/fem/geometry/hexmesh.py +11 -6
- warp/fem/geometry/quadmesh_2d.py +16 -12
- warp/fem/geometry/tetmesh.py +19 -8
- warp/fem/geometry/trimesh_2d.py +18 -7
- warp/fem/integrate.py +341 -196
- warp/fem/quadrature/__init__.py +1 -1
- warp/fem/quadrature/pic_quadrature.py +138 -53
- warp/fem/quadrature/quadrature.py +81 -9
- warp/fem/space/__init__.py +1 -1
- warp/fem/space/basis_space.py +169 -51
- warp/fem/space/grid_2d_function_space.py +2 -2
- warp/fem/space/grid_3d_function_space.py +2 -2
- warp/fem/space/hexmesh_function_space.py +2 -2
- warp/fem/space/partition.py +9 -6
- warp/fem/space/quadmesh_2d_function_space.py +2 -2
- warp/fem/space/shape/cube_shape_function.py +27 -15
- warp/fem/space/shape/square_shape_function.py +29 -18
- warp/fem/space/tetmesh_function_space.py +2 -2
- warp/fem/space/topology.py +10 -0
- warp/fem/space/trimesh_2d_function_space.py +2 -2
- warp/fem/utils.py +10 -5
- warp/native/array.h +49 -8
- warp/native/builtin.h +31 -14
- warp/native/cuda_util.cpp +8 -3
- warp/native/cuda_util.h +1 -0
- warp/native/exports.h +1177 -1108
- warp/native/intersect.h +4 -4
- warp/native/intersect_adj.h +8 -8
- warp/native/mat.h +65 -6
- warp/native/mesh.h +126 -5
- warp/native/quat.h +28 -4
- warp/native/vec.h +76 -14
- warp/native/warp.cu +1 -6
- warp/render/render_opengl.py +261 -109
- warp/sim/import_mjcf.py +13 -7
- warp/sim/import_urdf.py +14 -14
- warp/sim/inertia.py +17 -18
- warp/sim/model.py +67 -67
- warp/sim/render.py +1 -1
- warp/sparse.py +6 -6
- warp/stubs.py +19 -81
- warp/tape.py +1 -1
- warp/tests/__main__.py +3 -6
- warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
- warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
- warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
- warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
- warp/tests/aux_test_unresolved_func.py +14 -0
- warp/tests/aux_test_unresolved_symbol.py +14 -0
- warp/tests/{test_kinematics.py → disabled_kinematics.py} +10 -12
- warp/tests/run_coverage_serial.py +31 -0
- warp/tests/test_adam.py +102 -106
- warp/tests/test_arithmetic.py +39 -40
- warp/tests/test_array.py +46 -48
- warp/tests/test_array_reduce.py +25 -19
- warp/tests/test_atomic.py +62 -26
- warp/tests/test_bool.py +16 -11
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +9 -12
- warp/tests/test_closest_point_edge_edge.py +53 -57
- warp/tests/test_codegen.py +164 -134
- warp/tests/test_compile_consts.py +13 -19
- warp/tests/test_conditional.py +30 -32
- warp/tests/test_copy.py +9 -12
- warp/tests/test_ctypes.py +90 -98
- warp/tests/test_dense.py +20 -14
- warp/tests/test_devices.py +34 -35
- warp/tests/test_dlpack.py +74 -75
- warp/tests/test_examples.py +215 -97
- warp/tests/test_fabricarray.py +15 -21
- warp/tests/test_fast_math.py +14 -11
- warp/tests/test_fem.py +280 -97
- warp/tests/test_fp16.py +19 -15
- warp/tests/test_func.py +177 -194
- warp/tests/test_generics.py +71 -77
- warp/tests/test_grad.py +83 -32
- warp/tests/test_grad_customs.py +7 -9
- warp/tests/test_hash_grid.py +6 -10
- warp/tests/test_import.py +9 -23
- warp/tests/test_indexedarray.py +19 -21
- warp/tests/test_intersect.py +15 -9
- warp/tests/test_large.py +17 -19
- warp/tests/test_launch.py +14 -17
- warp/tests/test_lerp.py +63 -63
- warp/tests/test_lvalue.py +84 -35
- warp/tests/test_marching_cubes.py +9 -13
- warp/tests/test_mat.py +388 -3004
- warp/tests/test_mat_lite.py +9 -12
- warp/tests/test_mat_scalar_ops.py +2889 -0
- warp/tests/test_math.py +10 -11
- warp/tests/test_matmul.py +104 -100
- warp/tests/test_matmul_lite.py +72 -98
- warp/tests/test_mesh.py +35 -32
- warp/tests/test_mesh_query_aabb.py +18 -25
- warp/tests/test_mesh_query_point.py +39 -23
- warp/tests/test_mesh_query_ray.py +9 -21
- warp/tests/test_mlp.py +8 -9
- warp/tests/test_model.py +89 -93
- warp/tests/test_modules_lite.py +15 -25
- warp/tests/test_multigpu.py +87 -114
- warp/tests/test_noise.py +10 -12
- warp/tests/test_operators.py +14 -21
- warp/tests/test_options.py +10 -11
- warp/tests/test_pinned.py +16 -18
- warp/tests/test_print.py +16 -20
- warp/tests/test_quat.py +121 -88
- warp/tests/test_rand.py +12 -13
- warp/tests/test_reload.py +27 -32
- warp/tests/test_rounding.py +7 -10
- warp/tests/test_runlength_encode.py +105 -106
- warp/tests/test_smoothstep.py +8 -9
- warp/tests/test_snippet.py +13 -22
- warp/tests/test_sparse.py +30 -29
- warp/tests/test_spatial.py +179 -174
- warp/tests/test_streams.py +100 -107
- warp/tests/test_struct.py +98 -67
- warp/tests/test_tape.py +11 -17
- warp/tests/test_torch.py +89 -86
- warp/tests/test_transient_module.py +9 -12
- warp/tests/test_types.py +328 -50
- warp/tests/test_utils.py +217 -218
- warp/tests/test_vec.py +133 -2133
- warp/tests/test_vec_lite.py +8 -11
- warp/tests/test_vec_scalar_ops.py +2099 -0
- warp/tests/test_volume.py +391 -382
- warp/tests/test_volume_write.py +122 -135
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +291 -0
- warp/tests/{test_base.py → unittest_utils.py} +138 -25
- warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
- warp/tests/{test_debug.py → walkthough_debug.py} +2 -15
- warp/thirdparty/unittest_parallel.py +257 -54
- warp/types.py +119 -98
- warp/utils.py +14 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/METADATA +2 -1
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/RECORD +182 -178
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
- warp/tests/test_all.py +0 -239
- warp/tests/test_conditional_unequal_types_kernels.py +0 -14
- warp/tests/test_coverage.py +0 -38
- warp/tests/test_unresolved_func.py +0 -7
- warp/tests/test_unresolved_symbol.py +0 -7
- /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
- /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
- /warp/tests/{test_square.py → aux_test_square.py} +0 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
warp/tests/test_grad.py
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
7
|
|
|
8
8
|
import unittest
|
|
9
|
+
from typing import Any
|
|
9
10
|
|
|
10
11
|
import numpy as np
|
|
11
12
|
|
|
12
13
|
import warp as wp
|
|
13
|
-
from warp.tests.
|
|
14
|
+
from warp.tests.unittest_utils import *
|
|
14
15
|
|
|
15
16
|
wp.init()
|
|
16
17
|
|
|
@@ -66,26 +67,26 @@ def test_for_loop_grad(test, device):
|
|
|
66
67
|
|
|
67
68
|
|
|
68
69
|
def test_for_loop_graph_grad(test, device):
|
|
70
|
+
wp.load_module(device=device)
|
|
71
|
+
|
|
69
72
|
n = 32
|
|
70
73
|
val = np.ones(n, dtype=np.float32)
|
|
71
74
|
|
|
72
75
|
x = wp.array(val, device=device, requires_grad=True)
|
|
73
76
|
sum = wp.zeros(1, dtype=wp.float32, device=device, requires_grad=True)
|
|
74
77
|
|
|
75
|
-
wp.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
with tape:
|
|
81
|
-
wp.launch(for_loop_grad, dim=1, inputs=[n, x, sum], device=device)
|
|
82
|
-
|
|
83
|
-
tape.backward(loss=sum)
|
|
78
|
+
wp.capture_begin(device, force_module_load=False)
|
|
79
|
+
try:
|
|
80
|
+
tape = wp.Tape()
|
|
81
|
+
with tape:
|
|
82
|
+
wp.launch(for_loop_grad, dim=1, inputs=[n, x, sum], device=device)
|
|
84
83
|
|
|
85
|
-
|
|
84
|
+
tape.backward(loss=sum)
|
|
85
|
+
finally:
|
|
86
|
+
graph = wp.capture_end(device)
|
|
86
87
|
|
|
87
88
|
wp.capture_launch(graph)
|
|
88
|
-
wp.
|
|
89
|
+
wp.synchronize_device(device)
|
|
89
90
|
|
|
90
91
|
# ensure forward pass outputs persist
|
|
91
92
|
assert_np_equal(sum.numpy(), 2.0 * np.sum(x.numpy()))
|
|
@@ -93,7 +94,7 @@ def test_for_loop_graph_grad(test, device):
|
|
|
93
94
|
assert_np_equal(x.grad.numpy(), 2.0 * val)
|
|
94
95
|
|
|
95
96
|
wp.capture_launch(graph)
|
|
96
|
-
wp.
|
|
97
|
+
wp.synchronize_device(device)
|
|
97
98
|
|
|
98
99
|
|
|
99
100
|
@wp.kernel
|
|
@@ -560,30 +561,80 @@ def test_name_clash(test, device):
|
|
|
560
561
|
assert_np_equal(input_b.grad.numpy(), np.array([1.0, 1.0, 0.0]))
|
|
561
562
|
|
|
562
563
|
|
|
563
|
-
|
|
564
|
-
|
|
564
|
+
@wp.struct
|
|
565
|
+
class NestedStruct:
|
|
566
|
+
v: wp.vec2
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
@wp.struct
|
|
570
|
+
class ParentStruct:
|
|
571
|
+
a: float
|
|
572
|
+
n: NestedStruct
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
@wp.func
|
|
576
|
+
def noop(a: Any):
|
|
577
|
+
pass
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
@wp.func
|
|
581
|
+
def sum2(v: wp.vec2):
|
|
582
|
+
return v[0] + v[1]
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
@wp.kernel
|
|
586
|
+
def test_struct_attribute_gradient_kernel(src: wp.array(dtype=float), res: wp.array(dtype=float)):
|
|
587
|
+
tid = wp.tid()
|
|
588
|
+
|
|
589
|
+
p = ParentStruct(src[tid], NestedStruct(wp.vec2(2.0 * src[tid])))
|
|
590
|
+
|
|
591
|
+
# test that we are not losing gradients when accessing attributes
|
|
592
|
+
noop(p.a)
|
|
593
|
+
noop(p.n)
|
|
594
|
+
noop(p.n.v)
|
|
595
|
+
|
|
596
|
+
res[tid] = p.a + sum2(p.n.v)
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
def test_struct_attribute_gradient(test_case, device):
|
|
600
|
+
src = wp.array([1], dtype=float, requires_grad=True)
|
|
601
|
+
res = wp.empty_like(src)
|
|
602
|
+
|
|
603
|
+
tape = wp.Tape()
|
|
604
|
+
with tape:
|
|
605
|
+
wp.launch(test_struct_attribute_gradient_kernel, dim=1, inputs=[src, res])
|
|
606
|
+
|
|
607
|
+
res.grad.fill_(1.0)
|
|
608
|
+
tape.backward()
|
|
609
|
+
|
|
610
|
+
test_case.assertEqual(src.grad.numpy()[0], 5.0)
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
devices = get_test_devices()
|
|
614
|
+
|
|
565
615
|
|
|
566
|
-
|
|
567
|
-
|
|
616
|
+
class TestGrad(unittest.TestCase):
|
|
617
|
+
pass
|
|
568
618
|
|
|
569
|
-
# add_function_test(TestGrad, "test_while_loop_grad", test_while_loop_grad, devices=devices)
|
|
570
|
-
add_function_test(TestGrad, "test_for_loop_nested_for_grad", test_for_loop_nested_for_grad, devices=devices)
|
|
571
|
-
add_function_test(TestGrad, "test_scalar_grad", test_scalar_grad, devices=devices)
|
|
572
|
-
add_function_test(TestGrad, "test_for_loop_grad", test_for_loop_grad, devices=devices)
|
|
573
|
-
add_function_test(TestGrad, "test_for_loop_graph_grad", test_for_loop_graph_grad, devices=wp.get_cuda_devices())
|
|
574
|
-
add_function_test(TestGrad, "test_for_loop_nested_if_grad", test_for_loop_nested_if_grad, devices=devices)
|
|
575
|
-
add_function_test(TestGrad, "test_preserve_outputs_grad", test_preserve_outputs_grad, devices=devices)
|
|
576
|
-
add_function_test(TestGrad, "test_vector_math_grad", test_vector_math_grad, devices=devices)
|
|
577
|
-
add_function_test(TestGrad, "test_matrix_math_grad", test_matrix_math_grad, devices=devices)
|
|
578
|
-
add_function_test(TestGrad, "test_3d_math_grad", test_3d_math_grad, devices=devices)
|
|
579
|
-
add_function_test(TestGrad, "test_multi_valued_function_grad", test_multi_valued_function_grad, devices=devices)
|
|
580
|
-
add_function_test(TestGrad, "test_mesh_grad", test_mesh_grad, devices=devices)
|
|
581
|
-
add_function_test(TestGrad, "test_name_clash", test_name_clash, devices=devices)
|
|
582
619
|
|
|
583
|
-
|
|
620
|
+
# add_function_test(TestGrad, "test_while_loop_grad", test_while_loop_grad, devices=devices)
|
|
621
|
+
add_function_test(TestGrad, "test_for_loop_nested_for_grad", test_for_loop_nested_for_grad, devices=devices)
|
|
622
|
+
add_function_test(TestGrad, "test_scalar_grad", test_scalar_grad, devices=devices)
|
|
623
|
+
add_function_test(TestGrad, "test_for_loop_grad", test_for_loop_grad, devices=devices)
|
|
624
|
+
add_function_test(
|
|
625
|
+
TestGrad, "test_for_loop_graph_grad", test_for_loop_graph_grad, devices=get_unique_cuda_test_devices()
|
|
626
|
+
)
|
|
627
|
+
add_function_test(TestGrad, "test_for_loop_nested_if_grad", test_for_loop_nested_if_grad, devices=devices)
|
|
628
|
+
add_function_test(TestGrad, "test_preserve_outputs_grad", test_preserve_outputs_grad, devices=devices)
|
|
629
|
+
add_function_test(TestGrad, "test_vector_math_grad", test_vector_math_grad, devices=devices)
|
|
630
|
+
add_function_test(TestGrad, "test_matrix_math_grad", test_matrix_math_grad, devices=devices)
|
|
631
|
+
add_function_test(TestGrad, "test_3d_math_grad", test_3d_math_grad, devices=devices)
|
|
632
|
+
add_function_test(TestGrad, "test_multi_valued_function_grad", test_multi_valued_function_grad, devices=devices)
|
|
633
|
+
add_function_test(TestGrad, "test_mesh_grad", test_mesh_grad, devices=devices)
|
|
634
|
+
add_function_test(TestGrad, "test_name_clash", test_name_clash, devices=devices)
|
|
635
|
+
add_function_test(TestGrad, "test_struct_attribute_gradient", test_struct_attribute_gradient, devices=devices)
|
|
584
636
|
|
|
585
637
|
|
|
586
638
|
if __name__ == "__main__":
|
|
587
639
|
wp.build.clear_kernel_cache()
|
|
588
|
-
_ = register(unittest.TestCase)
|
|
589
640
|
unittest.main(verbosity=2, failfast=False)
|
warp/tests/test_grad_customs.py
CHANGED
|
@@ -10,7 +10,7 @@ import unittest
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
|
|
12
12
|
import warp as wp
|
|
13
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
14
14
|
|
|
15
15
|
wp.init()
|
|
16
16
|
|
|
@@ -160,19 +160,17 @@ def test_custom_overload_grad(test, device):
|
|
|
160
160
|
# fmt: on
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
devices = get_test_devices()
|
|
163
|
+
devices = get_test_devices()
|
|
165
164
|
|
|
166
|
-
class TestGradCustoms(parent):
|
|
167
|
-
pass
|
|
168
165
|
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
class TestGradCustoms(unittest.TestCase):
|
|
167
|
+
pass
|
|
171
168
|
|
|
172
|
-
|
|
169
|
+
|
|
170
|
+
add_function_test(TestGradCustoms, "test_custom_replay_grad", test_custom_replay_grad, devices=devices)
|
|
171
|
+
add_function_test(TestGradCustoms, "test_custom_overload_grad", test_custom_overload_grad, devices=devices)
|
|
173
172
|
|
|
174
173
|
|
|
175
174
|
if __name__ == "__main__":
|
|
176
175
|
wp.build.clear_kernel_cache()
|
|
177
|
-
_ = register(unittest.TestCase)
|
|
178
176
|
unittest.main(verbosity=2, failfast=False)
|
warp/tests/test_hash_grid.py
CHANGED
|
@@ -10,8 +10,7 @@ import unittest
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
|
|
12
12
|
import warp as wp
|
|
13
|
-
from warp.tests.
|
|
14
|
-
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
15
14
|
|
|
16
15
|
wp.init()
|
|
17
16
|
|
|
@@ -73,6 +72,7 @@ def count_neighbors_reference(
|
|
|
73
72
|
|
|
74
73
|
|
|
75
74
|
def test_hashgrid_query(test, device):
|
|
75
|
+
wp.load_module(device=device)
|
|
76
76
|
rng = np.random.default_rng(123)
|
|
77
77
|
|
|
78
78
|
grid = wp.HashGrid(dim_x, dim_y, dim_z, device)
|
|
@@ -134,19 +134,15 @@ def test_hashgrid_query(test, device):
|
|
|
134
134
|
test.assertTrue(np.array_equal(counts, counts_ref))
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
devices = get_test_devices()
|
|
137
|
+
devices = get_test_devices()
|
|
139
138
|
|
|
140
|
-
class TestHashGrid(parent):
|
|
141
|
-
pass
|
|
142
139
|
|
|
143
|
-
|
|
140
|
+
class TestHashGrid(unittest.TestCase):
|
|
141
|
+
pass
|
|
144
142
|
|
|
145
|
-
return TestHashGrid
|
|
146
143
|
|
|
144
|
+
add_function_test(TestHashGrid, "test_hashgrid_query", test_hashgrid_query, devices=devices)
|
|
147
145
|
|
|
148
146
|
if __name__ == "__main__":
|
|
149
147
|
wp.build.clear_kernel_cache()
|
|
150
|
-
wp.force_load()
|
|
151
|
-
_ = register(unittest.TestCase)
|
|
152
148
|
unittest.main(verbosity=2, failfast=False)
|
warp/tests/test_import.py
CHANGED
|
@@ -5,20 +5,14 @@
|
|
|
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
|
-
|
|
9
|
-
import numpy as np
|
|
10
|
-
import math
|
|
8
|
+
import unittest
|
|
11
9
|
|
|
12
10
|
import warp as wp
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import unittest
|
|
11
|
+
import warp.tests.test_func as test_func
|
|
12
|
+
from warp.tests.unittest_utils import *
|
|
16
13
|
|
|
17
14
|
wp.init()
|
|
18
15
|
|
|
19
|
-
# from test_func import sqr
|
|
20
|
-
import warp.tests.test_func as test_func
|
|
21
|
-
|
|
22
16
|
|
|
23
17
|
@wp.kernel
|
|
24
18
|
def test_import_func():
|
|
@@ -30,24 +24,16 @@ def test_import_func():
|
|
|
30
24
|
wp.expect_eq(y, 8.0)
|
|
31
25
|
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
devices = get_test_devices()
|
|
28
|
+
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
class TestImport(unittest.TestCase):
|
|
31
|
+
pass
|
|
38
32
|
|
|
39
|
-
add_kernel_test(TestImport, kernel=test_import_func, name="test_import_func", dim=1, devices=devices)
|
|
40
33
|
|
|
41
|
-
|
|
34
|
+
add_kernel_test(TestImport, kernel=test_import_func, name="test_import_func", dim=1, devices=devices)
|
|
42
35
|
|
|
43
36
|
|
|
44
37
|
if __name__ == "__main__":
|
|
45
38
|
wp.build.clear_kernel_cache()
|
|
46
|
-
|
|
47
|
-
# unittest.main(verbosity=2)
|
|
48
|
-
|
|
49
|
-
wp.force_load()
|
|
50
|
-
|
|
51
|
-
loader = unittest.defaultTestLoader
|
|
52
|
-
testSuite = loader.loadTestsFromTestCase(c)
|
|
53
|
-
testSuite.debug()
|
|
39
|
+
unittest.main(verbosity=2)
|
warp/tests/test_indexedarray.py
CHANGED
|
@@ -12,7 +12,7 @@ import numpy as np
|
|
|
12
12
|
|
|
13
13
|
import warp as wp
|
|
14
14
|
from warp.tests.test_array import FillStruct
|
|
15
|
-
from warp.tests.
|
|
15
|
+
from warp.tests.unittest_utils import *
|
|
16
16
|
|
|
17
17
|
wp.init()
|
|
18
18
|
|
|
@@ -1106,31 +1106,29 @@ def test_indexedarray_fill_struct(test, device):
|
|
|
1106
1106
|
assert_np_equal(a4.numpy(), np.zeros(a4.shape, dtype=nptype))
|
|
1107
1107
|
|
|
1108
1108
|
|
|
1109
|
-
|
|
1110
|
-
devices = get_test_devices()
|
|
1109
|
+
devices = get_test_devices()
|
|
1111
1110
|
|
|
1112
|
-
class TestIndexedArray(parent):
|
|
1113
|
-
pass
|
|
1114
1111
|
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
add_function_test(TestIndexedArray, "test_indexedarray_3d", test_indexedarray_3d, devices=devices)
|
|
1118
|
-
add_function_test(TestIndexedArray, "test_indexedarray_4d", test_indexedarray_4d, devices=devices)
|
|
1119
|
-
add_function_test(TestIndexedArray, "test_indexedarray_mixed", test_indexedarray_mixed, devices=devices)
|
|
1120
|
-
add_function_test(TestIndexedArray, "test_indexedarray_shape", test_indexedarray_shape, devices=devices)
|
|
1121
|
-
add_function_test(TestIndexedArray, "test_indexedarray_getitem", test_indexedarray_getitem, devices=devices)
|
|
1122
|
-
add_function_test(TestIndexedArray, "test_indexedarray_slicing", test_indexedarray_slicing, devices=devices)
|
|
1123
|
-
add_function_test(TestIndexedArray, "test_indexedarray_generics", test_indexedarray_generics, devices=devices)
|
|
1124
|
-
add_function_test(TestIndexedArray, "test_indexedarray_empty", test_indexedarray_empty, devices=devices)
|
|
1125
|
-
add_function_test(TestIndexedArray, "test_indexedarray_fill_scalar", test_indexedarray_fill_scalar, devices=devices)
|
|
1126
|
-
add_function_test(TestIndexedArray, "test_indexedarray_fill_vector", test_indexedarray_fill_vector, devices=devices)
|
|
1127
|
-
add_function_test(TestIndexedArray, "test_indexedarray_fill_matrix", test_indexedarray_fill_matrix, devices=devices)
|
|
1128
|
-
add_function_test(TestIndexedArray, "test_indexedarray_fill_struct", test_indexedarray_fill_struct, devices=devices)
|
|
1112
|
+
class TestIndexedArray(unittest.TestCase):
|
|
1113
|
+
pass
|
|
1129
1114
|
|
|
1130
|
-
|
|
1115
|
+
|
|
1116
|
+
add_function_test(TestIndexedArray, "test_indexedarray_1d", test_indexedarray_1d, devices=devices)
|
|
1117
|
+
add_function_test(TestIndexedArray, "test_indexedarray_2d", test_indexedarray_2d, devices=devices)
|
|
1118
|
+
add_function_test(TestIndexedArray, "test_indexedarray_3d", test_indexedarray_3d, devices=devices)
|
|
1119
|
+
add_function_test(TestIndexedArray, "test_indexedarray_4d", test_indexedarray_4d, devices=devices)
|
|
1120
|
+
add_function_test(TestIndexedArray, "test_indexedarray_mixed", test_indexedarray_mixed, devices=devices)
|
|
1121
|
+
add_function_test(TestIndexedArray, "test_indexedarray_shape", test_indexedarray_shape, devices=devices)
|
|
1122
|
+
add_function_test(TestIndexedArray, "test_indexedarray_getitem", test_indexedarray_getitem, devices=devices)
|
|
1123
|
+
add_function_test(TestIndexedArray, "test_indexedarray_slicing", test_indexedarray_slicing, devices=devices)
|
|
1124
|
+
add_function_test(TestIndexedArray, "test_indexedarray_generics", test_indexedarray_generics, devices=devices)
|
|
1125
|
+
add_function_test(TestIndexedArray, "test_indexedarray_empty", test_indexedarray_empty, devices=devices)
|
|
1126
|
+
add_function_test(TestIndexedArray, "test_indexedarray_fill_scalar", test_indexedarray_fill_scalar, devices=devices)
|
|
1127
|
+
add_function_test(TestIndexedArray, "test_indexedarray_fill_vector", test_indexedarray_fill_vector, devices=devices)
|
|
1128
|
+
add_function_test(TestIndexedArray, "test_indexedarray_fill_matrix", test_indexedarray_fill_matrix, devices=devices)
|
|
1129
|
+
add_function_test(TestIndexedArray, "test_indexedarray_fill_struct", test_indexedarray_fill_struct, devices=devices)
|
|
1131
1130
|
|
|
1132
1131
|
|
|
1133
1132
|
if __name__ == "__main__":
|
|
1134
1133
|
wp.build.clear_kernel_cache()
|
|
1135
|
-
_ = register(unittest.TestCase)
|
|
1136
1134
|
unittest.main(verbosity=2)
|
warp/tests/test_intersect.py
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved.
|
|
2
|
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
|
3
|
+
# and proprietary rights in and to this software, related documentation
|
|
4
|
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
|
5
|
+
# distribution of this software and related documentation without an express
|
|
6
|
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
|
+
|
|
1
8
|
import unittest
|
|
2
9
|
|
|
3
|
-
import warp as wp
|
|
4
10
|
import numpy as np
|
|
5
|
-
|
|
11
|
+
|
|
12
|
+
import warp as wp
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
6
14
|
|
|
7
15
|
wp.init()
|
|
8
16
|
|
|
@@ -44,18 +52,16 @@ def test_intersect_tri(test, device):
|
|
|
44
52
|
assert_np_equal(result.numpy(), np.array([0]))
|
|
45
53
|
|
|
46
54
|
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
devices = get_test_devices()
|
|
56
|
+
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
class TestIntersect(unittest.TestCase):
|
|
59
|
+
pass
|
|
52
60
|
|
|
53
|
-
add_function_test(TestIntersect, "test_intersect_tri", test_intersect_tri, devices=devices)
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
add_function_test(TestIntersect, "test_intersect_tri", test_intersect_tri, devices=devices)
|
|
56
63
|
|
|
57
64
|
|
|
58
65
|
if __name__ == "__main__":
|
|
59
66
|
wp.build.clear_kernel_cache()
|
|
60
|
-
_ = register(unittest.TestCase)
|
|
61
67
|
unittest.main(verbosity=2, failfast=False)
|
warp/tests/test_large.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c)
|
|
1
|
+
# Copyright (c) 2023 NVIDIA CORPORATION. All rights reserved.
|
|
2
2
|
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
|
3
3
|
# and proprietary rights in and to this software, related documentation
|
|
4
4
|
# and any modifications thereto. Any use, reproduction, disclosure or
|
|
@@ -9,7 +9,7 @@ import math
|
|
|
9
9
|
import unittest
|
|
10
10
|
|
|
11
11
|
import warp as wp
|
|
12
|
-
from warp.tests.
|
|
12
|
+
from warp.tests.unittest_utils import *
|
|
13
13
|
|
|
14
14
|
wp.init()
|
|
15
15
|
|
|
@@ -114,30 +114,28 @@ def test_large_arrays_fast(test, device):
|
|
|
114
114
|
assert_np_equal(a1.numpy(), np.zeros_like(a1.numpy()))
|
|
115
115
|
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
devices = get_test_devices()
|
|
117
|
+
devices = get_test_devices()
|
|
119
118
|
|
|
120
|
-
class TestLarge(parent):
|
|
121
|
-
pass
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
)
|
|
120
|
+
class TestLarge(unittest.TestCase):
|
|
121
|
+
pass
|
|
126
122
|
|
|
127
|
-
add_function_test(TestLarge, "test_large_launch_max_blocks", test_large_launch_max_blocks, devices=devices)
|
|
128
|
-
add_function_test(
|
|
129
|
-
TestLarge,
|
|
130
|
-
"test_large_launch_very_large_kernel",
|
|
131
|
-
test_large_launch_very_large_kernel,
|
|
132
|
-
devices=wp.get_cuda_devices(),
|
|
133
|
-
)
|
|
134
123
|
|
|
135
|
-
|
|
124
|
+
add_function_test(
|
|
125
|
+
TestLarge, "test_large_launch_large_kernel", test_large_launch_large_kernel, devices=get_unique_cuda_test_devices()
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
add_function_test(TestLarge, "test_large_launch_max_blocks", test_large_launch_max_blocks, devices=devices)
|
|
129
|
+
add_function_test(
|
|
130
|
+
TestLarge,
|
|
131
|
+
"test_large_launch_very_large_kernel",
|
|
132
|
+
test_large_launch_very_large_kernel,
|
|
133
|
+
devices=get_unique_cuda_test_devices(),
|
|
134
|
+
)
|
|
136
135
|
|
|
137
|
-
|
|
136
|
+
add_function_test(TestLarge, "test_large_arrays_fast", test_large_arrays_fast, devices=devices)
|
|
138
137
|
|
|
139
138
|
|
|
140
139
|
if __name__ == "__main__":
|
|
141
140
|
wp.build.clear_kernel_cache()
|
|
142
|
-
_ = register(unittest.TestCase)
|
|
143
141
|
unittest.main(verbosity=2)
|
warp/tests/test_launch.py
CHANGED
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import unittest
|
|
9
9
|
|
|
10
|
-
# include parent path
|
|
11
10
|
import numpy as np
|
|
12
11
|
|
|
13
12
|
import warp as wp
|
|
14
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
15
14
|
|
|
16
15
|
wp.init()
|
|
17
16
|
|
|
@@ -306,27 +305,25 @@ def test_launch_tuple_args(test, device):
|
|
|
306
305
|
assert_np_equal(out.numpy(), np.array((0, 3, 6, 9)))
|
|
307
306
|
|
|
308
307
|
|
|
309
|
-
|
|
310
|
-
devices = get_test_devices()
|
|
308
|
+
devices = get_test_devices()
|
|
311
309
|
|
|
312
|
-
class TestLaunch(parent):
|
|
313
|
-
pass
|
|
314
310
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
add_function_test(TestLaunch, "test_launch_3d", test3d, devices=devices)
|
|
318
|
-
add_function_test(TestLaunch, "test_launch_4d", test4d, devices=devices)
|
|
311
|
+
class TestLaunch(unittest.TestCase):
|
|
312
|
+
pass
|
|
319
313
|
|
|
320
|
-
add_function_test(TestLaunch, "test_launch_cmd", test_launch_cmd, devices=devices)
|
|
321
|
-
add_function_test(TestLaunch, "test_launch_cmd_set_param", test_launch_cmd_set_param, devices=devices)
|
|
322
|
-
add_function_test(TestLaunch, "test_launch_cmd_set_ctype", test_launch_cmd_set_ctype, devices=devices)
|
|
323
|
-
add_function_test(TestLaunch, "test_launch_cmd_set_dim", test_launch_cmd_set_dim, devices=devices)
|
|
324
|
-
add_function_test(TestLaunch, "test_launch_cmd_empty", test_launch_cmd_empty, devices=devices)
|
|
325
314
|
|
|
326
|
-
|
|
315
|
+
add_function_test(TestLaunch, "test_launch_1d", test1d, devices=devices)
|
|
316
|
+
add_function_test(TestLaunch, "test_launch_2d", test2d, devices=devices)
|
|
317
|
+
add_function_test(TestLaunch, "test_launch_3d", test3d, devices=devices)
|
|
318
|
+
add_function_test(TestLaunch, "test_launch_4d", test4d, devices=devices)
|
|
319
|
+
|
|
320
|
+
add_function_test(TestLaunch, "test_launch_cmd", test_launch_cmd, devices=devices)
|
|
321
|
+
add_function_test(TestLaunch, "test_launch_cmd_set_param", test_launch_cmd_set_param, devices=devices)
|
|
322
|
+
add_function_test(TestLaunch, "test_launch_cmd_set_ctype", test_launch_cmd_set_ctype, devices=devices)
|
|
323
|
+
add_function_test(TestLaunch, "test_launch_cmd_set_dim", test_launch_cmd_set_dim, devices=devices)
|
|
324
|
+
add_function_test(TestLaunch, "test_launch_cmd_empty", test_launch_cmd_empty, devices=devices)
|
|
327
325
|
|
|
328
326
|
|
|
329
327
|
if __name__ == "__main__":
|
|
330
328
|
wp.build.clear_kernel_cache()
|
|
331
|
-
_ = register(unittest.TestCase)
|
|
332
329
|
unittest.main(verbosity=2)
|
warp/tests/test_lerp.py
CHANGED
|
@@ -5,14 +5,16 @@
|
|
|
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 unittest
|
|
8
9
|
from dataclasses import dataclass
|
|
9
10
|
from typing import Any
|
|
10
|
-
import unittest
|
|
11
11
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
|
|
14
14
|
import warp as wp
|
|
15
|
-
from warp.tests.
|
|
15
|
+
from warp.tests.unittest_utils import *
|
|
16
|
+
|
|
17
|
+
wp.init()
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
@dataclass
|
|
@@ -162,8 +164,6 @@ TEST_DATA = {
|
|
|
162
164
|
),
|
|
163
165
|
}
|
|
164
166
|
|
|
165
|
-
wp.init()
|
|
166
|
-
|
|
167
167
|
|
|
168
168
|
def test_lerp(test, device):
|
|
169
169
|
def make_kernel_fn(data_type):
|
|
@@ -184,78 +184,78 @@ def test_lerp(test, device):
|
|
|
184
184
|
key=f"test_lerp_{data_type.__name__}_kernel",
|
|
185
185
|
)
|
|
186
186
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
requires_grad=True,
|
|
193
|
-
)
|
|
194
|
-
b = wp.array(
|
|
195
|
-
[test_data.b],
|
|
196
|
-
dtype=data_type,
|
|
197
|
-
device=device,
|
|
198
|
-
requires_grad=True,
|
|
199
|
-
)
|
|
200
|
-
t = wp.array(
|
|
201
|
-
[test_data.t],
|
|
202
|
-
dtype=float,
|
|
203
|
-
device=device,
|
|
204
|
-
requires_grad=True,
|
|
205
|
-
)
|
|
206
|
-
out = wp.array(
|
|
207
|
-
[0] * wp.types.type_length(data_type),
|
|
208
|
-
dtype=data_type,
|
|
209
|
-
device=device,
|
|
210
|
-
requires_grad=True,
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
tape = wp.Tape()
|
|
214
|
-
with tape:
|
|
215
|
-
wp.launch(
|
|
216
|
-
kernel,
|
|
217
|
-
dim=1,
|
|
218
|
-
inputs=[a, b, t, out],
|
|
187
|
+
with test.subTest(data_type=data_type):
|
|
188
|
+
for test_data in TEST_DATA[data_type]:
|
|
189
|
+
a = wp.array(
|
|
190
|
+
[test_data.a],
|
|
191
|
+
dtype=data_type,
|
|
219
192
|
device=device,
|
|
193
|
+
requires_grad=True,
|
|
220
194
|
)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
if test_data.check_backwards():
|
|
229
|
-
tape.backward(out)
|
|
230
|
-
|
|
231
|
-
assert_np_equal(
|
|
232
|
-
tape.gradients[a].numpy(),
|
|
233
|
-
np.array([test_data.expected_adj_a]),
|
|
234
|
-
tol=1e-6,
|
|
195
|
+
b = wp.array(
|
|
196
|
+
[test_data.b],
|
|
197
|
+
dtype=data_type,
|
|
198
|
+
device=device,
|
|
199
|
+
requires_grad=True,
|
|
235
200
|
)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
201
|
+
t = wp.array(
|
|
202
|
+
[test_data.t],
|
|
203
|
+
dtype=float,
|
|
204
|
+
device=device,
|
|
205
|
+
requires_grad=True,
|
|
206
|
+
)
|
|
207
|
+
out = wp.array(
|
|
208
|
+
[0] * wp.types.type_length(data_type),
|
|
209
|
+
dtype=data_type,
|
|
210
|
+
device=device,
|
|
211
|
+
requires_grad=True,
|
|
240
212
|
)
|
|
213
|
+
|
|
214
|
+
tape = wp.Tape()
|
|
215
|
+
with tape:
|
|
216
|
+
wp.launch(
|
|
217
|
+
kernel,
|
|
218
|
+
dim=1,
|
|
219
|
+
inputs=[a, b, t, out],
|
|
220
|
+
device=device,
|
|
221
|
+
)
|
|
222
|
+
|
|
241
223
|
assert_np_equal(
|
|
242
|
-
|
|
243
|
-
np.array([test_data.
|
|
224
|
+
out.numpy(),
|
|
225
|
+
np.array([test_data.expected]),
|
|
244
226
|
tol=1e-6,
|
|
245
227
|
)
|
|
246
228
|
|
|
229
|
+
if test_data.check_backwards():
|
|
230
|
+
tape.backward(out)
|
|
231
|
+
|
|
232
|
+
assert_np_equal(
|
|
233
|
+
tape.gradients[a].numpy(),
|
|
234
|
+
np.array([test_data.expected_adj_a]),
|
|
235
|
+
tol=1e-6,
|
|
236
|
+
)
|
|
237
|
+
assert_np_equal(
|
|
238
|
+
tape.gradients[b].numpy(),
|
|
239
|
+
np.array([test_data.expected_adj_b]),
|
|
240
|
+
tol=1e-6,
|
|
241
|
+
)
|
|
242
|
+
assert_np_equal(
|
|
243
|
+
tape.gradients[t].numpy(),
|
|
244
|
+
np.array([test_data.expected_adj_t]),
|
|
245
|
+
tol=1e-6,
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
devices = get_test_devices()
|
|
250
|
+
|
|
247
251
|
|
|
248
|
-
|
|
249
|
-
|
|
252
|
+
class TestLerp(unittest.TestCase):
|
|
253
|
+
pass
|
|
250
254
|
|
|
251
|
-
class TestLerp(parent):
|
|
252
|
-
pass
|
|
253
255
|
|
|
254
|
-
|
|
255
|
-
return TestLerp
|
|
256
|
+
add_function_test(TestLerp, "test_lerp", test_lerp, devices=devices)
|
|
256
257
|
|
|
257
258
|
|
|
258
259
|
if __name__ == "__main__":
|
|
259
260
|
wp.build.clear_kernel_cache()
|
|
260
|
-
_ = register(unittest.TestCase)
|
|
261
261
|
unittest.main(verbosity=2)
|