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_arithmetic.py
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
import unittest
|
|
9
9
|
|
|
10
10
|
import numpy as np
|
|
11
|
+
|
|
11
12
|
import warp as wp
|
|
12
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
13
14
|
|
|
14
15
|
wp.init()
|
|
15
16
|
|
|
@@ -1040,52 +1041,50 @@ def test_clamp(test, device, dtype, register_kernels=False):
|
|
|
1040
1041
|
tape.zero()
|
|
1041
1042
|
|
|
1042
1043
|
|
|
1043
|
-
|
|
1044
|
-
devices = get_test_devices()
|
|
1044
|
+
devices = get_test_devices()
|
|
1045
1045
|
|
|
1046
|
-
class TestArithmetic(parent):
|
|
1047
|
-
pass
|
|
1048
1046
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
add_function_test_register_kernel(
|
|
1052
|
-
TestArithmetic, f"test_unary_ops_{dtype.__name__}", test_unary_ops, devices=devices, dtype=dtype
|
|
1053
|
-
)
|
|
1047
|
+
class TestArithmetic(unittest.TestCase):
|
|
1048
|
+
pass
|
|
1054
1049
|
|
|
1055
|
-
for dtype in np_float_types:
|
|
1056
|
-
add_function_test_register_kernel(
|
|
1057
|
-
TestArithmetic, f"test_special_funcs_{dtype.__name__}", test_special_funcs, devices=devices, dtype=dtype
|
|
1058
|
-
)
|
|
1059
|
-
add_function_test_register_kernel(
|
|
1060
|
-
TestArithmetic,
|
|
1061
|
-
f"test_special_funcs_2arg_{dtype.__name__}",
|
|
1062
|
-
test_special_funcs_2arg,
|
|
1063
|
-
devices=devices,
|
|
1064
|
-
dtype=dtype,
|
|
1065
|
-
)
|
|
1066
|
-
add_function_test_register_kernel(
|
|
1067
|
-
TestArithmetic, f"test_interp_{dtype.__name__}", test_interp, devices=devices, dtype=dtype
|
|
1068
|
-
)
|
|
1069
|
-
add_function_test_register_kernel(
|
|
1070
|
-
TestArithmetic, f"test_float_to_int_{dtype.__name__}", test_float_to_int, devices=devices, dtype=dtype
|
|
1071
|
-
)
|
|
1072
1050
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
TestArithmetic, f"test_nonzero_{dtype.__name__}", test_nonzero, devices=devices, dtype=dtype
|
|
1079
|
-
)
|
|
1080
|
-
add_function_test(TestArithmetic, f"test_arrays_{dtype.__name__}", test_arrays, devices=devices, dtype=dtype)
|
|
1081
|
-
add_function_test_register_kernel(
|
|
1082
|
-
TestArithmetic, f"test_binary_ops_{dtype.__name__}", test_binary_ops, devices=devices, dtype=dtype
|
|
1083
|
-
)
|
|
1051
|
+
# these unary ops only make sense for signed values:
|
|
1052
|
+
for dtype in np_signed_int_types + np_float_types:
|
|
1053
|
+
add_function_test_register_kernel(
|
|
1054
|
+
TestArithmetic, f"test_unary_ops_{dtype.__name__}", test_unary_ops, devices=devices, dtype=dtype
|
|
1055
|
+
)
|
|
1084
1056
|
|
|
1085
|
-
|
|
1057
|
+
for dtype in np_float_types:
|
|
1058
|
+
add_function_test_register_kernel(
|
|
1059
|
+
TestArithmetic, f"test_special_funcs_{dtype.__name__}", test_special_funcs, devices=devices, dtype=dtype
|
|
1060
|
+
)
|
|
1061
|
+
add_function_test_register_kernel(
|
|
1062
|
+
TestArithmetic,
|
|
1063
|
+
f"test_special_funcs_2arg_{dtype.__name__}",
|
|
1064
|
+
test_special_funcs_2arg,
|
|
1065
|
+
devices=devices,
|
|
1066
|
+
dtype=dtype,
|
|
1067
|
+
)
|
|
1068
|
+
add_function_test_register_kernel(
|
|
1069
|
+
TestArithmetic, f"test_interp_{dtype.__name__}", test_interp, devices=devices, dtype=dtype
|
|
1070
|
+
)
|
|
1071
|
+
add_function_test_register_kernel(
|
|
1072
|
+
TestArithmetic, f"test_float_to_int_{dtype.__name__}", test_float_to_int, devices=devices, dtype=dtype
|
|
1073
|
+
)
|
|
1074
|
+
|
|
1075
|
+
for dtype in np_scalar_types:
|
|
1076
|
+
add_function_test_register_kernel(
|
|
1077
|
+
TestArithmetic, f"test_clamp_{dtype.__name__}", test_clamp, devices=devices, dtype=dtype
|
|
1078
|
+
)
|
|
1079
|
+
add_function_test_register_kernel(
|
|
1080
|
+
TestArithmetic, f"test_nonzero_{dtype.__name__}", test_nonzero, devices=devices, dtype=dtype
|
|
1081
|
+
)
|
|
1082
|
+
add_function_test(TestArithmetic, f"test_arrays_{dtype.__name__}", test_arrays, devices=devices, dtype=dtype)
|
|
1083
|
+
add_function_test_register_kernel(
|
|
1084
|
+
TestArithmetic, f"test_binary_ops_{dtype.__name__}", test_binary_ops, devices=devices, dtype=dtype
|
|
1085
|
+
)
|
|
1086
1086
|
|
|
1087
1087
|
|
|
1088
1088
|
if __name__ == "__main__":
|
|
1089
1089
|
wp.build.clear_kernel_cache()
|
|
1090
|
-
_ = register(unittest.TestCase)
|
|
1091
1090
|
unittest.main(verbosity=2, failfast=False)
|
warp/tests/test_array.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
|
|
|
@@ -2085,55 +2085,53 @@ def test_array_from_numpy(test, device):
|
|
|
2085
2085
|
assert_np_equal(result.numpy(), expected.numpy())
|
|
2086
2086
|
|
|
2087
2087
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
return TestArray
|
|
2088
|
+
devices = get_test_devices()
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
class TestArray(unittest.TestCase):
|
|
2092
|
+
pass
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
add_function_test(TestArray, "test_shape", test_shape, devices=devices)
|
|
2096
|
+
add_function_test(TestArray, "test_flatten", test_flatten, devices=devices)
|
|
2097
|
+
add_function_test(TestArray, "test_reshape", test_reshape, devices=devices)
|
|
2098
|
+
add_function_test(TestArray, "test_slicing", test_slicing, devices=devices)
|
|
2099
|
+
add_function_test(TestArray, "test_transpose", test_transpose, devices=devices)
|
|
2100
|
+
add_function_test(TestArray, "test_view", test_view, devices=devices)
|
|
2101
|
+
|
|
2102
|
+
add_function_test(TestArray, "test_1d_array", test_1d, devices=devices)
|
|
2103
|
+
add_function_test(TestArray, "test_2d_array", test_2d, devices=devices)
|
|
2104
|
+
add_function_test(TestArray, "test_3d_array", test_3d, devices=devices)
|
|
2105
|
+
add_function_test(TestArray, "test_4d_array", test_4d, devices=devices)
|
|
2106
|
+
add_function_test(TestArray, "test_4d_array_transposed", test_4d_transposed, devices=devices)
|
|
2107
|
+
|
|
2108
|
+
add_function_test(TestArray, "test_fill_scalar", test_fill_scalar, devices=devices)
|
|
2109
|
+
add_function_test(TestArray, "test_fill_vector", test_fill_vector, devices=devices)
|
|
2110
|
+
add_function_test(TestArray, "test_fill_matrix", test_fill_matrix, devices=devices)
|
|
2111
|
+
add_function_test(TestArray, "test_fill_struct", test_fill_struct, devices=devices)
|
|
2112
|
+
add_function_test(TestArray, "test_fill_slices", test_fill_slices, devices=devices)
|
|
2113
|
+
add_function_test(TestArray, "test_full_scalar", test_full_scalar, devices=devices)
|
|
2114
|
+
add_function_test(TestArray, "test_full_vector", test_full_vector, devices=devices)
|
|
2115
|
+
add_function_test(TestArray, "test_full_matrix", test_full_matrix, devices=devices)
|
|
2116
|
+
add_function_test(TestArray, "test_full_struct", test_full_struct, devices=devices)
|
|
2117
|
+
add_function_test(TestArray, "test_empty_array", test_empty_array, devices=devices)
|
|
2118
|
+
add_function_test(TestArray, "test_empty_from_numpy", test_empty_from_numpy, devices=devices)
|
|
2119
|
+
add_function_test(TestArray, "test_empty_from_list", test_empty_from_list, devices=devices)
|
|
2120
|
+
add_function_test(TestArray, "test_to_list_scalar", test_to_list_scalar, devices=devices)
|
|
2121
|
+
add_function_test(TestArray, "test_to_list_vector", test_to_list_vector, devices=devices)
|
|
2122
|
+
add_function_test(TestArray, "test_to_list_matrix", test_to_list_matrix, devices=devices)
|
|
2123
|
+
add_function_test(TestArray, "test_to_list_struct", test_to_list_struct, devices=devices)
|
|
2124
|
+
|
|
2125
|
+
add_function_test(TestArray, "test_lower_bound", test_lower_bound, devices=devices)
|
|
2126
|
+
add_function_test(TestArray, "test_round_trip", test_round_trip, devices=devices)
|
|
2127
|
+
add_function_test(TestArray, "test_array_to_bool", test_array_to_bool, devices=devices)
|
|
2128
|
+
add_function_test(TestArray, "test_array_of_structs", test_array_of_structs, devices=devices)
|
|
2129
|
+
add_function_test(TestArray, "test_array_of_structs_grad", test_array_of_structs_grad, devices=devices)
|
|
2130
|
+
add_function_test(TestArray, "test_array_of_structs_from_numpy", test_array_of_structs_from_numpy, devices=devices)
|
|
2131
|
+
add_function_test(TestArray, "test_array_of_structs_roundtrip", test_array_of_structs_roundtrip, devices=devices)
|
|
2132
|
+
add_function_test(TestArray, "test_array_from_numpy", test_array_from_numpy, devices=devices)
|
|
2134
2133
|
|
|
2135
2134
|
|
|
2136
2135
|
if __name__ == "__main__":
|
|
2137
2136
|
wp.build.clear_kernel_cache()
|
|
2138
|
-
_ = register(unittest.TestCase)
|
|
2139
2137
|
unittest.main(verbosity=2)
|
warp/tests/test_array_reduce.py
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
# Copyright (c) 2023 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
|
|
9
|
+
|
|
2
10
|
import numpy as np
|
|
3
|
-
import warp as wp
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
from warp.tests.
|
|
12
|
+
import warp as wp
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
14
|
+
from warp.utils import array_inner, array_sum
|
|
7
15
|
|
|
8
16
|
wp.init()
|
|
9
17
|
|
|
@@ -118,27 +126,25 @@ def test_array_inner_empty(test, device):
|
|
|
118
126
|
assert_np_equal(array_inner(values, values, axis=0).numpy(), np.zeros(3))
|
|
119
127
|
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
devices = get_test_devices()
|
|
130
|
+
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
class TestArrayReduce(unittest.TestCase):
|
|
133
|
+
pass
|
|
126
134
|
|
|
127
|
-
add_function_test(TestArraySym, "test_array_sum_double", make_test_array_sum(wp.float64), devices=devices)
|
|
128
|
-
add_function_test(TestArraySym, "test_array_sum_vec3", make_test_array_sum(wp.vec3), devices=devices)
|
|
129
|
-
add_function_test(TestArraySym, "test_array_sum_axis_float", make_test_array_sum_axis(wp.float32), devices=devices)
|
|
130
|
-
add_function_test(TestArraySym, "test_array_sum_empty", test_array_sum_empty, devices=devices)
|
|
131
|
-
add_function_test(TestArraySym, "test_array_inner_double", make_test_array_inner(wp.float64), devices=devices)
|
|
132
|
-
add_function_test(TestArraySym, "test_array_inner_vec3", make_test_array_inner(wp.vec3), devices=devices)
|
|
133
|
-
add_function_test(
|
|
134
|
-
TestArraySym, "test_array_inner_axis_float", make_test_array_inner_axis(wp.float32), devices=devices
|
|
135
|
-
)
|
|
136
|
-
add_function_test(TestArraySym, "test_array_inner_empty", test_array_inner_empty, devices=devices)
|
|
137
135
|
|
|
138
|
-
|
|
136
|
+
add_function_test(TestArrayReduce, "test_array_sum_double", make_test_array_sum(wp.float64), devices=devices)
|
|
137
|
+
add_function_test(TestArrayReduce, "test_array_sum_vec3", make_test_array_sum(wp.vec3), devices=devices)
|
|
138
|
+
add_function_test(TestArrayReduce, "test_array_sum_axis_float", make_test_array_sum_axis(wp.float32), devices=devices)
|
|
139
|
+
add_function_test(TestArrayReduce, "test_array_sum_empty", test_array_sum_empty, devices=devices)
|
|
140
|
+
add_function_test(TestArrayReduce, "test_array_inner_double", make_test_array_inner(wp.float64), devices=devices)
|
|
141
|
+
add_function_test(TestArrayReduce, "test_array_inner_vec3", make_test_array_inner(wp.vec3), devices=devices)
|
|
142
|
+
add_function_test(
|
|
143
|
+
TestArrayReduce, "test_array_inner_axis_float", make_test_array_inner_axis(wp.float32), devices=devices
|
|
144
|
+
)
|
|
145
|
+
add_function_test(TestArrayReduce, "test_array_inner_empty", test_array_inner_empty, devices=devices)
|
|
139
146
|
|
|
140
147
|
|
|
141
148
|
if __name__ == "__main__":
|
|
142
149
|
wp.build.clear_kernel_cache()
|
|
143
|
-
_ = register(unittest.TestCase)
|
|
144
150
|
unittest.main(verbosity=2)
|
warp/tests/test_atomic.py
CHANGED
|
@@ -5,14 +5,12 @@
|
|
|
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
|
-
|
|
8
|
+
import unittest
|
|
9
|
+
|
|
9
10
|
import numpy as np
|
|
10
|
-
import math
|
|
11
11
|
|
|
12
12
|
import warp as wp
|
|
13
|
-
from warp.tests.
|
|
14
|
-
|
|
15
|
-
import unittest
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
16
14
|
|
|
17
15
|
wp.init()
|
|
18
16
|
|
|
@@ -53,20 +51,60 @@ def make_atomic_test(type):
|
|
|
53
51
|
base = rng.random(size=(1, *type._shape_), dtype=float)
|
|
54
52
|
val = rng.random(size=(n, *type._shape_), dtype=float)
|
|
55
53
|
|
|
56
|
-
add_array = wp.array(base, dtype=type, device=device)
|
|
57
|
-
min_array = wp.array(base, dtype=type, device=device)
|
|
58
|
-
max_array = wp.array(base, dtype=type, device=device)
|
|
54
|
+
add_array = wp.array(base, dtype=type, device=device, requires_grad=True)
|
|
55
|
+
min_array = wp.array(base, dtype=type, device=device, requires_grad=True)
|
|
56
|
+
max_array = wp.array(base, dtype=type, device=device, requires_grad=True)
|
|
57
|
+
add_array.zero_()
|
|
58
|
+
min_array.fill_(10000)
|
|
59
|
+
max_array.fill_(-10000)
|
|
59
60
|
|
|
60
|
-
val_array = wp.array(val, dtype=type, device=device)
|
|
61
|
+
val_array = wp.array(val, dtype=type, device=device, requires_grad=True)
|
|
61
62
|
|
|
62
|
-
wp.
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
tape = wp.Tape()
|
|
64
|
+
with tape:
|
|
65
|
+
wp.launch(kernel, n, inputs=[add_array, min_array, max_array, val_array], device=device)
|
|
65
66
|
|
|
66
67
|
assert_np_equal(add_array.numpy(), np.sum(val, axis=0), tol=1.0e-2)
|
|
67
68
|
assert_np_equal(min_array.numpy(), np.min(val, axis=0), tol=1.0e-2)
|
|
68
69
|
assert_np_equal(max_array.numpy(), np.max(val, axis=0), tol=1.0e-2)
|
|
69
70
|
|
|
71
|
+
if type != wp.int32:
|
|
72
|
+
add_array.grad.fill_(1)
|
|
73
|
+
tape.backward()
|
|
74
|
+
assert_np_equal(val_array.grad.numpy(), np.ones_like(val))
|
|
75
|
+
tape.zero()
|
|
76
|
+
|
|
77
|
+
min_array.grad.fill_(1)
|
|
78
|
+
tape.backward()
|
|
79
|
+
min_grad_array = np.zeros_like(val)
|
|
80
|
+
argmin = val.argmin(axis=0)
|
|
81
|
+
if val.ndim == 1:
|
|
82
|
+
min_grad_array[argmin] = 1
|
|
83
|
+
elif val.ndim == 2:
|
|
84
|
+
for i in range(val.shape[1]):
|
|
85
|
+
min_grad_array[argmin[i], i] = 1
|
|
86
|
+
elif val.ndim == 3:
|
|
87
|
+
for i in range(val.shape[1]):
|
|
88
|
+
for j in range(val.shape[2]):
|
|
89
|
+
min_grad_array[argmin[i, j], i, j] = 1
|
|
90
|
+
assert_np_equal(val_array.grad.numpy(), min_grad_array)
|
|
91
|
+
tape.zero()
|
|
92
|
+
|
|
93
|
+
max_array.grad.fill_(1)
|
|
94
|
+
tape.backward()
|
|
95
|
+
max_grad_array = np.zeros_like(val)
|
|
96
|
+
argmax = val.argmax(axis=0)
|
|
97
|
+
if val.ndim == 1:
|
|
98
|
+
max_grad_array[argmax] = 1
|
|
99
|
+
elif val.ndim == 2:
|
|
100
|
+
for i in range(val.shape[1]):
|
|
101
|
+
max_grad_array[argmax[i], i] = 1
|
|
102
|
+
elif val.ndim == 3:
|
|
103
|
+
for i in range(val.shape[1]):
|
|
104
|
+
for j in range(val.shape[2]):
|
|
105
|
+
max_grad_array[argmax[i, j], i, j] = 1
|
|
106
|
+
assert_np_equal(val_array.grad.numpy(), max_grad_array)
|
|
107
|
+
|
|
70
108
|
return test_atomic
|
|
71
109
|
|
|
72
110
|
|
|
@@ -81,25 +119,23 @@ test_atomic_mat33 = make_atomic_test(wp.mat33)
|
|
|
81
119
|
test_atomic_mat44 = make_atomic_test(wp.mat44)
|
|
82
120
|
|
|
83
121
|
|
|
84
|
-
|
|
85
|
-
|
|
122
|
+
devices = get_test_devices()
|
|
123
|
+
|
|
86
124
|
|
|
87
|
-
|
|
88
|
-
|
|
125
|
+
class TestAtomic(unittest.TestCase):
|
|
126
|
+
pass
|
|
89
127
|
|
|
90
|
-
add_function_test(TestAtomic, "test_atomic_int", test_atomic_int, devices=devices)
|
|
91
|
-
add_function_test(TestAtomic, "test_atomic_float", test_atomic_float, devices=devices)
|
|
92
|
-
add_function_test(TestAtomic, "test_atomic_vec2", test_atomic_vec2, devices=devices)
|
|
93
|
-
add_function_test(TestAtomic, "test_atomic_vec3", test_atomic_vec3, devices=devices)
|
|
94
|
-
add_function_test(TestAtomic, "test_atomic_vec4", test_atomic_vec4, devices=devices)
|
|
95
|
-
add_function_test(TestAtomic, "test_atomic_mat22", test_atomic_mat22, devices=devices)
|
|
96
|
-
add_function_test(TestAtomic, "test_atomic_mat33", test_atomic_mat33, devices=devices)
|
|
97
|
-
add_function_test(TestAtomic, "test_atomic_mat44", test_atomic_mat44, devices=devices)
|
|
98
128
|
|
|
99
|
-
|
|
129
|
+
add_function_test(TestAtomic, "test_atomic_int", test_atomic_int, devices=devices)
|
|
130
|
+
add_function_test(TestAtomic, "test_atomic_float", test_atomic_float, devices=devices)
|
|
131
|
+
add_function_test(TestAtomic, "test_atomic_vec2", test_atomic_vec2, devices=devices)
|
|
132
|
+
add_function_test(TestAtomic, "test_atomic_vec3", test_atomic_vec3, devices=devices)
|
|
133
|
+
add_function_test(TestAtomic, "test_atomic_vec4", test_atomic_vec4, devices=devices)
|
|
134
|
+
add_function_test(TestAtomic, "test_atomic_mat22", test_atomic_mat22, devices=devices)
|
|
135
|
+
add_function_test(TestAtomic, "test_atomic_mat33", test_atomic_mat33, devices=devices)
|
|
136
|
+
add_function_test(TestAtomic, "test_atomic_mat44", test_atomic_mat44, devices=devices)
|
|
100
137
|
|
|
101
138
|
|
|
102
139
|
if __name__ == "__main__":
|
|
103
140
|
wp.build.clear_kernel_cache()
|
|
104
|
-
_ = register(unittest.TestCase)
|
|
105
141
|
unittest.main(verbosity=2)
|
warp/tests/test_bool.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023 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
10
|
import numpy as np
|
|
4
11
|
|
|
5
12
|
import warp as wp
|
|
6
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
7
14
|
|
|
8
15
|
wp.init()
|
|
9
16
|
|
|
@@ -71,24 +78,22 @@ def check_compile_constant(result: wp.array(dtype=wp.bool)):
|
|
|
71
78
|
|
|
72
79
|
|
|
73
80
|
def test_bool_constant(test, device):
|
|
74
|
-
compile_constant_value = wp.zeros(1, dtype=wp.bool)
|
|
75
|
-
wp.launch(check_compile_constant, 1, inputs=[compile_constant_value])
|
|
81
|
+
compile_constant_value = wp.zeros(1, dtype=wp.bool, device=device)
|
|
82
|
+
wp.launch(check_compile_constant, 1, inputs=[compile_constant_value], device=device)
|
|
76
83
|
test.assertTrue(compile_constant_value.numpy()[0])
|
|
77
84
|
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
devices = get_test_devices()
|
|
87
|
+
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
class TestBool(unittest.TestCase):
|
|
90
|
+
pass
|
|
84
91
|
|
|
85
|
-
add_function_test(TestBool, "test_bool_identity_ops", test_bool_identity_ops, devices=devices)
|
|
86
|
-
add_function_test(TestBool, "test_bool_constant", test_bool_constant, devices=devices)
|
|
87
92
|
|
|
88
|
-
|
|
93
|
+
add_function_test(TestBool, "test_bool_identity_ops", test_bool_identity_ops, devices=devices)
|
|
94
|
+
add_function_test(TestBool, "test_bool_constant", test_bool_constant, devices=devices)
|
|
89
95
|
|
|
90
96
|
|
|
91
97
|
if __name__ == "__main__":
|
|
92
98
|
wp.build.clear_kernel_cache()
|
|
93
|
-
_ = register(unittest.TestCase)
|
|
94
99
|
unittest.main(verbosity=2)
|