warp-lang 1.9.1__py3-none-manylinux_2_34_aarch64.whl → 1.10.0rc2__py3-none-manylinux_2_34_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of warp-lang might be problematic. Click here for more details.

Files changed (346) hide show
  1. warp/__init__.py +301 -287
  2. warp/__init__.pyi +794 -305
  3. warp/_src/__init__.py +14 -0
  4. warp/_src/autograd.py +1075 -0
  5. warp/_src/build.py +618 -0
  6. warp/_src/build_dll.py +640 -0
  7. warp/{builtins.py → _src/builtins.py} +1382 -377
  8. warp/_src/codegen.py +4359 -0
  9. warp/{config.py → _src/config.py} +178 -169
  10. warp/_src/constants.py +57 -0
  11. warp/_src/context.py +8294 -0
  12. warp/_src/dlpack.py +462 -0
  13. warp/_src/fabric.py +355 -0
  14. warp/_src/fem/__init__.py +14 -0
  15. warp/_src/fem/adaptivity.py +508 -0
  16. warp/_src/fem/cache.py +687 -0
  17. warp/_src/fem/dirichlet.py +188 -0
  18. warp/{fem → _src/fem}/domain.py +40 -30
  19. warp/_src/fem/field/__init__.py +131 -0
  20. warp/_src/fem/field/field.py +701 -0
  21. warp/{fem → _src/fem}/field/nodal_field.py +30 -15
  22. warp/{fem → _src/fem}/field/restriction.py +1 -1
  23. warp/{fem → _src/fem}/field/virtual.py +53 -27
  24. warp/_src/fem/geometry/__init__.py +32 -0
  25. warp/{fem → _src/fem}/geometry/adaptive_nanogrid.py +77 -163
  26. warp/_src/fem/geometry/closest_point.py +97 -0
  27. warp/{fem → _src/fem}/geometry/deformed_geometry.py +14 -22
  28. warp/{fem → _src/fem}/geometry/element.py +32 -10
  29. warp/{fem → _src/fem}/geometry/geometry.py +48 -20
  30. warp/{fem → _src/fem}/geometry/grid_2d.py +12 -23
  31. warp/{fem → _src/fem}/geometry/grid_3d.py +12 -23
  32. warp/{fem → _src/fem}/geometry/hexmesh.py +40 -63
  33. warp/{fem → _src/fem}/geometry/nanogrid.py +255 -248
  34. warp/{fem → _src/fem}/geometry/partition.py +121 -63
  35. warp/{fem → _src/fem}/geometry/quadmesh.py +26 -45
  36. warp/{fem → _src/fem}/geometry/tetmesh.py +40 -63
  37. warp/{fem → _src/fem}/geometry/trimesh.py +26 -45
  38. warp/{fem → _src/fem}/integrate.py +164 -158
  39. warp/_src/fem/linalg.py +383 -0
  40. warp/_src/fem/operator.py +396 -0
  41. warp/_src/fem/polynomial.py +229 -0
  42. warp/{fem → _src/fem}/quadrature/pic_quadrature.py +15 -20
  43. warp/{fem → _src/fem}/quadrature/quadrature.py +95 -47
  44. warp/_src/fem/space/__init__.py +248 -0
  45. warp/{fem → _src/fem}/space/basis_function_space.py +20 -11
  46. warp/_src/fem/space/basis_space.py +679 -0
  47. warp/{fem → _src/fem}/space/dof_mapper.py +3 -3
  48. warp/{fem → _src/fem}/space/function_space.py +14 -13
  49. warp/{fem → _src/fem}/space/grid_2d_function_space.py +4 -7
  50. warp/{fem → _src/fem}/space/grid_3d_function_space.py +4 -4
  51. warp/{fem → _src/fem}/space/hexmesh_function_space.py +4 -10
  52. warp/{fem → _src/fem}/space/nanogrid_function_space.py +3 -9
  53. warp/{fem → _src/fem}/space/partition.py +117 -60
  54. warp/{fem → _src/fem}/space/quadmesh_function_space.py +4 -10
  55. warp/{fem → _src/fem}/space/restriction.py +66 -33
  56. warp/_src/fem/space/shape/__init__.py +152 -0
  57. warp/{fem → _src/fem}/space/shape/cube_shape_function.py +9 -9
  58. warp/{fem → _src/fem}/space/shape/shape_function.py +8 -9
  59. warp/{fem → _src/fem}/space/shape/square_shape_function.py +6 -6
  60. warp/{fem → _src/fem}/space/shape/tet_shape_function.py +3 -3
  61. warp/{fem → _src/fem}/space/shape/triangle_shape_function.py +3 -3
  62. warp/{fem → _src/fem}/space/tetmesh_function_space.py +3 -9
  63. warp/_src/fem/space/topology.py +459 -0
  64. warp/{fem → _src/fem}/space/trimesh_function_space.py +3 -9
  65. warp/_src/fem/types.py +112 -0
  66. warp/_src/fem/utils.py +486 -0
  67. warp/_src/jax.py +186 -0
  68. warp/_src/jax_experimental/__init__.py +14 -0
  69. warp/_src/jax_experimental/custom_call.py +387 -0
  70. warp/_src/jax_experimental/ffi.py +1284 -0
  71. warp/_src/jax_experimental/xla_ffi.py +656 -0
  72. warp/_src/marching_cubes.py +708 -0
  73. warp/_src/math.py +414 -0
  74. warp/_src/optim/__init__.py +14 -0
  75. warp/_src/optim/adam.py +163 -0
  76. warp/_src/optim/linear.py +1606 -0
  77. warp/_src/optim/sgd.py +112 -0
  78. warp/_src/paddle.py +406 -0
  79. warp/_src/render/__init__.py +14 -0
  80. warp/_src/render/imgui_manager.py +289 -0
  81. warp/_src/render/render_opengl.py +3636 -0
  82. warp/_src/render/render_usd.py +937 -0
  83. warp/_src/render/utils.py +160 -0
  84. warp/_src/sparse.py +2716 -0
  85. warp/_src/tape.py +1206 -0
  86. warp/{thirdparty → _src/thirdparty}/unittest_parallel.py +9 -2
  87. warp/_src/torch.py +391 -0
  88. warp/_src/types.py +5870 -0
  89. warp/_src/utils.py +1693 -0
  90. warp/autograd.py +12 -1054
  91. warp/bin/warp-clang.so +0 -0
  92. warp/bin/warp.so +0 -0
  93. warp/build.py +8 -588
  94. warp/build_dll.py +6 -721
  95. warp/codegen.py +6 -4251
  96. warp/constants.py +6 -39
  97. warp/context.py +12 -8062
  98. warp/dlpack.py +6 -444
  99. warp/examples/distributed/example_jacobi_mpi.py +4 -5
  100. warp/examples/fem/example_adaptive_grid.py +1 -1
  101. warp/examples/fem/example_apic_fluid.py +1 -1
  102. warp/examples/fem/example_burgers.py +8 -8
  103. warp/examples/fem/example_diffusion.py +1 -1
  104. warp/examples/fem/example_distortion_energy.py +1 -1
  105. warp/examples/fem/example_mixed_elasticity.py +2 -2
  106. warp/examples/fem/example_navier_stokes.py +1 -1
  107. warp/examples/fem/example_nonconforming_contact.py +7 -7
  108. warp/examples/fem/example_stokes.py +1 -1
  109. warp/examples/fem/example_stokes_transfer.py +1 -1
  110. warp/examples/fem/utils.py +2 -2
  111. warp/examples/interop/example_jax_callable.py +1 -1
  112. warp/examples/interop/example_jax_ffi_callback.py +1 -1
  113. warp/examples/interop/example_jax_kernel.py +1 -1
  114. warp/examples/tile/example_tile_mcgp.py +191 -0
  115. warp/fabric.py +6 -337
  116. warp/fem/__init__.py +159 -97
  117. warp/fem/adaptivity.py +7 -489
  118. warp/fem/cache.py +9 -648
  119. warp/fem/dirichlet.py +6 -184
  120. warp/fem/field/__init__.py +8 -109
  121. warp/fem/field/field.py +7 -652
  122. warp/fem/geometry/__init__.py +7 -18
  123. warp/fem/geometry/closest_point.py +11 -77
  124. warp/fem/linalg.py +18 -366
  125. warp/fem/operator.py +11 -369
  126. warp/fem/polynomial.py +9 -209
  127. warp/fem/space/__init__.py +5 -211
  128. warp/fem/space/basis_space.py +6 -662
  129. warp/fem/space/shape/__init__.py +41 -118
  130. warp/fem/space/topology.py +6 -437
  131. warp/fem/types.py +6 -81
  132. warp/fem/utils.py +11 -444
  133. warp/jax.py +8 -165
  134. warp/jax_experimental/__init__.py +14 -1
  135. warp/jax_experimental/custom_call.py +8 -365
  136. warp/jax_experimental/ffi.py +17 -873
  137. warp/jax_experimental/xla_ffi.py +5 -605
  138. warp/marching_cubes.py +5 -689
  139. warp/math.py +16 -393
  140. warp/native/array.h +385 -37
  141. warp/native/builtin.h +314 -37
  142. warp/native/bvh.cpp +43 -9
  143. warp/native/bvh.cu +62 -27
  144. warp/native/bvh.h +310 -309
  145. warp/native/clang/clang.cpp +102 -97
  146. warp/native/coloring.cpp +0 -1
  147. warp/native/crt.h +208 -0
  148. warp/native/exports.h +156 -0
  149. warp/native/hashgrid.cu +2 -0
  150. warp/native/intersect.h +24 -1
  151. warp/native/intersect_tri.h +44 -35
  152. warp/native/mat.h +1456 -276
  153. warp/native/mesh.cpp +4 -4
  154. warp/native/mesh.cu +4 -2
  155. warp/native/mesh.h +176 -61
  156. warp/native/quat.h +0 -52
  157. warp/native/scan.cu +2 -0
  158. warp/native/sparse.cu +7 -3
  159. warp/native/spatial.h +12 -0
  160. warp/native/tile.h +681 -89
  161. warp/native/tile_radix_sort.h +1 -1
  162. warp/native/tile_reduce.h +394 -46
  163. warp/native/tile_scan.h +4 -4
  164. warp/native/vec.h +469 -0
  165. warp/native/version.h +23 -0
  166. warp/native/volume.cpp +1 -1
  167. warp/native/volume.cu +1 -0
  168. warp/native/volume.h +1 -1
  169. warp/native/volume_builder.cu +2 -0
  170. warp/native/warp.cpp +57 -29
  171. warp/native/warp.cu +253 -171
  172. warp/native/warp.h +11 -8
  173. warp/optim/__init__.py +6 -3
  174. warp/optim/adam.py +6 -145
  175. warp/optim/linear.py +14 -1585
  176. warp/optim/sgd.py +6 -94
  177. warp/paddle.py +6 -388
  178. warp/render/__init__.py +8 -4
  179. warp/render/imgui_manager.py +7 -267
  180. warp/render/render_opengl.py +6 -3618
  181. warp/render/render_usd.py +6 -919
  182. warp/render/utils.py +6 -142
  183. warp/sparse.py +37 -2563
  184. warp/tape.py +6 -1188
  185. warp/tests/__main__.py +1 -1
  186. warp/tests/cuda/test_async.py +4 -4
  187. warp/tests/cuda/test_conditional_captures.py +1 -1
  188. warp/tests/cuda/test_multigpu.py +1 -1
  189. warp/tests/cuda/test_streams.py +58 -1
  190. warp/tests/geometry/test_bvh.py +157 -22
  191. warp/tests/geometry/test_marching_cubes.py +0 -1
  192. warp/tests/geometry/test_mesh.py +5 -3
  193. warp/tests/geometry/test_mesh_query_aabb.py +5 -12
  194. warp/tests/geometry/test_mesh_query_point.py +5 -2
  195. warp/tests/geometry/test_mesh_query_ray.py +15 -3
  196. warp/tests/geometry/test_volume_write.py +5 -5
  197. warp/tests/interop/test_dlpack.py +14 -14
  198. warp/tests/interop/test_jax.py +772 -49
  199. warp/tests/interop/test_paddle.py +1 -1
  200. warp/tests/test_adam.py +0 -1
  201. warp/tests/test_arithmetic.py +9 -9
  202. warp/tests/test_array.py +527 -100
  203. warp/tests/test_array_reduce.py +3 -3
  204. warp/tests/test_atomic.py +12 -8
  205. warp/tests/test_atomic_bitwise.py +209 -0
  206. warp/tests/test_atomic_cas.py +4 -4
  207. warp/tests/test_bool.py +2 -2
  208. warp/tests/test_builtins_resolution.py +5 -571
  209. warp/tests/test_codegen.py +33 -14
  210. warp/tests/test_conditional.py +1 -1
  211. warp/tests/test_context.py +6 -6
  212. warp/tests/test_copy.py +242 -161
  213. warp/tests/test_ctypes.py +3 -3
  214. warp/tests/test_devices.py +24 -2
  215. warp/tests/test_examples.py +16 -84
  216. warp/tests/test_fabricarray.py +35 -35
  217. warp/tests/test_fast_math.py +0 -2
  218. warp/tests/test_fem.py +56 -10
  219. warp/tests/test_fixedarray.py +3 -3
  220. warp/tests/test_func.py +8 -5
  221. warp/tests/test_generics.py +1 -1
  222. warp/tests/test_indexedarray.py +24 -24
  223. warp/tests/test_intersect.py +39 -9
  224. warp/tests/test_large.py +1 -1
  225. warp/tests/test_lerp.py +3 -1
  226. warp/tests/test_linear_solvers.py +1 -1
  227. warp/tests/test_map.py +35 -4
  228. warp/tests/test_mat.py +52 -62
  229. warp/tests/test_mat_constructors.py +4 -5
  230. warp/tests/test_mat_lite.py +1 -1
  231. warp/tests/test_mat_scalar_ops.py +121 -121
  232. warp/tests/test_math.py +34 -0
  233. warp/tests/test_module_aot.py +4 -4
  234. warp/tests/test_modules_lite.py +28 -2
  235. warp/tests/test_print.py +11 -11
  236. warp/tests/test_quat.py +93 -58
  237. warp/tests/test_runlength_encode.py +1 -1
  238. warp/tests/test_scalar_ops.py +38 -10
  239. warp/tests/test_smoothstep.py +1 -1
  240. warp/tests/test_sparse.py +126 -15
  241. warp/tests/test_spatial.py +105 -87
  242. warp/tests/test_special_values.py +6 -6
  243. warp/tests/test_static.py +7 -7
  244. warp/tests/test_struct.py +13 -2
  245. warp/tests/test_triangle_closest_point.py +48 -1
  246. warp/tests/test_types.py +27 -15
  247. warp/tests/test_utils.py +52 -52
  248. warp/tests/test_vec.py +29 -29
  249. warp/tests/test_vec_constructors.py +5 -5
  250. warp/tests/test_vec_scalar_ops.py +97 -97
  251. warp/tests/test_version.py +75 -0
  252. warp/tests/tile/test_tile.py +178 -0
  253. warp/tests/tile/test_tile_atomic_bitwise.py +403 -0
  254. warp/tests/tile/test_tile_cholesky.py +7 -4
  255. warp/tests/tile/test_tile_load.py +26 -2
  256. warp/tests/tile/test_tile_mathdx.py +3 -3
  257. warp/tests/tile/test_tile_matmul.py +1 -1
  258. warp/tests/tile/test_tile_mlp.py +2 -4
  259. warp/tests/tile/test_tile_reduce.py +214 -13
  260. warp/tests/unittest_suites.py +6 -14
  261. warp/tests/unittest_utils.py +10 -9
  262. warp/tests/walkthrough_debug.py +3 -1
  263. warp/torch.py +6 -373
  264. warp/types.py +29 -5764
  265. warp/utils.py +10 -1659
  266. {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/METADATA +46 -99
  267. warp_lang-1.10.0rc2.dist-info/RECORD +468 -0
  268. warp_lang-1.10.0rc2.dist-info/licenses/licenses/Gaia-LICENSE.txt +6 -0
  269. warp_lang-1.10.0rc2.dist-info/licenses/licenses/appdirs-LICENSE.txt +22 -0
  270. warp_lang-1.10.0rc2.dist-info/licenses/licenses/asset_pixel_jpg-LICENSE.txt +3 -0
  271. warp_lang-1.10.0rc2.dist-info/licenses/licenses/cuda-LICENSE.txt +1582 -0
  272. warp_lang-1.10.0rc2.dist-info/licenses/licenses/dlpack-LICENSE.txt +201 -0
  273. warp_lang-1.10.0rc2.dist-info/licenses/licenses/fp16-LICENSE.txt +28 -0
  274. warp_lang-1.10.0rc2.dist-info/licenses/licenses/libmathdx-LICENSE.txt +220 -0
  275. warp_lang-1.10.0rc2.dist-info/licenses/licenses/llvm-LICENSE.txt +279 -0
  276. warp_lang-1.10.0rc2.dist-info/licenses/licenses/moller-LICENSE.txt +16 -0
  277. warp_lang-1.10.0rc2.dist-info/licenses/licenses/nanovdb-LICENSE.txt +2 -0
  278. warp_lang-1.10.0rc2.dist-info/licenses/licenses/nvrtc-LICENSE.txt +1592 -0
  279. warp_lang-1.10.0rc2.dist-info/licenses/licenses/svd-LICENSE.txt +23 -0
  280. warp_lang-1.10.0rc2.dist-info/licenses/licenses/unittest_parallel-LICENSE.txt +21 -0
  281. warp_lang-1.10.0rc2.dist-info/licenses/licenses/usd-LICENSE.txt +213 -0
  282. warp_lang-1.10.0rc2.dist-info/licenses/licenses/windingnumber-LICENSE.txt +21 -0
  283. warp/examples/assets/cartpole.urdf +0 -110
  284. warp/examples/assets/crazyflie.usd +0 -0
  285. warp/examples/assets/nv_ant.xml +0 -92
  286. warp/examples/assets/nv_humanoid.xml +0 -183
  287. warp/examples/assets/quadruped.urdf +0 -268
  288. warp/examples/optim/example_bounce.py +0 -266
  289. warp/examples/optim/example_cloth_throw.py +0 -228
  290. warp/examples/optim/example_drone.py +0 -870
  291. warp/examples/optim/example_inverse_kinematics.py +0 -182
  292. warp/examples/optim/example_inverse_kinematics_torch.py +0 -191
  293. warp/examples/optim/example_softbody_properties.py +0 -400
  294. warp/examples/optim/example_spring_cage.py +0 -245
  295. warp/examples/optim/example_trajectory.py +0 -227
  296. warp/examples/sim/example_cartpole.py +0 -143
  297. warp/examples/sim/example_cloth.py +0 -225
  298. warp/examples/sim/example_cloth_self_contact.py +0 -316
  299. warp/examples/sim/example_granular.py +0 -130
  300. warp/examples/sim/example_granular_collision_sdf.py +0 -202
  301. warp/examples/sim/example_jacobian_ik.py +0 -244
  302. warp/examples/sim/example_particle_chain.py +0 -124
  303. warp/examples/sim/example_quadruped.py +0 -203
  304. warp/examples/sim/example_rigid_chain.py +0 -203
  305. warp/examples/sim/example_rigid_contact.py +0 -195
  306. warp/examples/sim/example_rigid_force.py +0 -133
  307. warp/examples/sim/example_rigid_gyroscopic.py +0 -115
  308. warp/examples/sim/example_rigid_soft_contact.py +0 -140
  309. warp/examples/sim/example_soft_body.py +0 -196
  310. warp/examples/tile/example_tile_walker.py +0 -327
  311. warp/sim/__init__.py +0 -74
  312. warp/sim/articulation.py +0 -793
  313. warp/sim/collide.py +0 -2570
  314. warp/sim/graph_coloring.py +0 -307
  315. warp/sim/import_mjcf.py +0 -791
  316. warp/sim/import_snu.py +0 -227
  317. warp/sim/import_urdf.py +0 -579
  318. warp/sim/import_usd.py +0 -898
  319. warp/sim/inertia.py +0 -357
  320. warp/sim/integrator.py +0 -245
  321. warp/sim/integrator_euler.py +0 -2000
  322. warp/sim/integrator_featherstone.py +0 -2101
  323. warp/sim/integrator_vbd.py +0 -2487
  324. warp/sim/integrator_xpbd.py +0 -3295
  325. warp/sim/model.py +0 -4821
  326. warp/sim/particles.py +0 -121
  327. warp/sim/render.py +0 -431
  328. warp/sim/utils.py +0 -431
  329. warp/tests/sim/disabled_kinematics.py +0 -244
  330. warp/tests/sim/test_cloth.py +0 -863
  331. warp/tests/sim/test_collision.py +0 -743
  332. warp/tests/sim/test_coloring.py +0 -347
  333. warp/tests/sim/test_inertia.py +0 -161
  334. warp/tests/sim/test_model.py +0 -226
  335. warp/tests/sim/test_sim_grad.py +0 -287
  336. warp/tests/sim/test_sim_grad_bounce_linear.py +0 -212
  337. warp/tests/sim/test_sim_kinematics.py +0 -98
  338. warp/thirdparty/__init__.py +0 -0
  339. warp_lang-1.9.1.dist-info/RECORD +0 -456
  340. /warp/{fem → _src/fem}/quadrature/__init__.py +0 -0
  341. /warp/{tests/sim → _src/thirdparty}/__init__.py +0 -0
  342. /warp/{thirdparty → _src/thirdparty}/appdirs.py +0 -0
  343. /warp/{thirdparty → _src/thirdparty}/dlpack.py +0 -0
  344. {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/WHEEL +0 -0
  345. {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/licenses/LICENSE.md +0 -0
  346. {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/top_level.txt +0 -0
warp/tests/test_array.py CHANGED
@@ -526,7 +526,7 @@ def test_transpose(test, device):
526
526
  def test_fill_scalar(test, device):
527
527
  dim_x = 4
528
528
 
529
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
529
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
530
530
  a1 = wp.zeros(dim_x, dtype=wptype, device=device)
531
531
  a2 = wp.zeros((dim_x, dim_x), dtype=wptype, device=device)
532
532
  a3 = wp.zeros((dim_x, dim_x, dim_x), dtype=wptype, device=device)
@@ -560,7 +560,7 @@ def test_fill_scalar(test, device):
560
560
  assert_np_equal(a3.numpy(), np.zeros(a3.shape, dtype=nptype))
561
561
  assert_np_equal(a4.numpy(), np.zeros(a4.shape, dtype=nptype))
562
562
 
563
- if wptype in wp.types.float_types:
563
+ if wptype in wp._src.types.float_types:
564
564
  # fill with float value
565
565
  fill_value = 13.37
566
566
 
@@ -593,13 +593,13 @@ def test_fill_vector(test, device):
593
593
 
594
594
  dim_x = 4
595
595
 
596
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
596
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
597
597
  # vector types
598
598
  vector_types = [
599
- wp.types.vector(2, wptype),
600
- wp.types.vector(3, wptype),
601
- wp.types.vector(4, wptype),
602
- wp.types.vector(5, wptype),
599
+ wp._src.types.vector(2, wptype),
600
+ wp._src.types.vector(3, wptype),
601
+ wp._src.types.vector(4, wptype),
602
+ wp._src.types.vector(5, wptype),
603
603
  ]
604
604
 
605
605
  for vec_type in vector_types:
@@ -694,7 +694,7 @@ def test_fill_vector(test, device):
694
694
  assert_np_equal(a3.numpy(), expected3)
695
695
  assert_np_equal(a4.numpy(), expected4)
696
696
 
697
- if wptype in wp.types.float_types:
697
+ if wptype in wp._src.types.float_types:
698
698
  # fill with float scalar
699
699
  fill_value = 13.37
700
700
 
@@ -732,19 +732,19 @@ def test_fill_matrix(test, device):
732
732
 
733
733
  dim_x = 4
734
734
 
735
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
735
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
736
736
  # matrix types
737
737
  matrix_types = [
738
738
  # square matrices
739
- wp.types.matrix((2, 2), wptype),
740
- wp.types.matrix((3, 3), wptype),
741
- wp.types.matrix((4, 4), wptype),
742
- wp.types.matrix((5, 5), wptype),
739
+ wp._src.types.matrix((2, 2), wptype),
740
+ wp._src.types.matrix((3, 3), wptype),
741
+ wp._src.types.matrix((4, 4), wptype),
742
+ wp._src.types.matrix((5, 5), wptype),
743
743
  # non-square matrices
744
- wp.types.matrix((2, 3), wptype),
745
- wp.types.matrix((3, 2), wptype),
746
- wp.types.matrix((3, 4), wptype),
747
- wp.types.matrix((4, 3), wptype),
744
+ wp._src.types.matrix((2, 3), wptype),
745
+ wp._src.types.matrix((3, 2), wptype),
746
+ wp._src.types.matrix((3, 4), wptype),
747
+ wp._src.types.matrix((4, 3), wptype),
748
748
  ]
749
749
 
750
750
  for mat_type in matrix_types:
@@ -891,15 +891,15 @@ class FillStruct:
891
891
  f4: wp.float32
892
892
  f8: wp.float16
893
893
  # vector members (make sure to test vectors of float16)
894
- v2: wp.types.vector(2, wp.int64)
895
- v3: wp.types.vector(3, wp.float32)
896
- v4: wp.types.vector(4, wp.float16)
897
- v5: wp.types.vector(5, wp.uint8)
894
+ v2: wp._src.types.vector(2, wp.int64)
895
+ v3: wp._src.types.vector(3, wp.float32)
896
+ v4: wp._src.types.vector(4, wp.float16)
897
+ v5: wp._src.types.vector(5, wp.uint8)
898
898
  # matrix members (make sure to test matrices of float16)
899
- m2: wp.types.matrix((2, 2), wp.float64)
900
- m3: wp.types.matrix((3, 3), wp.int32)
901
- m4: wp.types.matrix((4, 4), wp.float16)
902
- m5: wp.types.matrix((5, 5), wp.int8)
899
+ m2: wp._src.types.matrix((2, 2), wp.float64)
900
+ m3: wp._src.types.matrix((3, 3), wp.int32)
901
+ m4: wp._src.types.matrix((4, 4), wp.float16)
902
+ m5: wp._src.types.matrix((5, 5), wp.int8)
903
903
  # arrays
904
904
  a1: wp.array(dtype=float)
905
905
  a2: wp.array2d(dtype=float)
@@ -1000,7 +1000,7 @@ def test_fill_slices(test, device):
1000
1000
 
1001
1001
  dim_x = 8
1002
1002
 
1003
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1003
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1004
1004
  a1 = wp.zeros(dim_x, dtype=wptype, device=device)
1005
1005
  a2 = wp.zeros((dim_x, dim_x), dtype=wptype, device=device)
1006
1006
  a3 = wp.zeros((dim_x, dim_x, dim_x), dtype=wptype, device=device)
@@ -1011,7 +1011,7 @@ def test_fill_slices(test, device):
1011
1011
  assert_np_equal(a3.numpy(), np.zeros(a3.shape, dtype=nptype))
1012
1012
  assert_np_equal(a4.numpy(), np.zeros(a4.shape, dtype=nptype))
1013
1013
 
1014
- # partititon each array into even and odd slices
1014
+ # partition each array into even and odd slices
1015
1015
  a1a = a1[::2]
1016
1016
  a1b = a1[1::2]
1017
1017
  a2a = a2[::2]
@@ -1108,7 +1108,7 @@ def test_full_scalar(test, device):
1108
1108
  for ndim in range(1, 5):
1109
1109
  shape = (dim,) * ndim
1110
1110
 
1111
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1111
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1112
1112
  # fill with int value and specific dtype
1113
1113
  fill_value = 42
1114
1114
  a = wp.full(shape, fill_value, dtype=wptype, device=device)
@@ -1120,7 +1120,7 @@ def test_full_scalar(test, device):
1120
1120
  test.assertEqual(na.dtype, nptype)
1121
1121
  assert_np_equal(na, np.full(shape, fill_value, dtype=nptype))
1122
1122
 
1123
- if wptype in wp.types.float_types:
1123
+ if wptype in wp._src.types.float_types:
1124
1124
  # fill with float value and specific dtype
1125
1125
  fill_value = 13.37
1126
1126
  a = wp.full(shape, fill_value, dtype=wptype, device=device)
@@ -1165,8 +1165,8 @@ def test_full_vector(test, device):
1165
1165
  for veclen in [2, 3, 4, 5]:
1166
1166
  npshape = (*shape, veclen)
1167
1167
 
1168
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1169
- vectype = wp.types.vector(veclen, wptype)
1168
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1169
+ vectype = wp._src.types.vector(veclen, wptype)
1170
1170
 
1171
1171
  # fill with scalar int value and specific dtype
1172
1172
  fill_value = 42
@@ -1179,7 +1179,7 @@ def test_full_vector(test, device):
1179
1179
  test.assertEqual(na.dtype, nptype)
1180
1180
  assert_np_equal(na, np.full(a.size * veclen, fill_value, dtype=nptype).reshape(npshape))
1181
1181
 
1182
- if wptype in wp.types.float_types:
1182
+ if wptype in wp._src.types.float_types:
1183
1183
  # fill with scalar float value and specific dtype
1184
1184
  fill_value = 13.37
1185
1185
  a = wp.full(shape, fill_value, dtype=vectype, device=device)
@@ -1224,8 +1224,8 @@ def test_full_vector(test, device):
1224
1224
  veclen = len(fill_list)
1225
1225
  npshape = (*shape, veclen)
1226
1226
 
1227
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1228
- vectype = wp.types.vector(veclen, wptype)
1227
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1228
+ vectype = wp._src.types.vector(veclen, wptype)
1229
1229
 
1230
1230
  # fill with list and specific dtype
1231
1231
  a = wp.full(shape, fill_list, dtype=vectype, device=device)
@@ -1256,7 +1256,7 @@ def test_full_vector(test, device):
1256
1256
  na = a.numpy()
1257
1257
 
1258
1258
  test.assertEqual(a.shape, shape)
1259
- test.assertTrue(wp.types.types_equal(a.dtype, vectype))
1259
+ test.assertTrue(wp._src.types.types_equal(a.dtype, vectype))
1260
1260
  test.assertEqual(na.shape, npshape)
1261
1261
  test.assertEqual(na.dtype, nptype)
1262
1262
  assert_np_equal(na, expected)
@@ -1283,18 +1283,18 @@ def test_full_matrix(test, device):
1283
1283
  for ndim in range(1, 5):
1284
1284
  shape = (dim,) * ndim
1285
1285
 
1286
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1286
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1287
1287
  matrix_types = [
1288
1288
  # square matrices
1289
- wp.types.matrix((2, 2), wptype),
1290
- wp.types.matrix((3, 3), wptype),
1291
- wp.types.matrix((4, 4), wptype),
1292
- wp.types.matrix((5, 5), wptype),
1289
+ wp._src.types.matrix((2, 2), wptype),
1290
+ wp._src.types.matrix((3, 3), wptype),
1291
+ wp._src.types.matrix((4, 4), wptype),
1292
+ wp._src.types.matrix((5, 5), wptype),
1293
1293
  # non-square matrices
1294
- wp.types.matrix((2, 3), wptype),
1295
- wp.types.matrix((3, 2), wptype),
1296
- wp.types.matrix((3, 4), wptype),
1297
- wp.types.matrix((4, 3), wptype),
1294
+ wp._src.types.matrix((2, 3), wptype),
1295
+ wp._src.types.matrix((3, 2), wptype),
1296
+ wp._src.types.matrix((3, 4), wptype),
1297
+ wp._src.types.matrix((4, 3), wptype),
1298
1298
  ]
1299
1299
 
1300
1300
  for mattype in matrix_types:
@@ -1311,7 +1311,7 @@ def test_full_matrix(test, device):
1311
1311
  test.assertEqual(na.dtype, nptype)
1312
1312
  assert_np_equal(na, np.full(a.size * mattype._length_, fill_value, dtype=nptype).reshape(npshape))
1313
1313
 
1314
- if wptype in wp.types.float_types:
1314
+ if wptype in wp._src.types.float_types:
1315
1315
  # fill with scalar float value and specific dtype
1316
1316
  fill_value = 13.37
1317
1317
  a = wp.full(shape, fill_value, dtype=mattype, device=device)
@@ -1377,7 +1377,7 @@ def test_full_matrix(test, device):
1377
1377
  na = a.numpy()
1378
1378
 
1379
1379
  test.assertEqual(a.shape, shape)
1380
- test.assertTrue(wp.types.types_equal(a.dtype, mattype))
1380
+ test.assertTrue(wp._src.types.types_equal(a.dtype, mattype))
1381
1381
  test.assertEqual(na.shape, npshape)
1382
1382
  test.assertEqual(na.dtype, nptype)
1383
1383
  assert_np_equal(na, expected)
@@ -1507,7 +1507,7 @@ def test_ones_scalar(test, device):
1507
1507
  for ndim in range(1, 5):
1508
1508
  shape = (dim,) * ndim
1509
1509
 
1510
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1510
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1511
1511
  a = wp.ones(shape, dtype=wptype, device=device)
1512
1512
  na = a.numpy()
1513
1513
 
@@ -1527,8 +1527,8 @@ def test_ones_vector(test, device):
1527
1527
  for veclen in [2, 3, 4, 5]:
1528
1528
  npshape = (*shape, veclen)
1529
1529
 
1530
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1531
- vectype = wp.types.vector(veclen, wptype)
1530
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1531
+ vectype = wp._src.types.vector(veclen, wptype)
1532
1532
 
1533
1533
  a = wp.ones(shape, dtype=vectype, device=device)
1534
1534
  na = a.numpy()
@@ -1546,18 +1546,18 @@ def test_ones_matrix(test, device):
1546
1546
  for ndim in range(1, 5):
1547
1547
  shape = (dim,) * ndim
1548
1548
 
1549
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1549
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1550
1550
  matrix_types = [
1551
1551
  # square matrices
1552
- wp.types.matrix((2, 2), wptype),
1553
- wp.types.matrix((3, 3), wptype),
1554
- wp.types.matrix((4, 4), wptype),
1555
- wp.types.matrix((5, 5), wptype),
1552
+ wp._src.types.matrix((2, 2), wptype),
1553
+ wp._src.types.matrix((3, 3), wptype),
1554
+ wp._src.types.matrix((4, 4), wptype),
1555
+ wp._src.types.matrix((5, 5), wptype),
1556
1556
  # non-square matrices
1557
- wp.types.matrix((2, 3), wptype),
1558
- wp.types.matrix((3, 2), wptype),
1559
- wp.types.matrix((3, 4), wptype),
1560
- wp.types.matrix((4, 3), wptype),
1557
+ wp._src.types.matrix((2, 3), wptype),
1558
+ wp._src.types.matrix((3, 2), wptype),
1559
+ wp._src.types.matrix((3, 4), wptype),
1560
+ wp._src.types.matrix((4, 3), wptype),
1561
1561
  ]
1562
1562
 
1563
1563
  for mattype in matrix_types:
@@ -1579,7 +1579,7 @@ def test_ones_like_scalar(test, device):
1579
1579
  for ndim in range(1, 5):
1580
1580
  shape = (dim,) * ndim
1581
1581
 
1582
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1582
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1583
1583
  # source array
1584
1584
  a = wp.zeros(shape, dtype=wptype, device=device)
1585
1585
  na = a.numpy()
@@ -1608,8 +1608,8 @@ def test_ones_like_vector(test, device):
1608
1608
  for veclen in [2, 3, 4, 5]:
1609
1609
  npshape = (*shape, veclen)
1610
1610
 
1611
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1612
- vectype = wp.types.vector(veclen, wptype)
1611
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1612
+ vectype = wp._src.types.vector(veclen, wptype)
1613
1613
 
1614
1614
  # source array
1615
1615
  a = wp.zeros(shape, dtype=vectype, device=device)
@@ -1636,18 +1636,18 @@ def test_ones_like_matrix(test, device):
1636
1636
  for ndim in range(1, 5):
1637
1637
  shape = (dim,) * ndim
1638
1638
 
1639
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1639
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1640
1640
  matrix_types = [
1641
1641
  # square matrices
1642
- wp.types.matrix((2, 2), wptype),
1643
- wp.types.matrix((3, 3), wptype),
1644
- wp.types.matrix((4, 4), wptype),
1645
- wp.types.matrix((5, 5), wptype),
1642
+ wp._src.types.matrix((2, 2), wptype),
1643
+ wp._src.types.matrix((3, 3), wptype),
1644
+ wp._src.types.matrix((4, 4), wptype),
1645
+ wp._src.types.matrix((5, 5), wptype),
1646
1646
  # non-square matrices
1647
- wp.types.matrix((2, 3), wptype),
1648
- wp.types.matrix((3, 2), wptype),
1649
- wp.types.matrix((3, 4), wptype),
1650
- wp.types.matrix((4, 3), wptype),
1647
+ wp._src.types.matrix((2, 3), wptype),
1648
+ wp._src.types.matrix((3, 2), wptype),
1649
+ wp._src.types.matrix((3, 4), wptype),
1650
+ wp._src.types.matrix((4, 3), wptype),
1651
1651
  ]
1652
1652
 
1653
1653
  for mattype in matrix_types:
@@ -1676,7 +1676,7 @@ def test_round_trip(test, device):
1676
1676
  rng = np.random.default_rng(123)
1677
1677
  dim_x = 4
1678
1678
 
1679
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1679
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1680
1680
  a_np = rng.standard_normal(size=dim_x).astype(nptype)
1681
1681
  a = wp.array(a_np, device=device)
1682
1682
  test.assertEqual(a.dtype, wptype)
@@ -1684,7 +1684,7 @@ def test_round_trip(test, device):
1684
1684
  assert_np_equal(a.numpy(), a_np)
1685
1685
 
1686
1686
  v_np = rng.standard_normal(size=(dim_x, 3)).astype(nptype)
1687
- v = wp.array(v_np, dtype=wp.types.vector(3, wptype), device=device)
1687
+ v = wp.array(v_np, dtype=wp._src.types.vector(3, wptype), device=device)
1688
1688
 
1689
1689
  assert_np_equal(v.numpy(), v_np)
1690
1690
 
@@ -1697,13 +1697,13 @@ def test_empty_array(test, device):
1697
1697
  shape = (0,) * ndim
1698
1698
  dtype_shape = ()
1699
1699
 
1700
- if wptype in wp.types.scalar_types:
1700
+ if wptype in wp._src.types.scalar_types:
1701
1701
  # scalar, vector, or matrix
1702
1702
  if ncols > 0:
1703
1703
  if nrows > 0:
1704
- wptype = wp.types.matrix((nrows, ncols), wptype)
1704
+ wptype = wp._src.types.matrix((nrows, ncols), wptype)
1705
1705
  else:
1706
- wptype = wp.types.vector(ncols, wptype)
1706
+ wptype = wp._src.types.vector(ncols, wptype)
1707
1707
  dtype_shape = wptype._shape_
1708
1708
  fill_value = wptype(42)
1709
1709
  else:
@@ -1745,7 +1745,7 @@ def test_empty_array(test, device):
1745
1745
 
1746
1746
  for ndim in range(1, 5):
1747
1747
  # test with scalars, vectors, and matrices
1748
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1748
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1749
1749
  # scalars
1750
1750
  test_empty_ops(ndim, 0, 0, wptype, nptype)
1751
1751
 
@@ -1774,9 +1774,9 @@ def test_empty_from_numpy(test, device):
1774
1774
 
1775
1775
  if ncols > 0:
1776
1776
  if nrows > 0:
1777
- wptype = wp.types.matrix((nrows, ncols), wptype)
1777
+ wptype = wp._src.types.matrix((nrows, ncols), wptype)
1778
1778
  else:
1779
- wptype = wp.types.vector(ncols, wptype)
1779
+ wptype = wp._src.types.vector(ncols, wptype)
1780
1780
  dtype_shape = wptype._shape_
1781
1781
 
1782
1782
  npshape = (*shape, *dtype_shape)
@@ -1788,7 +1788,7 @@ def test_empty_from_numpy(test, device):
1788
1788
 
1789
1789
  for ndim in range(1, 5):
1790
1790
  # test with scalars, vectors, and matrices
1791
- for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
1791
+ for nptype, wptype in wp._src.types.np_dtype_to_warp_type.items():
1792
1792
  # scalars
1793
1793
  test_empty_from_data(ndim, 0, 0, wptype, nptype)
1794
1794
 
@@ -1811,16 +1811,16 @@ def test_empty_from_list(test, device):
1811
1811
  def test_empty_from_data(nrows, ncols, wptype):
1812
1812
  if ncols > 0:
1813
1813
  if nrows > 0:
1814
- wptype = wp.types.matrix((nrows, ncols), wptype)
1814
+ wptype = wp._src.types.matrix((nrows, ncols), wptype)
1815
1815
  else:
1816
- wptype = wp.types.vector(ncols, wptype)
1816
+ wptype = wp._src.types.vector(ncols, wptype)
1817
1817
 
1818
1818
  a = wp.array([], dtype=wptype, device=device)
1819
1819
  test.assertEqual(a.size, 0)
1820
1820
  test.assertEqual(a.shape, (0,))
1821
1821
 
1822
1822
  # test with scalars, vectors, and matrices
1823
- for wptype in wp.types.scalar_types:
1823
+ for wptype in wp._src.types.scalar_types:
1824
1824
  # scalars
1825
1825
  test_empty_from_data(0, 0, wptype)
1826
1826
 
@@ -1844,7 +1844,7 @@ def test_to_list_scalar(test, device):
1844
1844
  for ndim in range(1, 5):
1845
1845
  shape = (dim,) * ndim
1846
1846
 
1847
- for wptype in wp.types.scalar_types:
1847
+ for wptype in wp._src.types.scalar_types:
1848
1848
  a = wp.full(shape, fill_value, dtype=wptype, device=device)
1849
1849
  l = a.list()
1850
1850
 
@@ -1859,8 +1859,8 @@ def test_to_list_vector(test, device):
1859
1859
  shape = (dim,) * ndim
1860
1860
 
1861
1861
  for veclen in [2, 3, 4, 5]:
1862
- for wptype in wp.types.scalar_types:
1863
- vectype = wp.types.vector(veclen, wptype)
1862
+ for wptype in wp._src.types.scalar_types:
1863
+ vectype = wp._src.types.vector(veclen, wptype)
1864
1864
  fill_value = vectype(42)
1865
1865
 
1866
1866
  a = wp.full(shape, fill_value, dtype=vectype, device=device)
@@ -1876,18 +1876,18 @@ def test_to_list_matrix(test, device):
1876
1876
  for ndim in range(1, 5):
1877
1877
  shape = (dim,) * ndim
1878
1878
 
1879
- for wptype in wp.types.scalar_types:
1879
+ for wptype in wp._src.types.scalar_types:
1880
1880
  matrix_types = [
1881
1881
  # square matrices
1882
- wp.types.matrix((2, 2), wptype),
1883
- wp.types.matrix((3, 3), wptype),
1884
- wp.types.matrix((4, 4), wptype),
1885
- wp.types.matrix((5, 5), wptype),
1882
+ wp._src.types.matrix((2, 2), wptype),
1883
+ wp._src.types.matrix((3, 3), wptype),
1884
+ wp._src.types.matrix((4, 4), wptype),
1885
+ wp._src.types.matrix((5, 5), wptype),
1886
1886
  # non-square matrices
1887
- wp.types.matrix((2, 3), wptype),
1888
- wp.types.matrix((3, 2), wptype),
1889
- wp.types.matrix((3, 4), wptype),
1890
- wp.types.matrix((4, 3), wptype),
1887
+ wp._src.types.matrix((2, 3), wptype),
1888
+ wp._src.types.matrix((3, 2), wptype),
1889
+ wp._src.types.matrix((3, 4), wptype),
1890
+ wp._src.types.matrix((4, 3), wptype),
1891
1891
  ]
1892
1892
 
1893
1893
  for mattype in matrix_types:
@@ -1914,9 +1914,9 @@ def test_to_list_struct(test, device):
1914
1914
  vi: wp.vec2i
1915
1915
  vf: wp.vec3f
1916
1916
  vh: wp.vec4h
1917
- mi: wp.types.matrix((2, 2), int)
1918
- mf: wp.types.matrix((3, 3), float)
1919
- mh: wp.types.matrix((4, 4), wp.float16)
1917
+ mi: wp._src.types.matrix((2, 2), int)
1918
+ mf: wp._src.types.matrix((3, 3), float)
1919
+ mh: wp._src.types.matrix((4, 4), wp.float16)
1920
1920
  inner: Inner
1921
1921
  a1: wp.array(dtype=int)
1922
1922
  a2: wp.array2d(dtype=float)
@@ -2857,7 +2857,7 @@ def test_array_inplace_non_diff_ops(test, device):
2857
2857
  wp.launch(inplace_div_1d, N, inputs=[x1, y1], device=device)
2858
2858
  assert_np_equal(x1.numpy(), np.full(N, fill_value=2.0, dtype=float))
2859
2859
 
2860
- for dtype in (*wp.types.non_atomic_types, wp.vec2b, wp.vec2ub, wp.vec2s, wp.vec2us, uint16vec3):
2860
+ for dtype in (*wp._src.types.non_atomic_types, wp.vec2b, wp.vec2ub, wp.vec2s, wp.vec2us, uint16vec3):
2861
2861
  x = wp.full(N, value=0, dtype=dtype, device=device)
2862
2862
  y = wp.full(N, value=1, dtype=dtype, device=device)
2863
2863
 
@@ -2980,7 +2980,7 @@ def test_numpy_array_interface(test, device):
2980
2980
 
2981
2981
  n = 10
2982
2982
 
2983
- scalar_types = wp.types.scalar_types
2983
+ scalar_types = wp._src.types.scalar_types
2984
2984
 
2985
2985
  for dtype in scalar_types:
2986
2986
  # test round trip
@@ -3080,7 +3080,7 @@ def test_alloc_strides(test, device):
3080
3080
  a1 = wp.zeros(shape, dtype=dtype)
3081
3081
 
3082
3082
  # allocate with contiguous strides
3083
- strides = wp.types.strides_from_shape(shape, dtype)
3083
+ strides = wp._src.types.strides_from_shape(shape, dtype)
3084
3084
  a2 = wp.zeros(shape, dtype=dtype, strides=strides)
3085
3085
 
3086
3086
  # allocate with transposed (reversed) shape/strides
@@ -3169,6 +3169,428 @@ def test_cuda_interface_conversion(test, device):
3169
3169
  assert wp_array.ptr != 0
3170
3170
 
3171
3171
 
3172
+ @wp.kernel
3173
+ def test_array1d_slicing_kernel(arr: wp.array1d(dtype=int)):
3174
+ sub = arr[:3]
3175
+ wp.expect_eq(sub.ndim, 1)
3176
+ wp.expect_eq(sub.shape[0], 3)
3177
+ wp.expect_eq(sub.shape[1], 0)
3178
+ wp.expect_eq(sub[0], 0)
3179
+ wp.expect_eq(sub[2], 2)
3180
+
3181
+ sub = arr[3:5]
3182
+ wp.expect_eq(sub.ndim, 1)
3183
+ wp.expect_eq(sub.shape[0], 2)
3184
+ wp.expect_eq(sub.shape[1], 0)
3185
+ wp.expect_eq(sub[0], 3)
3186
+ wp.expect_eq(sub[1], 4)
3187
+
3188
+ sub = arr[3::-1]
3189
+ wp.expect_eq(sub.ndim, 1)
3190
+ wp.expect_eq(sub.shape[0], 4)
3191
+ wp.expect_eq(sub.shape[1], 0)
3192
+ wp.expect_eq(sub[0], 3)
3193
+ wp.expect_eq(sub[3], 0)
3194
+
3195
+ sub = arr[::-3]
3196
+ sub = sub[::2]
3197
+ wp.expect_eq(sub.ndim, 1)
3198
+ wp.expect_eq(sub.shape[0], 3)
3199
+ wp.expect_eq(sub.shape[1], 0)
3200
+ wp.expect_eq(sub[0], 15)
3201
+ wp.expect_eq(sub[2], 3)
3202
+
3203
+
3204
+ def test_array1d_slicing(test, device):
3205
+ arr = wp.array(tuple(range(16)), dtype=int, device=device)
3206
+ wp.launch(test_array1d_slicing_kernel, dim=1, inputs=(arr,), device=device)
3207
+
3208
+
3209
+ @wp.kernel
3210
+ def test_array2d_slicing_kernel(arr: wp.array2d(dtype=int)):
3211
+ sub = arr[:2]
3212
+ wp.expect_eq(sub.ndim, 2)
3213
+ wp.expect_eq(sub.shape[0], 2)
3214
+ wp.expect_eq(sub.shape[1], 4)
3215
+ wp.expect_eq(sub.shape[2], 0)
3216
+ wp.expect_eq(sub[0, 0], 0)
3217
+ wp.expect_eq(sub[1, 3], 7)
3218
+
3219
+ sub = arr[:2, 1]
3220
+ wp.expect_eq(sub.ndim, 1)
3221
+ wp.expect_eq(sub.shape[0], 2)
3222
+ wp.expect_eq(sub.shape[1], 0)
3223
+ wp.expect_eq(sub[0], 1)
3224
+ wp.expect_eq(sub[1], 5)
3225
+
3226
+ sub = arr[-4, :3]
3227
+ wp.expect_eq(sub.ndim, 1)
3228
+ wp.expect_eq(sub.shape[0], 3)
3229
+ wp.expect_eq(sub.shape[1], 0)
3230
+ wp.expect_eq(sub[0], 16)
3231
+ wp.expect_eq(sub[2], 18)
3232
+
3233
+ sub = arr[3:5, 3:1:-1]
3234
+ wp.expect_eq(sub.ndim, 2)
3235
+ wp.expect_eq(sub.shape[0], 2)
3236
+ wp.expect_eq(sub.shape[1], 2)
3237
+ wp.expect_eq(sub.shape[2], 0)
3238
+ wp.expect_eq(sub[0, 0], 15)
3239
+ wp.expect_eq(sub[1, 1], 18)
3240
+
3241
+ sub = arr[::4]
3242
+ sub = sub[:, ::-3]
3243
+ wp.expect_eq(sub.ndim, 2)
3244
+ wp.expect_eq(sub.shape[0], 2)
3245
+ wp.expect_eq(sub.shape[1], 2)
3246
+ wp.expect_eq(sub.shape[2], 0)
3247
+ wp.expect_eq(sub[0, 0], 3)
3248
+ wp.expect_eq(sub[1, 1], 16)
3249
+
3250
+
3251
+ def test_array2d_slicing(test, device):
3252
+ arr = wp.array(tuple(range(32)), dtype=int, shape=(8, 4), device=device)
3253
+ wp.launch(test_array2d_slicing_kernel, dim=1, inputs=(arr,), device=device)
3254
+
3255
+
3256
+ @wp.kernel
3257
+ def test_array3d_slicing_kernel(arr: wp.array3d(dtype=int)):
3258
+ sub = arr[-1:]
3259
+ wp.expect_eq(sub.ndim, 3)
3260
+ wp.expect_eq(sub.shape[0], 1)
3261
+ wp.expect_eq(sub.shape[1], 8)
3262
+ wp.expect_eq(sub.shape[2], 4)
3263
+ wp.expect_eq(sub.shape[3], 0)
3264
+ wp.expect_eq(sub[0, 0, 0], 32)
3265
+ wp.expect_eq(sub[0, 7, 3], 63)
3266
+
3267
+ sub = arr[:2, -3]
3268
+ wp.expect_eq(sub.ndim, 2)
3269
+ wp.expect_eq(sub.shape[0], 2)
3270
+ wp.expect_eq(sub.shape[1], 4)
3271
+ wp.expect_eq(sub.shape[2], 0)
3272
+ wp.expect_eq(sub[0, 0], 20)
3273
+ wp.expect_eq(sub[1, 3], 55)
3274
+
3275
+ sub = arr[1, 2:]
3276
+ wp.expect_eq(sub.ndim, 2)
3277
+ wp.expect_eq(sub.shape[0], 6)
3278
+ wp.expect_eq(sub.shape[1], 4)
3279
+ wp.expect_eq(sub.shape[2], 0)
3280
+ wp.expect_eq(sub[0, 0], 40)
3281
+ wp.expect_eq(sub[5, 3], 63)
3282
+
3283
+ sub = arr[:1, 3:1:-1]
3284
+ wp.expect_eq(sub.ndim, 3)
3285
+ wp.expect_eq(sub.shape[0], 1)
3286
+ wp.expect_eq(sub.shape[1], 2)
3287
+ wp.expect_eq(sub.shape[2], 4)
3288
+ wp.expect_eq(sub.shape[3], 0)
3289
+ wp.expect_eq(sub[0, 0, 0], 12)
3290
+ wp.expect_eq(sub[0, 1, 3], 11)
3291
+
3292
+ sub = arr[::-2, 1, 3]
3293
+ wp.expect_eq(sub.ndim, 1)
3294
+ wp.expect_eq(sub.shape[0], 1)
3295
+ wp.expect_eq(sub.shape[1], 0)
3296
+ wp.expect_eq(sub[0], 39)
3297
+
3298
+ sub = arr[0, 2:5, -3]
3299
+ wp.expect_eq(sub.ndim, 1)
3300
+ wp.expect_eq(sub.shape[0], 3)
3301
+ wp.expect_eq(sub.shape[1], 0)
3302
+ wp.expect_eq(sub[0], 9)
3303
+ wp.expect_eq(sub[2], 17)
3304
+
3305
+ sub = arr[0, -2, ::2]
3306
+ wp.expect_eq(sub.ndim, 1)
3307
+ wp.expect_eq(sub.shape[0], 2)
3308
+ wp.expect_eq(sub.shape[1], 0)
3309
+ wp.expect_eq(sub[0], 24)
3310
+ wp.expect_eq(sub[1], 26)
3311
+
3312
+ sub = arr[-1:, :5:2, 0]
3313
+ wp.expect_eq(sub.ndim, 2)
3314
+ wp.expect_eq(sub.shape[0], 1)
3315
+ wp.expect_eq(sub.shape[1], 3)
3316
+ wp.expect_eq(sub.shape[2], 0)
3317
+ wp.expect_eq(sub[0, 0], 32)
3318
+ wp.expect_eq(sub[0, 2], 48)
3319
+
3320
+ sub = arr[:, 0, ::2]
3321
+ wp.expect_eq(sub.ndim, 2)
3322
+ wp.expect_eq(sub.shape[0], 2)
3323
+ wp.expect_eq(sub.shape[1], 2)
3324
+ wp.expect_eq(sub.shape[2], 0)
3325
+ wp.expect_eq(sub[0, 0], 0)
3326
+ wp.expect_eq(sub[1, 1], 34)
3327
+
3328
+ sub = arr[1, ::-4, ::-3]
3329
+ wp.expect_eq(sub.ndim, 2)
3330
+ wp.expect_eq(sub.shape[0], 2)
3331
+ wp.expect_eq(sub.shape[1], 2)
3332
+ wp.expect_eq(sub.shape[2], 0)
3333
+ wp.expect_eq(sub[0, 0], 63)
3334
+ wp.expect_eq(sub[1, 1], 44)
3335
+
3336
+ sub = arr[::2, :3:, -2:]
3337
+ wp.expect_eq(sub.ndim, 3)
3338
+ wp.expect_eq(sub.shape[0], 1)
3339
+ wp.expect_eq(sub.shape[1], 3)
3340
+ wp.expect_eq(sub.shape[2], 2)
3341
+ wp.expect_eq(sub.shape[3], 0)
3342
+ wp.expect_eq(sub[0, 0, 0], 2)
3343
+ wp.expect_eq(sub[0, 2, 1], 11)
3344
+
3345
+ sub = arr[:, :1]
3346
+ sub = sub[:, :, :2]
3347
+ wp.expect_eq(sub.ndim, 3)
3348
+ wp.expect_eq(sub.shape[0], 2)
3349
+ wp.expect_eq(sub.shape[1], 1)
3350
+ wp.expect_eq(sub.shape[2], 2)
3351
+ wp.expect_eq(sub.shape[3], 0)
3352
+ wp.expect_eq(sub[0, 0, 0], 0)
3353
+ wp.expect_eq(sub[1, 0, 1], 33)
3354
+
3355
+
3356
+ def test_array3d_slicing(test, device):
3357
+ arr = wp.array(tuple(range(64)), dtype=int, shape=(2, 8, 4), device=device)
3358
+ wp.launch(test_array3d_slicing_kernel, dim=1, inputs=(arr,), device=device)
3359
+
3360
+
3361
+ @wp.kernel
3362
+ def test_array4d_slicing_kernel(arr: wp.array4d(dtype=int)):
3363
+ sub = arr[:1]
3364
+ wp.expect_eq(sub.ndim, 4)
3365
+ wp.expect_eq(sub.shape[0], 1)
3366
+ wp.expect_eq(sub.shape[1], 2)
3367
+ wp.expect_eq(sub.shape[2], 2)
3368
+ wp.expect_eq(sub.shape[3], 4)
3369
+ wp.expect_eq(sub[0, 0, 0, 0], 0)
3370
+ wp.expect_eq(sub[0, 1, 1, 3], 15)
3371
+
3372
+ sub = arr[2:, 0]
3373
+ wp.expect_eq(sub.ndim, 3)
3374
+ wp.expect_eq(sub.shape[0], 2)
3375
+ wp.expect_eq(sub.shape[1], 2)
3376
+ wp.expect_eq(sub.shape[2], 4)
3377
+ wp.expect_eq(sub.shape[3], 0)
3378
+ wp.expect_eq(sub[0, 0, 0], 32)
3379
+ wp.expect_eq(sub[1, 1, 3], 55)
3380
+
3381
+ sub = arr[-1, -1:]
3382
+ wp.expect_eq(sub.ndim, 3)
3383
+ wp.expect_eq(sub.shape[0], 1)
3384
+ wp.expect_eq(sub.shape[1], 2)
3385
+ wp.expect_eq(sub.shape[2], 4)
3386
+ wp.expect_eq(sub.shape[3], 0)
3387
+ wp.expect_eq(sub[0, 0, 0], 56)
3388
+ wp.expect_eq(sub[0, 1, 3], 63)
3389
+
3390
+ sub = arr[3:4, :1]
3391
+ wp.expect_eq(sub.ndim, 4)
3392
+ wp.expect_eq(sub.shape[0], 1)
3393
+ wp.expect_eq(sub.shape[1], 1)
3394
+ wp.expect_eq(sub.shape[2], 2)
3395
+ wp.expect_eq(sub.shape[3], 4)
3396
+ wp.expect_eq(sub[0, 0, 0, 0], 48)
3397
+ wp.expect_eq(sub[0, 0, 1, 3], 55)
3398
+
3399
+ sub = arr[2::, 0, -1]
3400
+ wp.expect_eq(sub.ndim, 2)
3401
+ wp.expect_eq(sub.shape[0], 2)
3402
+ wp.expect_eq(sub.shape[1], 4)
3403
+ wp.expect_eq(sub.shape[2], 0)
3404
+ wp.expect_eq(sub[0, 0], 36)
3405
+ wp.expect_eq(sub[1, 3], 55)
3406
+
3407
+ sub = arr[-2, ::2, -2]
3408
+ wp.expect_eq(sub.ndim, 2)
3409
+ wp.expect_eq(sub.shape[0], 1)
3410
+ wp.expect_eq(sub.shape[1], 4)
3411
+ wp.expect_eq(sub.shape[2], 0)
3412
+ wp.expect_eq(sub[0, 0], 32)
3413
+ wp.expect_eq(sub[0, 3], 35)
3414
+
3415
+ sub = arr[1, -1, ::-3]
3416
+ wp.expect_eq(sub.ndim, 2)
3417
+ wp.expect_eq(sub.shape[0], 1)
3418
+ wp.expect_eq(sub.shape[1], 4)
3419
+ wp.expect_eq(sub.shape[2], 0)
3420
+ wp.expect_eq(sub[0, 0], 28)
3421
+ wp.expect_eq(sub[0, 3], 31)
3422
+
3423
+ sub = arr[1::2, :-1, 0]
3424
+ wp.expect_eq(sub.ndim, 3)
3425
+ wp.expect_eq(sub.shape[0], 2)
3426
+ wp.expect_eq(sub.shape[1], 1)
3427
+ wp.expect_eq(sub.shape[2], 4)
3428
+ wp.expect_eq(sub.shape[3], 0)
3429
+ wp.expect_eq(sub[0, 0, 0], 16)
3430
+ wp.expect_eq(sub[1, 0, 3], 51)
3431
+
3432
+ sub = arr[:2, 1, 1:]
3433
+ wp.expect_eq(sub.ndim, 3)
3434
+ wp.expect_eq(sub.shape[0], 2)
3435
+ wp.expect_eq(sub.shape[1], 1)
3436
+ wp.expect_eq(sub.shape[2], 4)
3437
+ wp.expect_eq(sub.shape[3], 0)
3438
+ wp.expect_eq(sub[0, 0, 0], 12)
3439
+ wp.expect_eq(sub[1, 0, 3], 31)
3440
+
3441
+ sub = arr[-1, :1, ::-3]
3442
+ wp.expect_eq(sub.ndim, 3)
3443
+ wp.expect_eq(sub.shape[0], 1)
3444
+ wp.expect_eq(sub.shape[1], 1)
3445
+ wp.expect_eq(sub.shape[2], 4)
3446
+ wp.expect_eq(sub.shape[3], 0)
3447
+ wp.expect_eq(sub[0, 0, 0], 52)
3448
+ wp.expect_eq(sub[0, 0, 3], 55)
3449
+
3450
+ sub = arr[::-4, :1, 1:]
3451
+ wp.expect_eq(sub.ndim, 4)
3452
+ wp.expect_eq(sub.shape[0], 1)
3453
+ wp.expect_eq(sub.shape[1], 1)
3454
+ wp.expect_eq(sub.shape[2], 1)
3455
+ wp.expect_eq(sub.shape[3], 4)
3456
+ wp.expect_eq(sub[0, 0, 0, 0], 52)
3457
+ wp.expect_eq(sub[0, 0, 0, 3], 55)
3458
+
3459
+ sub = arr[:2, 0, 1, 2]
3460
+ wp.expect_eq(sub.ndim, 1)
3461
+ wp.expect_eq(sub.shape[0], 2)
3462
+ wp.expect_eq(sub.shape[1], 0)
3463
+ wp.expect_eq(sub[0], 6)
3464
+ wp.expect_eq(sub[1], 22)
3465
+
3466
+ sub = arr[-3, ::2, 0, 2]
3467
+ wp.expect_eq(sub.ndim, 1)
3468
+ wp.expect_eq(sub.shape[0], 1)
3469
+ wp.expect_eq(sub.shape[1], 0)
3470
+ wp.expect_eq(sub[0], 18)
3471
+
3472
+ sub = arr[2, 0, :-1, 1]
3473
+ wp.expect_eq(sub.ndim, 1)
3474
+ wp.expect_eq(sub.shape[0], 1)
3475
+ wp.expect_eq(sub.shape[1], 0)
3476
+ wp.expect_eq(sub[0], 33)
3477
+
3478
+ sub = arr[1, 0, 1, :]
3479
+ wp.expect_eq(sub.ndim, 1)
3480
+ wp.expect_eq(sub.shape[0], 4)
3481
+ wp.expect_eq(sub.shape[1], 0)
3482
+ wp.expect_eq(sub[0], 20)
3483
+ wp.expect_eq(sub[3], 23)
3484
+
3485
+ sub = arr[1:, :2, 1, -3]
3486
+ wp.expect_eq(sub.ndim, 2)
3487
+ wp.expect_eq(sub.shape[0], 3)
3488
+ wp.expect_eq(sub.shape[1], 2)
3489
+ wp.expect_eq(sub.shape[2], 0)
3490
+ wp.expect_eq(sub[0, 0], 21)
3491
+ wp.expect_eq(sub[2, 1], 61)
3492
+
3493
+ sub = arr[2:, 0, :2, 1]
3494
+ wp.expect_eq(sub.ndim, 2)
3495
+ wp.expect_eq(sub.shape[0], 2)
3496
+ wp.expect_eq(sub.shape[1], 2)
3497
+ wp.expect_eq(sub.shape[2], 0)
3498
+ wp.expect_eq(sub[0, 0], 33)
3499
+ wp.expect_eq(sub[1, 1], 53)
3500
+
3501
+ sub = arr[::-2, 0, 0, ::3]
3502
+ wp.expect_eq(sub.ndim, 2)
3503
+ wp.expect_eq(sub.shape[0], 2)
3504
+ wp.expect_eq(sub.shape[1], 2)
3505
+ wp.expect_eq(sub.shape[2], 0)
3506
+ wp.expect_eq(sub[0, 0], 48)
3507
+ wp.expect_eq(sub[1, 1], 19)
3508
+
3509
+ sub = arr[-2, 1:2, ::-1, 0]
3510
+ wp.expect_eq(sub.ndim, 2)
3511
+ wp.expect_eq(sub.shape[0], 1)
3512
+ wp.expect_eq(sub.shape[1], 2)
3513
+ wp.expect_eq(sub.shape[2], 0)
3514
+ wp.expect_eq(sub[0, 0], 44)
3515
+ wp.expect_eq(sub[0, 1], 40)
3516
+
3517
+ sub = arr[1, :2, 0, ::-2]
3518
+ wp.expect_eq(sub.ndim, 2)
3519
+ wp.expect_eq(sub.shape[0], 2)
3520
+ wp.expect_eq(sub.shape[1], 2)
3521
+ wp.expect_eq(sub.shape[2], 0)
3522
+ wp.expect_eq(sub[0, 0], 19)
3523
+ wp.expect_eq(sub[1, 1], 25)
3524
+
3525
+ sub = arr[-1, 0, ::3, -4:-1]
3526
+ wp.expect_eq(sub.ndim, 2)
3527
+ wp.expect_eq(sub.shape[0], 1)
3528
+ wp.expect_eq(sub.shape[1], 3)
3529
+ wp.expect_eq(sub.shape[2], 0)
3530
+ wp.expect_eq(sub[0, 0], 48)
3531
+ wp.expect_eq(sub[0, 2], 50)
3532
+
3533
+ sub = arr[-2:, 1:2, ::3, 1]
3534
+ wp.expect_eq(sub.ndim, 3)
3535
+ wp.expect_eq(sub.shape[0], 2)
3536
+ wp.expect_eq(sub.shape[1], 1)
3537
+ wp.expect_eq(sub.shape[2], 1)
3538
+ wp.expect_eq(sub.shape[3], 0)
3539
+ wp.expect_eq(sub[0, 0, 0], 41)
3540
+ wp.expect_eq(sub[1, 0, 0], 57)
3541
+
3542
+ sub = arr[:1, :, 1, -2:]
3543
+ wp.expect_eq(sub.ndim, 3)
3544
+ wp.expect_eq(sub.shape[0], 1)
3545
+ wp.expect_eq(sub.shape[1], 2)
3546
+ wp.expect_eq(sub.shape[2], 2)
3547
+ wp.expect_eq(sub.shape[3], 0)
3548
+ wp.expect_eq(sub[0, 0, 0], 6)
3549
+ wp.expect_eq(sub[0, 1, 1], 15)
3550
+
3551
+ sub = arr[:2:-1, 0, -1:, ::-1]
3552
+ wp.expect_eq(sub.ndim, 3)
3553
+ wp.expect_eq(sub.shape[0], 1)
3554
+ wp.expect_eq(sub.shape[1], 1)
3555
+ wp.expect_eq(sub.shape[2], 4)
3556
+ wp.expect_eq(sub.shape[3], 0)
3557
+ wp.expect_eq(sub[0, 0, 0], 55)
3558
+ wp.expect_eq(sub[0, 0, 3], 52)
3559
+
3560
+ sub = arr[-2, ::-1, -2:, 1:3]
3561
+ wp.expect_eq(sub.ndim, 3)
3562
+ wp.expect_eq(sub.shape[0], 2)
3563
+ wp.expect_eq(sub.shape[1], 2)
3564
+ wp.expect_eq(sub.shape[2], 2)
3565
+ wp.expect_eq(sub.shape[3], 0)
3566
+ wp.expect_eq(sub[0, 0, 0], 41)
3567
+ wp.expect_eq(sub[1, 1, 1], 38)
3568
+
3569
+ sub = arr[:2, 1:, 1:, :-2]
3570
+ wp.expect_eq(sub.ndim, 4)
3571
+ wp.expect_eq(sub.shape[0], 2)
3572
+ wp.expect_eq(sub.shape[1], 1)
3573
+ wp.expect_eq(sub.shape[2], 1)
3574
+ wp.expect_eq(sub.shape[3], 2)
3575
+ wp.expect_eq(sub[0, 0, 0, 0], 12)
3576
+ wp.expect_eq(sub[1, 0, 0, 1], 29)
3577
+
3578
+ sub = arr[-2:, 1, ::-1]
3579
+ sub = sub[::2]
3580
+ wp.expect_eq(sub.ndim, 3)
3581
+ wp.expect_eq(sub.shape[0], 1)
3582
+ wp.expect_eq(sub.shape[1], 2)
3583
+ wp.expect_eq(sub.shape[2], 4)
3584
+ wp.expect_eq(sub.shape[3], 0)
3585
+ wp.expect_eq(sub[0, 0, 0], 44)
3586
+ wp.expect_eq(sub[0, 1, 3], 43)
3587
+
3588
+
3589
+ def test_array4d_slicing(test, device):
3590
+ arr = wp.array(tuple(range(64)), dtype=int, shape=(4, 2, 2, 4), device=device)
3591
+ wp.launch(test_array4d_slicing_kernel, dim=1, inputs=(arr,), device=device)
3592
+
3593
+
3172
3594
  devices = get_test_devices()
3173
3595
 
3174
3596
 
@@ -3249,6 +3671,11 @@ add_function_test(TestArray, "test_array_len", test_array_len, devices=devices)
3249
3671
  add_function_test(TestArray, "test_cuda_interface_conversion", test_cuda_interface_conversion, devices=devices)
3250
3672
  add_function_test(TestArray, "test_array_from_data", test_array_from_data, devices=devices)
3251
3673
 
3674
+ add_function_test(TestArray, "test_array1d_slicing", test_array1d_slicing, devices=devices)
3675
+ add_function_test(TestArray, "test_array2d_slicing", test_array2d_slicing, devices=devices)
3676
+ add_function_test(TestArray, "test_array3d_slicing", test_array3d_slicing, devices=devices)
3677
+ add_function_test(TestArray, "test_array4d_slicing", test_array4d_slicing, devices=devices)
3678
+
3252
3679
  try:
3253
3680
  import torch
3254
3681