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.
Files changed (187) hide show
  1. docs/conf.py +3 -4
  2. examples/env/env_ant.py +1 -1
  3. examples/env/env_cartpole.py +1 -1
  4. examples/env/env_humanoid.py +1 -1
  5. examples/example_dem.py +28 -26
  6. examples/example_diffray.py +37 -30
  7. examples/example_fluid.py +7 -3
  8. examples/example_jacobian_ik.py +1 -1
  9. examples/example_mesh_intersect.py +10 -7
  10. examples/example_nvdb.py +3 -3
  11. examples/example_render_opengl.py +19 -10
  12. examples/example_sim_cartpole.py +9 -5
  13. examples/example_sim_cloth.py +29 -25
  14. examples/example_sim_fk_grad.py +2 -2
  15. examples/example_sim_fk_grad_torch.py +3 -3
  16. examples/example_sim_grad_bounce.py +11 -8
  17. examples/example_sim_grad_cloth.py +12 -9
  18. examples/example_sim_granular.py +2 -2
  19. examples/example_sim_granular_collision_sdf.py +13 -13
  20. examples/example_sim_neo_hookean.py +3 -3
  21. examples/example_sim_particle_chain.py +2 -2
  22. examples/example_sim_quadruped.py +8 -5
  23. examples/example_sim_rigid_chain.py +8 -5
  24. examples/example_sim_rigid_contact.py +13 -10
  25. examples/example_sim_rigid_fem.py +2 -2
  26. examples/example_sim_rigid_gyroscopic.py +2 -2
  27. examples/example_sim_rigid_kinematics.py +1 -1
  28. examples/example_sim_trajopt.py +3 -2
  29. examples/fem/example_apic_fluid.py +5 -7
  30. examples/fem/example_diffusion_mgpu.py +18 -16
  31. warp/__init__.py +3 -2
  32. warp/bin/warp.so +0 -0
  33. warp/build_dll.py +29 -9
  34. warp/builtins.py +206 -7
  35. warp/codegen.py +58 -38
  36. warp/config.py +3 -1
  37. warp/context.py +234 -128
  38. warp/fem/__init__.py +2 -2
  39. warp/fem/cache.py +2 -1
  40. warp/fem/field/nodal_field.py +18 -17
  41. warp/fem/geometry/hexmesh.py +11 -6
  42. warp/fem/geometry/quadmesh_2d.py +16 -12
  43. warp/fem/geometry/tetmesh.py +19 -8
  44. warp/fem/geometry/trimesh_2d.py +18 -7
  45. warp/fem/integrate.py +341 -196
  46. warp/fem/quadrature/__init__.py +1 -1
  47. warp/fem/quadrature/pic_quadrature.py +138 -53
  48. warp/fem/quadrature/quadrature.py +81 -9
  49. warp/fem/space/__init__.py +1 -1
  50. warp/fem/space/basis_space.py +169 -51
  51. warp/fem/space/grid_2d_function_space.py +2 -2
  52. warp/fem/space/grid_3d_function_space.py +2 -2
  53. warp/fem/space/hexmesh_function_space.py +2 -2
  54. warp/fem/space/partition.py +9 -6
  55. warp/fem/space/quadmesh_2d_function_space.py +2 -2
  56. warp/fem/space/shape/cube_shape_function.py +27 -15
  57. warp/fem/space/shape/square_shape_function.py +29 -18
  58. warp/fem/space/tetmesh_function_space.py +2 -2
  59. warp/fem/space/topology.py +10 -0
  60. warp/fem/space/trimesh_2d_function_space.py +2 -2
  61. warp/fem/utils.py +10 -5
  62. warp/native/array.h +49 -8
  63. warp/native/builtin.h +31 -14
  64. warp/native/cuda_util.cpp +8 -3
  65. warp/native/cuda_util.h +1 -0
  66. warp/native/exports.h +1177 -1108
  67. warp/native/intersect.h +4 -4
  68. warp/native/intersect_adj.h +8 -8
  69. warp/native/mat.h +65 -6
  70. warp/native/mesh.h +126 -5
  71. warp/native/quat.h +28 -4
  72. warp/native/vec.h +76 -14
  73. warp/native/warp.cu +1 -6
  74. warp/render/render_opengl.py +261 -109
  75. warp/sim/import_mjcf.py +13 -7
  76. warp/sim/import_urdf.py +14 -14
  77. warp/sim/inertia.py +17 -18
  78. warp/sim/model.py +67 -67
  79. warp/sim/render.py +1 -1
  80. warp/sparse.py +6 -6
  81. warp/stubs.py +19 -81
  82. warp/tape.py +1 -1
  83. warp/tests/__main__.py +3 -6
  84. warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
  85. warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
  86. warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
  87. warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
  88. warp/tests/aux_test_unresolved_func.py +14 -0
  89. warp/tests/aux_test_unresolved_symbol.py +14 -0
  90. warp/tests/{test_kinematics.py → disabled_kinematics.py} +10 -12
  91. warp/tests/run_coverage_serial.py +31 -0
  92. warp/tests/test_adam.py +102 -106
  93. warp/tests/test_arithmetic.py +39 -40
  94. warp/tests/test_array.py +46 -48
  95. warp/tests/test_array_reduce.py +25 -19
  96. warp/tests/test_atomic.py +62 -26
  97. warp/tests/test_bool.py +16 -11
  98. warp/tests/test_builtins_resolution.py +1292 -0
  99. warp/tests/test_bvh.py +9 -12
  100. warp/tests/test_closest_point_edge_edge.py +53 -57
  101. warp/tests/test_codegen.py +164 -134
  102. warp/tests/test_compile_consts.py +13 -19
  103. warp/tests/test_conditional.py +30 -32
  104. warp/tests/test_copy.py +9 -12
  105. warp/tests/test_ctypes.py +90 -98
  106. warp/tests/test_dense.py +20 -14
  107. warp/tests/test_devices.py +34 -35
  108. warp/tests/test_dlpack.py +74 -75
  109. warp/tests/test_examples.py +215 -97
  110. warp/tests/test_fabricarray.py +15 -21
  111. warp/tests/test_fast_math.py +14 -11
  112. warp/tests/test_fem.py +280 -97
  113. warp/tests/test_fp16.py +19 -15
  114. warp/tests/test_func.py +177 -194
  115. warp/tests/test_generics.py +71 -77
  116. warp/tests/test_grad.py +83 -32
  117. warp/tests/test_grad_customs.py +7 -9
  118. warp/tests/test_hash_grid.py +6 -10
  119. warp/tests/test_import.py +9 -23
  120. warp/tests/test_indexedarray.py +19 -21
  121. warp/tests/test_intersect.py +15 -9
  122. warp/tests/test_large.py +17 -19
  123. warp/tests/test_launch.py +14 -17
  124. warp/tests/test_lerp.py +63 -63
  125. warp/tests/test_lvalue.py +84 -35
  126. warp/tests/test_marching_cubes.py +9 -13
  127. warp/tests/test_mat.py +388 -3004
  128. warp/tests/test_mat_lite.py +9 -12
  129. warp/tests/test_mat_scalar_ops.py +2889 -0
  130. warp/tests/test_math.py +10 -11
  131. warp/tests/test_matmul.py +104 -100
  132. warp/tests/test_matmul_lite.py +72 -98
  133. warp/tests/test_mesh.py +35 -32
  134. warp/tests/test_mesh_query_aabb.py +18 -25
  135. warp/tests/test_mesh_query_point.py +39 -23
  136. warp/tests/test_mesh_query_ray.py +9 -21
  137. warp/tests/test_mlp.py +8 -9
  138. warp/tests/test_model.py +89 -93
  139. warp/tests/test_modules_lite.py +15 -25
  140. warp/tests/test_multigpu.py +87 -114
  141. warp/tests/test_noise.py +10 -12
  142. warp/tests/test_operators.py +14 -21
  143. warp/tests/test_options.py +10 -11
  144. warp/tests/test_pinned.py +16 -18
  145. warp/tests/test_print.py +16 -20
  146. warp/tests/test_quat.py +121 -88
  147. warp/tests/test_rand.py +12 -13
  148. warp/tests/test_reload.py +27 -32
  149. warp/tests/test_rounding.py +7 -10
  150. warp/tests/test_runlength_encode.py +105 -106
  151. warp/tests/test_smoothstep.py +8 -9
  152. warp/tests/test_snippet.py +13 -22
  153. warp/tests/test_sparse.py +30 -29
  154. warp/tests/test_spatial.py +179 -174
  155. warp/tests/test_streams.py +100 -107
  156. warp/tests/test_struct.py +98 -67
  157. warp/tests/test_tape.py +11 -17
  158. warp/tests/test_torch.py +89 -86
  159. warp/tests/test_transient_module.py +9 -12
  160. warp/tests/test_types.py +328 -50
  161. warp/tests/test_utils.py +217 -218
  162. warp/tests/test_vec.py +133 -2133
  163. warp/tests/test_vec_lite.py +8 -11
  164. warp/tests/test_vec_scalar_ops.py +2099 -0
  165. warp/tests/test_volume.py +391 -382
  166. warp/tests/test_volume_write.py +122 -135
  167. warp/tests/unittest_serial.py +35 -0
  168. warp/tests/unittest_suites.py +291 -0
  169. warp/tests/{test_base.py → unittest_utils.py} +138 -25
  170. warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
  171. warp/tests/{test_debug.py → walkthough_debug.py} +2 -15
  172. warp/thirdparty/unittest_parallel.py +257 -54
  173. warp/types.py +119 -98
  174. warp/utils.py +14 -0
  175. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/METADATA +2 -1
  176. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/RECORD +182 -178
  177. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
  178. warp/tests/test_all.py +0 -239
  179. warp/tests/test_conditional_unequal_types_kernels.py +0 -14
  180. warp/tests/test_coverage.py +0 -38
  181. warp/tests/test_unresolved_func.py +0 -7
  182. warp/tests/test_unresolved_symbol.py +0 -7
  183. /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
  184. /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
  185. /warp/tests/{test_square.py → aux_test_square.py} +0 -0
  186. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
  187. {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
@@ -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.test_base import *
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
- def register(parent):
1044
- devices = get_test_devices()
1044
+ devices = get_test_devices()
1045
1045
 
1046
- class TestArithmetic(parent):
1047
- pass
1048
1046
 
1049
- # these unary ops only make sense for signed values:
1050
- for dtype in np_signed_int_types + np_float_types:
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
- for dtype in np_scalar_types:
1074
- add_function_test_register_kernel(
1075
- TestArithmetic, f"test_clamp_{dtype.__name__}", test_clamp, devices=devices, dtype=dtype
1076
- )
1077
- add_function_test_register_kernel(
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
- return TestArithmetic
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.test_base import *
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
- def register(parent):
2089
- devices = get_test_devices()
2090
-
2091
- class TestArray(parent):
2092
- pass
2093
-
2094
- add_function_test(TestArray, "test_shape", test_shape, devices=devices)
2095
- add_function_test(TestArray, "test_flatten", test_flatten, devices=devices)
2096
- add_function_test(TestArray, "test_reshape", test_reshape, devices=devices)
2097
- add_function_test(TestArray, "test_slicing", test_slicing, devices=devices)
2098
- add_function_test(TestArray, "test_transpose", test_transpose, devices=devices)
2099
- add_function_test(TestArray, "test_view", test_view, devices=devices)
2100
-
2101
- add_function_test(TestArray, "test_1d_array", test_1d, devices=devices)
2102
- add_function_test(TestArray, "test_2d_array", test_2d, devices=devices)
2103
- add_function_test(TestArray, "test_3d_array", test_3d, devices=devices)
2104
- add_function_test(TestArray, "test_4d_array", test_4d, devices=devices)
2105
- add_function_test(TestArray, "test_4d_array_transposed", test_4d_transposed, devices=devices)
2106
-
2107
- add_function_test(TestArray, "test_fill_scalar", test_fill_scalar, devices=devices)
2108
- add_function_test(TestArray, "test_fill_vector", test_fill_vector, devices=devices)
2109
- add_function_test(TestArray, "test_fill_matrix", test_fill_matrix, devices=devices)
2110
- add_function_test(TestArray, "test_fill_struct", test_fill_struct, devices=devices)
2111
- add_function_test(TestArray, "test_fill_slices", test_fill_slices, devices=devices)
2112
- add_function_test(TestArray, "test_full_scalar", test_full_scalar, devices=devices)
2113
- add_function_test(TestArray, "test_full_vector", test_full_vector, devices=devices)
2114
- add_function_test(TestArray, "test_full_matrix", test_full_matrix, devices=devices)
2115
- add_function_test(TestArray, "test_full_struct", test_full_struct, devices=devices)
2116
- add_function_test(TestArray, "test_empty_array", test_empty_array, devices=devices)
2117
- add_function_test(TestArray, "test_empty_from_numpy", test_empty_from_numpy, devices=devices)
2118
- add_function_test(TestArray, "test_empty_from_list", test_empty_from_list, devices=devices)
2119
- add_function_test(TestArray, "test_to_list_scalar", test_to_list_scalar, devices=devices)
2120
- add_function_test(TestArray, "test_to_list_vector", test_to_list_vector, devices=devices)
2121
- add_function_test(TestArray, "test_to_list_matrix", test_to_list_matrix, devices=devices)
2122
- add_function_test(TestArray, "test_to_list_struct", test_to_list_struct, devices=devices)
2123
-
2124
- add_function_test(TestArray, "test_lower_bound", test_lower_bound, devices=devices)
2125
- add_function_test(TestArray, "test_round_trip", test_round_trip, devices=devices)
2126
- add_function_test(TestArray, "test_array_to_bool", test_array_to_bool, devices=devices)
2127
- add_function_test(TestArray, "test_array_of_structs", test_array_of_structs, devices=devices)
2128
- add_function_test(TestArray, "test_array_of_structs_grad", test_array_of_structs_grad, devices=devices)
2129
- add_function_test(TestArray, "test_array_of_structs_from_numpy", test_array_of_structs_from_numpy, devices=devices)
2130
- add_function_test(TestArray, "test_array_of_structs_roundtrip", test_array_of_structs_roundtrip, devices=devices)
2131
- add_function_test(TestArray, "test_array_from_numpy", test_array_from_numpy, devices=devices)
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)
@@ -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
- from warp.utils import array_sum, array_inner
6
- from warp.tests.test_base import *
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
- def register(parent):
122
- devices = get_test_devices()
129
+ devices = get_test_devices()
130
+
123
131
 
124
- class TestArraySym(parent):
125
- pass
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
- return TestArraySym
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
- # include parent path
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.test_base import *
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.launch(kernel, n, inputs=[add_array, min_array, max_array, val_array], device=device)
63
-
64
- val = np.append(val, [base[0]], axis=0)
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
- def register(parent):
85
- devices = get_test_devices()
122
+ devices = get_test_devices()
123
+
86
124
 
87
- class TestAtomic(parent):
88
- pass
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
- return TestAtomic
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.test_base import *
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
- def register(parent):
80
- devices = get_test_devices()
86
+ devices = get_test_devices()
87
+
81
88
 
82
- class TestBool(parent):
83
- pass
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
- return TestBool
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)