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
warp/stubs.py CHANGED
@@ -40,7 +40,8 @@ from warp.types import spatial_vector, spatial_vectorh, spatial_vectorf, spatial
40
40
  from warp.types import spatial_matrix, spatial_matrixh, spatial_matrixf, spatial_matrixd
41
41
 
42
42
  from warp.types import Bvh, Mesh, HashGrid, Volume, MarchingCubes
43
- from warp.types import bvh_query_t, mesh_query_aabb_t, hash_grid_query_t
43
+ from warp.types import bvh_query_t, hash_grid_query_t, mesh_query_aabb_t, mesh_query_point_t, mesh_query_ray_t
44
+
44
45
 
45
46
  from warp.types import matmul, adj_matmul, batched_matmul, adj_batched_matmul, from_ptr
46
47
 
@@ -69,7 +70,6 @@ from warp.context import (
69
70
  )
70
71
  from warp.context import set_module_options, get_module_options, get_module
71
72
  from warp.context import capture_begin, capture_end, capture_launch
72
- from warp.context import print_builtins, export_builtins, export_stubs
73
73
  from warp.context import Kernel, Function, Launch
74
74
  from warp.context import Stream, get_stream, set_stream, synchronize_stream
75
75
  from warp.context import Event, record_event, wait_event, wait_stream
@@ -868,7 +868,7 @@ def mlp(
868
868
  def bvh_query_aabb(id: uint64, lower: vec3f, upper: vec3f) -> bvh_query_t:
869
869
  """
870
870
  Construct an axis-aligned bounding box query against a BVH object. This query can be used to iterate over all bounds
871
- inside a BVH. Returns an object that is used to track state during BVH traversal.
871
+ inside a BVH.
872
872
 
873
873
  :param id: The BVH identifier
874
874
  :param lower: The lower bound of the bounding box in BVH space
@@ -881,7 +881,7 @@ def bvh_query_aabb(id: uint64, lower: vec3f, upper: vec3f) -> bvh_query_t:
881
881
  def bvh_query_ray(id: uint64, start: vec3f, dir: vec3f) -> bvh_query_t:
882
882
  """
883
883
  Construct a ray query against a BVH object. This query can be used to iterate over all bounds
884
- that intersect the ray. Returns an object that is used to track state during BVH traversal.
884
+ that intersect the ray.
885
885
 
886
886
  :param id: The BVH identifier
887
887
  :param start: The start of the ray in BVH space
@@ -900,11 +900,9 @@ def bvh_query_next(query: bvh_query_t, index: int32) -> bool:
900
900
 
901
901
 
902
902
  @over
903
- def mesh_query_point(
904
- id: uint64, point: vec3f, max_dist: float32, inside: float32, face: int32, bary_u: float32, bary_v: float32
905
- ) -> bool:
903
+ def mesh_query_point(id: uint64, point: vec3f, max_dist: float32) -> mesh_query_point_t:
906
904
  """
907
- Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space. Returns ``True`` if a point < ``max_dist`` is found.
905
+ Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space.
908
906
 
909
907
  Identifies the sign of the distance using additional ray-casts to determine if the point is inside or outside.
910
908
  This method is relatively robust, but does increase computational cost.
@@ -913,66 +911,42 @@ def mesh_query_point(
913
911
  :param id: The mesh identifier
914
912
  :param point: The point in space to query
915
913
  :param max_dist: Mesh faces above this distance will not be considered by the query
916
- :param inside: Returns a value < 0 if query point is inside the mesh, >=0 otherwise.
917
- Note that mesh must be watertight for this to be robust
918
- :param face: Returns the index of the closest face
919
- :param bary_u: Returns the barycentric u coordinate of the closest point
920
- :param bary_v: Returns the barycentric v coordinate of the closest point
921
914
  """
922
915
  ...
923
916
 
924
917
 
925
918
  @over
926
- def mesh_query_point_no_sign(
927
- id: uint64, point: vec3f, max_dist: float32, face: int32, bary_u: float32, bary_v: float32
928
- ) -> bool:
919
+ def mesh_query_point_no_sign(id: uint64, point: vec3f, max_dist: float32) -> mesh_query_point_t:
929
920
  """
930
- Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space. Returns ``True`` if a point < ``max_dist`` is found.
921
+ Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space.
931
922
 
932
923
  This method does not compute the sign of the point (inside/outside) which makes it faster than other point query methods.
933
924
 
934
925
  :param id: The mesh identifier
935
926
  :param point: The point in space to query
936
927
  :param max_dist: Mesh faces above this distance will not be considered by the query
937
- :param face: Returns the index of the closest face
938
- :param bary_u: Returns the barycentric u coordinate of the closest point
939
- :param bary_v: Returns the barycentric v coordinate of the closest point
940
928
  """
941
929
  ...
942
930
 
943
931
 
944
932
  @over
945
- def mesh_query_furthest_point_no_sign(
946
- id: uint64, point: vec3f, min_dist: float32, face: int32, bary_u: float32, bary_v: float32
947
- ) -> bool:
933
+ def mesh_query_furthest_point_no_sign(id: uint64, point: vec3f, min_dist: float32) -> mesh_query_point_t:
948
934
  """
949
- Computes the furthest point on the mesh with identifier `id` to the given point in space. Returns ``True`` if a point > ``min_dist`` is found.
935
+ Computes the furthest point on the mesh with identifier `id` to the given point in space.
950
936
 
951
937
  This method does not compute the sign of the point (inside/outside).
952
938
 
953
939
  :param id: The mesh identifier
954
940
  :param point: The point in space to query
955
941
  :param min_dist: Mesh faces below this distance will not be considered by the query
956
- :param face: Returns the index of the furthest face
957
- :param bary_u: Returns the barycentric u coordinate of the furthest point
958
- :param bary_v: Returns the barycentric v coordinate of the furthest point
959
942
  """
960
943
  ...
961
944
 
962
945
 
963
946
  @over
964
- def mesh_query_point_sign_normal(
965
- id: uint64,
966
- point: vec3f,
967
- max_dist: float32,
968
- inside: float32,
969
- face: int32,
970
- bary_u: float32,
971
- bary_v: float32,
972
- epsilon: float32,
973
- ) -> bool:
947
+ def mesh_query_point_sign_normal(id: uint64, point: vec3f, max_dist: float32, epsilon: float32) -> mesh_query_point_t:
974
948
  """
975
- Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space. Returns ``True`` if a point < ``max_dist`` is found.
949
+ Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space.
976
950
 
977
951
  Identifies the sign of the distance (inside/outside) using the angle-weighted pseudo normal.
978
952
  This approach to sign determination is robust for well conditioned meshes that are watertight and non-self intersecting.
@@ -981,11 +955,6 @@ def mesh_query_point_sign_normal(
981
955
  :param id: The mesh identifier
982
956
  :param point: The point in space to query
983
957
  :param max_dist: Mesh faces above this distance will not be considered by the query
984
- :param inside: Returns a value < 0 if query point is inside the mesh, >=0 otherwise.
985
- Note that mesh must be watertight for this to be robust
986
- :param face: Returns the index of the closest face
987
- :param bary_u: Returns the barycentric u coordinate of the closest point
988
- :param bary_v: Returns the barycentric v coordinate of the closest point
989
958
  :param epsilon: Epsilon treating distance values as equal, when locating the minimum distance vertex/face/edge, as a
990
959
  fraction of the average edge length, also for treating closest point as being on edge/vertex default 1e-3
991
960
  """
@@ -994,18 +963,10 @@ def mesh_query_point_sign_normal(
994
963
 
995
964
  @over
996
965
  def mesh_query_point_sign_winding_number(
997
- id: uint64,
998
- point: vec3f,
999
- max_dist: float32,
1000
- inside: float32,
1001
- face: int32,
1002
- bary_u: float32,
1003
- bary_v: float32,
1004
- accuracy: float32,
1005
- threshold: float32,
1006
- ) -> bool:
1007
- """
1008
- Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given point in space. Returns ``True`` if a point < ``max_dist`` is found.
966
+ id: uint64, point: vec3f, max_dist: float32, accuracy: float32, threshold: float32
967
+ ) -> mesh_query_point_t:
968
+ """
969
+ Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given point in space.
1009
970
 
1010
971
  Identifies the sign using the winding number of the mesh relative to the query point. This method of sign determination is robust for poorly conditioned meshes
1011
972
  and provides a smooth approximation to sign even when the mesh is not watertight. This method is the most robust and accurate of the sign determination meshes
@@ -1016,11 +977,6 @@ def mesh_query_point_sign_winding_number(
1016
977
  :param id: The mesh identifier
1017
978
  :param point: The point in space to query
1018
979
  :param max_dist: Mesh faces above this distance will not be considered by the query
1019
- :param inside: Returns a value < 0 if query point is inside the mesh, >=0 otherwise.
1020
- Note that mesh must be watertight for this to be robust
1021
- :param face: Returns the index of the closest face
1022
- :param bary_u: Returns the barycentric u coordinate of the closest point
1023
- :param bary_v: Returns the barycentric v coordinate of the closest point
1024
980
  :param accuracy: Accuracy for computing the winding number with fast winding number method utilizing second-order dipole approximation, default 2.0
1025
981
  :param threshold: The threshold of the winding number to be considered inside, default 0.5
1026
982
  """
@@ -1028,31 +984,14 @@ def mesh_query_point_sign_winding_number(
1028
984
 
1029
985
 
1030
986
  @over
1031
- def mesh_query_ray(
1032
- id: uint64,
1033
- start: vec3f,
1034
- dir: vec3f,
1035
- max_t: float32,
1036
- t: float32,
1037
- bary_u: float32,
1038
- bary_v: float32,
1039
- sign: float32,
1040
- normal: vec3f,
1041
- face: int32,
1042
- ) -> bool:
987
+ def mesh_query_ray(id: uint64, start: vec3f, dir: vec3f, max_t: float32) -> mesh_query_ray_t:
1043
988
  """
1044
- Computes the closest ray hit on the :class:`Mesh` with identifier ``id``, returns ``True`` if a point < ``max_t`` is found.
989
+ Computes the closest ray hit on the :class:`Mesh` with identifier ``id``.
1045
990
 
1046
991
  :param id: The mesh identifier
1047
992
  :param start: The start point of the ray
1048
993
  :param dir: The ray direction (should be normalized)
1049
994
  :param max_t: The maximum distance along the ray to check for intersections
1050
- :param t: Returns the distance of the closest hit along the ray
1051
- :param bary_u: Returns the barycentric u coordinate of the closest hit
1052
- :param bary_v: Returns the barycentric v coordinate of the closest hit
1053
- :param sign: Returns a value > 0 if the hit ray hit front of the face, returns < 0 otherwise
1054
- :param normal: Returns the face normal
1055
- :param face: Returns the index of the hit face
1056
995
  """
1057
996
  ...
1058
997
 
@@ -1062,7 +1001,6 @@ def mesh_query_aabb(id: uint64, lower: vec3f, upper: vec3f) -> mesh_query_aabb_t
1062
1001
  """
1063
1002
  Construct an axis-aligned bounding box query against a :class:`Mesh`.
1064
1003
  This query can be used to iterate over all triangles inside a volume.
1065
- Returns an object that is used to track state during mesh traversal.
1066
1004
 
1067
1005
  :param id: The mesh identifier
1068
1006
  :param lower: The lower bound of the bounding box in mesh space
@@ -1099,7 +1037,7 @@ def mesh_eval_velocity(id: uint64, face: int32, bary_u: float32, bary_v: float32
1099
1037
  @over
1100
1038
  def hash_grid_query(id: uint64, point: vec3f, max_dist: float32) -> hash_grid_query_t:
1101
1039
  """
1102
- Construct a point query against a :class:`HashGrid`. This query can be used to iterate over all neighboring points within a fixed radius from the query point. Returns an object that is used to track state during neighbor traversal.
1040
+ Construct a point query against a :class:`HashGrid`. This query can be used to iterate over all neighboring points within a fixed radius from the query point.
1103
1041
  """
1104
1042
  ...
1105
1043
 
warp/tape.py CHANGED
@@ -82,7 +82,7 @@ class Tape:
82
82
  if loss.size > 1 or wp.types.type_length(loss.dtype) > 1:
83
83
  raise RuntimeError("Can only return gradients for scalar loss functions.")
84
84
 
85
- if loss.requires_grad is False:
85
+ if not loss.requires_grad:
86
86
  raise RuntimeError(
87
87
  "Scalar loss arrays should have requires_grad=True set before calling Tape.backward()"
88
88
  )
warp/tests/__main__.py CHANGED
@@ -1,7 +1,4 @@
1
- from .test_all import run
1
+ from warp.thirdparty.unittest_parallel import main
2
2
 
3
- ret = run()
4
-
5
- import sys
6
-
7
- sys.exit(ret)
3
+ if __name__ == "__main__":
4
+ main()
@@ -1,7 +1,15 @@
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
+
8
+ """Dummy class used in test_reload.py"""
9
+
1
10
  import warp as wp
2
11
 
3
12
 
4
- # dummy class used in test_reload.py
5
13
  class ClassKernelTest:
6
14
  def __init__(self, device):
7
15
  # 3x3 frames in the rest pose:
@@ -0,0 +1,21 @@
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
+
8
+ """This file defines a kernel that fails on codegen.py"""
9
+
10
+ import warp as wp
11
+
12
+
13
+ @wp.kernel
14
+ def unequal_types_kernel():
15
+ x = wp.int32(10)
16
+ y = 10
17
+ z = True
18
+
19
+ # Throws a TypeError
20
+ if x == y == z:
21
+ pass
@@ -5,10 +5,10 @@
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
- # This file is used to test reloading module references.
8
+ """This file is used to test reloading module references."""
9
9
 
10
10
  import warp as wp
11
- import warp.tests.test_reference as ref
11
+ import warp.tests.aux_test_reference as ref
12
12
 
13
13
  wp.init()
14
14
 
@@ -1,7 +1,7 @@
1
1
  # This file is used to test reloading module references.
2
2
 
3
3
  import warp as wp
4
- import warp.tests.test_reference_reference as refref
4
+ import warp.tests.aux_test_reference_reference as refref
5
5
 
6
6
  wp.init()
7
7
 
@@ -0,0 +1,14 @@
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
+
8
+ import warp as wp
9
+
10
+
11
+ @wp.kernel
12
+ def unresolved_func_kernel():
13
+ # this should trigger an exception due to unresolved function
14
+ x = wp.missing_func(42)
@@ -0,0 +1,14 @@
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
+
8
+ import warp as wp
9
+
10
+
11
+ @wp.kernel
12
+ def unresolved_symbol_kernel():
13
+ # this should trigger an exception due to unresolved symbol
14
+ x = missing_symbol
@@ -5,12 +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
+ import math
8
9
  import unittest
9
10
 
10
11
  import warp as wp
11
12
  import warp.sim
12
- import math
13
- from warp.tests.test_base import *
13
+ from warp.tests.unittest_utils import *
14
14
 
15
15
  wp.init()
16
16
 
@@ -221,21 +221,19 @@ def test_fk_ik_complex_joint_mechanism(test, device):
221
221
  check_fk_ik(builder, device)
222
222
 
223
223
 
224
- def register(parent):
225
- devices = get_test_devices()
224
+ devices = get_test_devices()
225
+
226
226
 
227
- class TestGrad(parent):
228
- pass
227
+ class TestKinematics(unittest.TestCase):
228
+ pass
229
229
 
230
- add_function_test(TestGrad, "test_fk_ik_ant", test_fk_ik_ant, devices=devices)
231
- add_function_test(
232
- TestGrad, "test_fk_ik_complex_joint_mechanism", test_fk_ik_complex_joint_mechanism, devices=devices
233
- )
234
230
 
235
- return TestGrad
231
+ add_function_test(TestKinematics, "test_fk_ik_ant", test_fk_ik_ant, devices=devices)
232
+ add_function_test(
233
+ TestKinematics, "test_fk_ik_complex_joint_mechanism", test_fk_ik_complex_joint_mechanism, devices=devices
234
+ )
236
235
 
237
236
 
238
237
  if __name__ == "__main__":
239
238
  wp.build.clear_kernel_cache()
240
- _ = register(unittest.TestCase)
241
239
  unittest.main(verbosity=2, failfast=False)
@@ -0,0 +1,31 @@
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
+
8
+ """Serial code-coverage runner
9
+
10
+ This script is used to generate code-coverage reports by running Warp tests.
11
+ It runs in serial so can take over an hour to finish. To generate a coverage
12
+ report in parallel, use the warp/thirdparty./unittest_parallel.py script
13
+ instead with the --coverage option, e.g. python -m warp.tests --coverage
14
+ """
15
+
16
+ import coverage
17
+
18
+ cover = coverage.Coverage(config_file=True, messages=True)
19
+
20
+ cover.start()
21
+
22
+ with cover.collect():
23
+ import unittest_serial # noqa: E402
24
+
25
+ unittest_serial.run_specified()
26
+
27
+ cover.save()
28
+
29
+ cover.report()
30
+
31
+ cover.html_report(title="Warp Testing Code Coverage Report")
warp/tests/test_adam.py CHANGED
@@ -5,16 +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
- # 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
- import unittest
15
-
16
13
  import warp.optim
17
14
  import warp.sim
15
+ from warp.tests.unittest_utils import *
18
16
 
19
17
  wp.init()
20
18
 
@@ -28,32 +26,32 @@ def objective(params: wp.array(dtype=float), score: wp.array(dtype=float)):
28
26
 
29
27
  # This test inspired by https://machinelearningmastery.com/adam-optimization-from-scratch/
30
28
  def test_adam_solve_float(test, device):
31
- wp.set_device(device)
32
- params_start = np.array([0.1, 0.2], dtype=float)
33
- score = wp.zeros(1, dtype=float, requires_grad=True)
34
- params = wp.array(params_start, dtype=float, requires_grad=True)
35
- tape = wp.Tape()
36
- opt = warp.optim.Adam([params], lr=0.02, betas=(0.8, 0.999))
37
-
38
- def gradient_func():
39
- tape.reset()
40
- score.zero_()
41
- with tape:
42
- wp.launch(kernel=objective, dim=len(params), inputs=[params, score])
43
- tape.backward(score)
44
- return [tape.gradients[params]]
45
-
46
- niters = 100
47
-
48
- opt.reset_internal_state()
49
- for _ in range(niters):
50
- opt.step(gradient_func())
51
-
52
- result = params.numpy()
53
- # optimum is at the origin, so the result should be close to it in all N dimensions.
54
- tol = 1e-5
55
- for r in result:
56
- test.assertLessEqual(r, tol)
29
+ with wp.ScopedDevice(device):
30
+ params_start = np.array([0.1, 0.2], dtype=float)
31
+ score = wp.zeros(1, dtype=float, requires_grad=True)
32
+ params = wp.array(params_start, dtype=float, requires_grad=True)
33
+ tape = wp.Tape()
34
+ opt = warp.optim.Adam([params], lr=0.02, betas=(0.8, 0.999))
35
+
36
+ def gradient_func():
37
+ tape.reset()
38
+ score.zero_()
39
+ with tape:
40
+ wp.launch(kernel=objective, dim=len(params), inputs=[params, score])
41
+ tape.backward(score)
42
+ return [tape.gradients[params]]
43
+
44
+ niters = 100
45
+
46
+ opt.reset_internal_state()
47
+ for _ in range(niters):
48
+ opt.step(gradient_func())
49
+
50
+ result = params.numpy()
51
+ # optimum is at the origin, so the result should be close to it in all N dimensions.
52
+ tol = 1e-5
53
+ for r in result:
54
+ test.assertLessEqual(r, tol)
57
55
 
58
56
 
59
57
  @wp.kernel
@@ -65,32 +63,32 @@ def objective_vec3(params: wp.array(dtype=wp.vec3), score: wp.array(dtype=float)
65
63
 
66
64
  # This test inspired by https://machinelearningmastery.com/adam-optimization-from-scratch/
67
65
  def test_adam_solve_vec3(test, device):
68
- wp.set_device(device)
69
- params_start = np.array([[0.1, 0.2, -0.1]], dtype=float)
70
- score = wp.zeros(1, dtype=float, requires_grad=True)
71
- params = wp.array(params_start, dtype=wp.vec3, requires_grad=True)
72
- tape = wp.Tape()
73
- opt = warp.optim.Adam([params], lr=0.02, betas=(0.8, 0.999))
74
-
75
- def gradient_func():
76
- tape.reset()
77
- score.zero_()
78
- with tape:
79
- wp.launch(kernel=objective_vec3, dim=len(params), inputs=[params, score])
80
- tape.backward(score)
81
- return [tape.gradients[params]]
82
-
83
- niters = 100
84
- opt.reset_internal_state()
85
- for _ in range(niters):
86
- opt.step(gradient_func())
87
-
88
- result = params.numpy()
89
- tol = 1e-5
90
- # optimum is at the origin, so the result should be close to it in all N dimensions.
91
- for r in result:
92
- for v in r:
93
- test.assertLessEqual(v, tol)
66
+ with wp.ScopedDevice(device):
67
+ params_start = np.array([[0.1, 0.2, -0.1]], dtype=float)
68
+ score = wp.zeros(1, dtype=float, requires_grad=True)
69
+ params = wp.array(params_start, dtype=wp.vec3, requires_grad=True)
70
+ tape = wp.Tape()
71
+ opt = warp.optim.Adam([params], lr=0.02, betas=(0.8, 0.999))
72
+
73
+ def gradient_func():
74
+ tape.reset()
75
+ score.zero_()
76
+ with tape:
77
+ wp.launch(kernel=objective_vec3, dim=len(params), inputs=[params, score])
78
+ tape.backward(score)
79
+ return [tape.gradients[params]]
80
+
81
+ niters = 100
82
+ opt.reset_internal_state()
83
+ for _ in range(niters):
84
+ opt.step(gradient_func())
85
+
86
+ result = params.numpy()
87
+ tol = 1e-5
88
+ # optimum is at the origin, so the result should be close to it in all N dimensions.
89
+ for r in result:
90
+ for v in r:
91
+ test.assertLessEqual(v, tol)
94
92
 
95
93
 
96
94
  @wp.kernel
@@ -105,57 +103,55 @@ def objective_two_inputs_vec3(
105
103
 
106
104
  # This test inspired by https://machinelearningmastery.com/adam-optimization-from-scratch/
107
105
  def test_adam_solve_two_inputs(test, device):
108
- wp.set_device(device)
109
- params_start1 = np.array([[0.1, 0.2, -0.1]], dtype=float)
110
- params_start2 = np.array([[0.2, 0.1, 0.1]], dtype=float)
111
- score = wp.zeros(1, dtype=float, requires_grad=True)
112
- params1 = wp.array(params_start1, dtype=wp.vec3, requires_grad=True)
113
- params2 = wp.array(params_start2, dtype=wp.vec3, requires_grad=True)
114
- tape = wp.Tape()
115
- opt = warp.optim.Adam([params1, params2], lr=0.02, betas=(0.8, 0.999))
116
-
117
- def gradient_func():
118
- tape.reset()
119
- score.zero_()
120
- with tape:
121
- wp.launch(kernel=objective_two_inputs_vec3, dim=len(params1), inputs=[params1, params2, score])
122
- tape.backward(score)
123
- return [tape.gradients[params1], tape.gradients[params2]]
124
-
125
- niters = 100
126
- opt.reset_internal_state()
127
- for _ in range(niters):
128
- opt.step(gradient_func())
129
-
130
- result = params1.numpy()
131
- tol = 1e-5
132
- # optimum is at the origin, so the result should be close to it in all N dimensions.
133
- for r in result:
134
- for v in r:
135
- test.assertLessEqual(v, tol)
136
-
137
- result = params2.numpy()
138
- tol = 1e-5
139
- # optimum is at the origin, so the result should be close to it in all N dimensions.
140
- for r in result:
141
- for v in r:
142
- test.assertLessEqual(v, tol)
143
-
144
-
145
- def register(parent):
146
- devices = get_test_devices()
147
-
148
- class TestArray(parent):
149
- pass
150
-
151
- add_function_test(TestArray, "test_adam_solve_float", test_adam_solve_float, devices=devices)
152
- add_function_test(TestArray, "test_adam_solve_vec3", test_adam_solve_vec3, devices=devices)
153
- add_function_test(TestArray, "test_adam_solve_two_inputs", test_adam_solve_two_inputs, devices=devices)
154
-
155
- return TestArray
106
+ with wp.ScopedDevice(device):
107
+ params_start1 = np.array([[0.1, 0.2, -0.1]], dtype=float)
108
+ params_start2 = np.array([[0.2, 0.1, 0.1]], dtype=float)
109
+ score = wp.zeros(1, dtype=float, requires_grad=True)
110
+ params1 = wp.array(params_start1, dtype=wp.vec3, requires_grad=True)
111
+ params2 = wp.array(params_start2, dtype=wp.vec3, requires_grad=True)
112
+ tape = wp.Tape()
113
+ opt = warp.optim.Adam([params1, params2], lr=0.02, betas=(0.8, 0.999))
114
+
115
+ def gradient_func():
116
+ tape.reset()
117
+ score.zero_()
118
+ with tape:
119
+ wp.launch(kernel=objective_two_inputs_vec3, dim=len(params1), inputs=[params1, params2, score])
120
+ tape.backward(score)
121
+ return [tape.gradients[params1], tape.gradients[params2]]
122
+
123
+ niters = 100
124
+ opt.reset_internal_state()
125
+ for _ in range(niters):
126
+ opt.step(gradient_func())
127
+
128
+ result = params1.numpy()
129
+ tol = 1e-5
130
+ # optimum is at the origin, so the result should be close to it in all N dimensions.
131
+ for r in result:
132
+ for v in r:
133
+ test.assertLessEqual(v, tol)
134
+
135
+ result = params2.numpy()
136
+ tol = 1e-5
137
+ # optimum is at the origin, so the result should be close to it in all N dimensions.
138
+ for r in result:
139
+ for v in r:
140
+ test.assertLessEqual(v, tol)
141
+
142
+
143
+ devices = get_test_devices()
144
+
145
+
146
+ class TestAdam(unittest.TestCase):
147
+ pass
148
+
149
+
150
+ add_function_test(TestAdam, "test_adam_solve_float", test_adam_solve_float, devices=devices)
151
+ add_function_test(TestAdam, "test_adam_solve_vec3", test_adam_solve_vec3, devices=devices)
152
+ add_function_test(TestAdam, "test_adam_solve_two_inputs", test_adam_solve_two_inputs, devices=devices)
156
153
 
157
154
 
158
155
  if __name__ == "__main__":
159
156
  wp.build.clear_kernel_cache()
160
- _ = register(unittest.TestCase)
161
157
  unittest.main(verbosity=2)