warp-lang 1.9.0__py3-none-win_amd64.whl → 1.10.0rc2__py3-none-win_amd64.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.
- warp/__init__.py +301 -287
- warp/__init__.pyi +2220 -313
- warp/_src/__init__.py +14 -0
- warp/_src/autograd.py +1075 -0
- warp/_src/build.py +618 -0
- warp/_src/build_dll.py +640 -0
- warp/{builtins.py → _src/builtins.py} +1497 -226
- warp/_src/codegen.py +4359 -0
- warp/{config.py → _src/config.py} +178 -169
- warp/_src/constants.py +57 -0
- warp/_src/context.py +8294 -0
- warp/_src/dlpack.py +462 -0
- warp/_src/fabric.py +355 -0
- warp/_src/fem/__init__.py +14 -0
- warp/_src/fem/adaptivity.py +508 -0
- warp/_src/fem/cache.py +687 -0
- warp/_src/fem/dirichlet.py +188 -0
- warp/{fem → _src/fem}/domain.py +40 -30
- warp/_src/fem/field/__init__.py +131 -0
- warp/_src/fem/field/field.py +701 -0
- warp/{fem → _src/fem}/field/nodal_field.py +30 -15
- warp/{fem → _src/fem}/field/restriction.py +1 -1
- warp/{fem → _src/fem}/field/virtual.py +53 -27
- warp/_src/fem/geometry/__init__.py +32 -0
- warp/{fem → _src/fem}/geometry/adaptive_nanogrid.py +77 -163
- warp/_src/fem/geometry/closest_point.py +97 -0
- warp/{fem → _src/fem}/geometry/deformed_geometry.py +14 -22
- warp/{fem → _src/fem}/geometry/element.py +32 -10
- warp/{fem → _src/fem}/geometry/geometry.py +48 -20
- warp/{fem → _src/fem}/geometry/grid_2d.py +12 -23
- warp/{fem → _src/fem}/geometry/grid_3d.py +12 -23
- warp/{fem → _src/fem}/geometry/hexmesh.py +40 -63
- warp/{fem → _src/fem}/geometry/nanogrid.py +255 -248
- warp/{fem → _src/fem}/geometry/partition.py +121 -63
- warp/{fem → _src/fem}/geometry/quadmesh.py +26 -45
- warp/{fem → _src/fem}/geometry/tetmesh.py +40 -63
- warp/{fem → _src/fem}/geometry/trimesh.py +26 -45
- warp/{fem → _src/fem}/integrate.py +164 -158
- warp/_src/fem/linalg.py +383 -0
- warp/_src/fem/operator.py +396 -0
- warp/_src/fem/polynomial.py +229 -0
- warp/{fem → _src/fem}/quadrature/pic_quadrature.py +15 -20
- warp/{fem → _src/fem}/quadrature/quadrature.py +95 -47
- warp/_src/fem/space/__init__.py +248 -0
- warp/{fem → _src/fem}/space/basis_function_space.py +20 -11
- warp/_src/fem/space/basis_space.py +679 -0
- warp/{fem → _src/fem}/space/dof_mapper.py +3 -3
- warp/{fem → _src/fem}/space/function_space.py +14 -13
- warp/{fem → _src/fem}/space/grid_2d_function_space.py +4 -7
- warp/{fem → _src/fem}/space/grid_3d_function_space.py +4 -4
- warp/{fem → _src/fem}/space/hexmesh_function_space.py +4 -10
- warp/{fem → _src/fem}/space/nanogrid_function_space.py +3 -9
- warp/{fem → _src/fem}/space/partition.py +117 -60
- warp/{fem → _src/fem}/space/quadmesh_function_space.py +4 -10
- warp/{fem → _src/fem}/space/restriction.py +66 -33
- warp/_src/fem/space/shape/__init__.py +152 -0
- warp/{fem → _src/fem}/space/shape/cube_shape_function.py +9 -9
- warp/{fem → _src/fem}/space/shape/shape_function.py +8 -9
- warp/{fem → _src/fem}/space/shape/square_shape_function.py +6 -6
- warp/{fem → _src/fem}/space/shape/tet_shape_function.py +3 -3
- warp/{fem → _src/fem}/space/shape/triangle_shape_function.py +3 -3
- warp/{fem → _src/fem}/space/tetmesh_function_space.py +3 -9
- warp/_src/fem/space/topology.py +459 -0
- warp/{fem → _src/fem}/space/trimesh_function_space.py +3 -9
- warp/_src/fem/types.py +112 -0
- warp/_src/fem/utils.py +486 -0
- warp/_src/jax.py +186 -0
- warp/_src/jax_experimental/__init__.py +14 -0
- warp/_src/jax_experimental/custom_call.py +387 -0
- warp/_src/jax_experimental/ffi.py +1284 -0
- warp/_src/jax_experimental/xla_ffi.py +656 -0
- warp/_src/marching_cubes.py +708 -0
- warp/_src/math.py +414 -0
- warp/_src/optim/__init__.py +14 -0
- warp/_src/optim/adam.py +163 -0
- warp/_src/optim/linear.py +1606 -0
- warp/_src/optim/sgd.py +112 -0
- warp/_src/paddle.py +406 -0
- warp/_src/render/__init__.py +14 -0
- warp/_src/render/imgui_manager.py +289 -0
- warp/_src/render/render_opengl.py +3636 -0
- warp/_src/render/render_usd.py +937 -0
- warp/_src/render/utils.py +160 -0
- warp/_src/sparse.py +2716 -0
- warp/_src/tape.py +1206 -0
- warp/{thirdparty → _src/thirdparty}/unittest_parallel.py +9 -2
- warp/_src/torch.py +391 -0
- warp/_src/types.py +5870 -0
- warp/_src/utils.py +1693 -0
- warp/autograd.py +12 -1054
- warp/bin/warp-clang.dll +0 -0
- warp/bin/warp.dll +0 -0
- warp/build.py +8 -588
- warp/build_dll.py +6 -471
- warp/codegen.py +6 -4246
- warp/constants.py +6 -39
- warp/context.py +12 -7851
- warp/dlpack.py +6 -444
- warp/examples/distributed/example_jacobi_mpi.py +4 -5
- warp/examples/fem/example_adaptive_grid.py +1 -1
- warp/examples/fem/example_apic_fluid.py +1 -1
- warp/examples/fem/example_burgers.py +8 -8
- warp/examples/fem/example_diffusion.py +1 -1
- warp/examples/fem/example_distortion_energy.py +1 -1
- warp/examples/fem/example_mixed_elasticity.py +2 -2
- warp/examples/fem/example_navier_stokes.py +1 -1
- warp/examples/fem/example_nonconforming_contact.py +7 -7
- warp/examples/fem/example_stokes.py +1 -1
- warp/examples/fem/example_stokes_transfer.py +1 -1
- warp/examples/fem/utils.py +2 -2
- warp/examples/interop/example_jax_callable.py +1 -1
- warp/examples/interop/example_jax_ffi_callback.py +1 -1
- warp/examples/interop/example_jax_kernel.py +3 -2
- warp/examples/tile/example_tile_mcgp.py +191 -0
- warp/fabric.py +6 -337
- warp/fem/__init__.py +159 -97
- warp/fem/adaptivity.py +7 -489
- warp/fem/cache.py +9 -648
- warp/fem/dirichlet.py +6 -184
- warp/fem/field/__init__.py +8 -109
- warp/fem/field/field.py +7 -652
- warp/fem/geometry/__init__.py +7 -18
- warp/fem/geometry/closest_point.py +11 -77
- warp/fem/linalg.py +18 -366
- warp/fem/operator.py +11 -369
- warp/fem/polynomial.py +9 -209
- warp/fem/space/__init__.py +5 -211
- warp/fem/space/basis_space.py +6 -662
- warp/fem/space/shape/__init__.py +41 -118
- warp/fem/space/topology.py +6 -437
- warp/fem/types.py +6 -81
- warp/fem/utils.py +11 -444
- warp/jax.py +8 -165
- warp/jax_experimental/__init__.py +14 -1
- warp/jax_experimental/custom_call.py +8 -342
- warp/jax_experimental/ffi.py +17 -853
- warp/jax_experimental/xla_ffi.py +5 -596
- warp/marching_cubes.py +5 -689
- warp/math.py +16 -393
- warp/native/array.h +385 -37
- warp/native/builtin.h +316 -39
- warp/native/bvh.cpp +43 -9
- warp/native/bvh.cu +62 -27
- warp/native/bvh.h +310 -309
- warp/native/clang/clang.cpp +102 -97
- warp/native/coloring.cpp +0 -1
- warp/native/crt.h +208 -0
- warp/native/exports.h +156 -0
- warp/native/hashgrid.cu +2 -0
- warp/native/intersect.h +24 -1
- warp/native/intersect_tri.h +44 -35
- warp/native/mat.h +1456 -276
- warp/native/mesh.cpp +4 -4
- warp/native/mesh.cu +4 -2
- warp/native/mesh.h +176 -61
- warp/native/quat.h +0 -52
- warp/native/scan.cu +2 -0
- warp/native/sort.cu +22 -13
- warp/native/sort.h +2 -0
- warp/native/sparse.cu +7 -3
- warp/native/spatial.h +12 -0
- warp/native/tile.h +837 -70
- warp/native/tile_radix_sort.h +1 -1
- warp/native/tile_reduce.h +394 -46
- warp/native/tile_scan.h +4 -4
- warp/native/vec.h +469 -53
- warp/native/version.h +23 -0
- warp/native/volume.cpp +1 -1
- warp/native/volume.cu +1 -0
- warp/native/volume.h +1 -1
- warp/native/volume_builder.cu +2 -0
- warp/native/warp.cpp +60 -32
- warp/native/warp.cu +313 -201
- warp/native/warp.h +14 -11
- warp/optim/__init__.py +6 -3
- warp/optim/adam.py +6 -145
- warp/optim/linear.py +14 -1585
- warp/optim/sgd.py +6 -94
- warp/paddle.py +6 -388
- warp/render/__init__.py +8 -4
- warp/render/imgui_manager.py +7 -267
- warp/render/render_opengl.py +6 -3616
- warp/render/render_usd.py +6 -918
- warp/render/utils.py +6 -142
- warp/sparse.py +37 -2563
- warp/tape.py +6 -1188
- warp/tests/__main__.py +1 -1
- warp/tests/cuda/test_async.py +4 -4
- warp/tests/cuda/test_conditional_captures.py +1 -1
- warp/tests/cuda/test_multigpu.py +1 -1
- warp/tests/cuda/test_streams.py +58 -1
- warp/tests/geometry/test_bvh.py +157 -22
- warp/tests/geometry/test_hash_grid.py +38 -0
- warp/tests/geometry/test_marching_cubes.py +0 -1
- warp/tests/geometry/test_mesh.py +5 -3
- warp/tests/geometry/test_mesh_query_aabb.py +5 -12
- warp/tests/geometry/test_mesh_query_point.py +5 -2
- warp/tests/geometry/test_mesh_query_ray.py +15 -3
- warp/tests/geometry/test_volume_write.py +5 -5
- warp/tests/interop/test_dlpack.py +14 -14
- warp/tests/interop/test_jax.py +1382 -79
- warp/tests/interop/test_paddle.py +1 -1
- warp/tests/test_adam.py +0 -1
- warp/tests/test_arithmetic.py +9 -9
- warp/tests/test_array.py +529 -100
- warp/tests/test_array_reduce.py +3 -3
- warp/tests/test_atomic.py +12 -8
- warp/tests/test_atomic_bitwise.py +209 -0
- warp/tests/test_atomic_cas.py +4 -4
- warp/tests/test_bool.py +2 -2
- warp/tests/test_builtins_resolution.py +5 -571
- warp/tests/test_codegen.py +34 -15
- warp/tests/test_conditional.py +1 -1
- warp/tests/test_context.py +6 -6
- warp/tests/test_copy.py +242 -161
- warp/tests/test_ctypes.py +3 -3
- warp/tests/test_devices.py +24 -2
- warp/tests/test_examples.py +16 -84
- warp/tests/test_fabricarray.py +35 -35
- warp/tests/test_fast_math.py +0 -2
- warp/tests/test_fem.py +60 -14
- warp/tests/test_fixedarray.py +3 -3
- warp/tests/test_func.py +8 -5
- warp/tests/test_generics.py +1 -1
- warp/tests/test_indexedarray.py +24 -24
- warp/tests/test_intersect.py +39 -9
- warp/tests/test_large.py +1 -1
- warp/tests/test_lerp.py +3 -1
- warp/tests/test_linear_solvers.py +1 -1
- warp/tests/test_map.py +49 -4
- warp/tests/test_mat.py +52 -62
- warp/tests/test_mat_constructors.py +4 -5
- warp/tests/test_mat_lite.py +1 -1
- warp/tests/test_mat_scalar_ops.py +121 -121
- warp/tests/test_math.py +34 -0
- warp/tests/test_module_aot.py +4 -4
- warp/tests/test_modules_lite.py +28 -2
- warp/tests/test_print.py +11 -11
- warp/tests/test_quat.py +93 -58
- warp/tests/test_runlength_encode.py +1 -1
- warp/tests/test_scalar_ops.py +38 -10
- warp/tests/test_smoothstep.py +1 -1
- warp/tests/test_sparse.py +126 -15
- warp/tests/test_spatial.py +105 -87
- warp/tests/test_special_values.py +6 -6
- warp/tests/test_static.py +7 -7
- warp/tests/test_struct.py +13 -2
- warp/tests/test_triangle_closest_point.py +48 -1
- warp/tests/test_tuple.py +96 -0
- warp/tests/test_types.py +82 -9
- warp/tests/test_utils.py +52 -52
- warp/tests/test_vec.py +29 -29
- warp/tests/test_vec_constructors.py +5 -5
- warp/tests/test_vec_scalar_ops.py +97 -97
- warp/tests/test_version.py +75 -0
- warp/tests/tile/test_tile.py +239 -0
- warp/tests/tile/test_tile_atomic_bitwise.py +403 -0
- warp/tests/tile/test_tile_cholesky.py +7 -4
- warp/tests/tile/test_tile_load.py +26 -2
- warp/tests/tile/test_tile_mathdx.py +3 -3
- warp/tests/tile/test_tile_matmul.py +1 -1
- warp/tests/tile/test_tile_mlp.py +2 -4
- warp/tests/tile/test_tile_reduce.py +214 -13
- warp/tests/unittest_suites.py +6 -14
- warp/tests/unittest_utils.py +10 -9
- warp/tests/walkthrough_debug.py +3 -1
- warp/torch.py +6 -373
- warp/types.py +29 -5750
- warp/utils.py +10 -1659
- {warp_lang-1.9.0.dist-info → warp_lang-1.10.0rc2.dist-info}/METADATA +47 -103
- warp_lang-1.10.0rc2.dist-info/RECORD +468 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/Gaia-LICENSE.txt +6 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/appdirs-LICENSE.txt +22 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/asset_pixel_jpg-LICENSE.txt +3 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/cuda-LICENSE.txt +1582 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/dlpack-LICENSE.txt +201 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/fp16-LICENSE.txt +28 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/libmathdx-LICENSE.txt +220 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/llvm-LICENSE.txt +279 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/moller-LICENSE.txt +16 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/nanovdb-LICENSE.txt +2 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/nvrtc-LICENSE.txt +1592 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/svd-LICENSE.txt +23 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/unittest_parallel-LICENSE.txt +21 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/usd-LICENSE.txt +213 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/windingnumber-LICENSE.txt +21 -0
- warp/examples/assets/cartpole.urdf +0 -110
- warp/examples/assets/crazyflie.usd +0 -0
- warp/examples/assets/nv_ant.xml +0 -92
- warp/examples/assets/nv_humanoid.xml +0 -183
- warp/examples/assets/quadruped.urdf +0 -268
- warp/examples/optim/example_bounce.py +0 -266
- warp/examples/optim/example_cloth_throw.py +0 -228
- warp/examples/optim/example_drone.py +0 -870
- warp/examples/optim/example_inverse_kinematics.py +0 -182
- warp/examples/optim/example_inverse_kinematics_torch.py +0 -191
- warp/examples/optim/example_softbody_properties.py +0 -400
- warp/examples/optim/example_spring_cage.py +0 -245
- warp/examples/optim/example_trajectory.py +0 -227
- warp/examples/sim/example_cartpole.py +0 -143
- warp/examples/sim/example_cloth.py +0 -225
- warp/examples/sim/example_cloth_self_contact.py +0 -316
- warp/examples/sim/example_granular.py +0 -130
- warp/examples/sim/example_granular_collision_sdf.py +0 -202
- warp/examples/sim/example_jacobian_ik.py +0 -244
- warp/examples/sim/example_particle_chain.py +0 -124
- warp/examples/sim/example_quadruped.py +0 -203
- warp/examples/sim/example_rigid_chain.py +0 -203
- warp/examples/sim/example_rigid_contact.py +0 -195
- warp/examples/sim/example_rigid_force.py +0 -133
- warp/examples/sim/example_rigid_gyroscopic.py +0 -115
- warp/examples/sim/example_rigid_soft_contact.py +0 -140
- warp/examples/sim/example_soft_body.py +0 -196
- warp/examples/tile/example_tile_walker.py +0 -327
- warp/sim/__init__.py +0 -74
- warp/sim/articulation.py +0 -793
- warp/sim/collide.py +0 -2570
- warp/sim/graph_coloring.py +0 -307
- warp/sim/import_mjcf.py +0 -791
- warp/sim/import_snu.py +0 -227
- warp/sim/import_urdf.py +0 -579
- warp/sim/import_usd.py +0 -898
- warp/sim/inertia.py +0 -357
- warp/sim/integrator.py +0 -245
- warp/sim/integrator_euler.py +0 -2000
- warp/sim/integrator_featherstone.py +0 -2101
- warp/sim/integrator_vbd.py +0 -2487
- warp/sim/integrator_xpbd.py +0 -3295
- warp/sim/model.py +0 -4821
- warp/sim/particles.py +0 -121
- warp/sim/render.py +0 -431
- warp/sim/utils.py +0 -431
- warp/tests/sim/disabled_kinematics.py +0 -244
- warp/tests/sim/test_cloth.py +0 -863
- warp/tests/sim/test_collision.py +0 -743
- warp/tests/sim/test_coloring.py +0 -347
- warp/tests/sim/test_inertia.py +0 -161
- warp/tests/sim/test_model.py +0 -226
- warp/tests/sim/test_sim_grad.py +0 -287
- warp/tests/sim/test_sim_grad_bounce_linear.py +0 -212
- warp/tests/sim/test_sim_kinematics.py +0 -98
- warp/thirdparty/__init__.py +0 -0
- warp_lang-1.9.0.dist-info/RECORD +0 -456
- /warp/{fem → _src/fem}/quadrature/__init__.py +0 -0
- /warp/{tests/sim → _src/thirdparty}/__init__.py +0 -0
- /warp/{thirdparty → _src/thirdparty}/appdirs.py +0 -0
- /warp/{thirdparty → _src/thirdparty}/dlpack.py +0 -0
- {warp_lang-1.9.0.dist-info → warp_lang-1.10.0rc2.dist-info}/WHEEL +0 -0
- {warp_lang-1.9.0.dist-info → warp_lang-1.10.0rc2.dist-info}/licenses/LICENSE.md +0 -0
- {warp_lang-1.9.0.dist-info → warp_lang-1.10.0rc2.dist-info}/top_level.txt +0 -0
warp/tests/test_array.py
CHANGED
|
@@ -364,6 +364,7 @@ def test_slicing(test, device):
|
|
|
364
364
|
slice_e = arr[-1:3, :, :] # test mixed slicing
|
|
365
365
|
slice_e2 = slice_e[0, 0, :] # test 2x slicing
|
|
366
366
|
slice_f = arr[0:3:2, 0, :] # test step
|
|
367
|
+
slice_g = arr[1:1, :0, -1:-1] # test empty slice
|
|
367
368
|
|
|
368
369
|
assert_array_equal(slice_a, wp.array(np_arr[1, :, :], dtype=float, device=device))
|
|
369
370
|
assert_array_equal(slice_b, wp.array(np_arr[1:2, :, :], dtype=float, device=device))
|
|
@@ -371,6 +372,7 @@ def test_slicing(test, device):
|
|
|
371
372
|
assert_array_equal(slice_d, wp.array(np_arr[-2:-1, :, :], dtype=float, device=device))
|
|
372
373
|
assert_array_equal(slice_e, wp.array(np_arr[-1:3, :, :], dtype=float, device=device))
|
|
373
374
|
assert_array_equal(slice_e2, wp.array(np_arr[2, 0, :], dtype=float, device=device))
|
|
375
|
+
assert slice_g.shape == np_arr[1:1, :0, -1:-1].shape == (0, 0, 0)
|
|
374
376
|
|
|
375
377
|
# wp does not support copying from/to non-contiguous arrays
|
|
376
378
|
# stepped windows must read on the device the original array was created on
|
|
@@ -524,7 +526,7 @@ def test_transpose(test, device):
|
|
|
524
526
|
def test_fill_scalar(test, device):
|
|
525
527
|
dim_x = 4
|
|
526
528
|
|
|
527
|
-
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():
|
|
528
530
|
a1 = wp.zeros(dim_x, dtype=wptype, device=device)
|
|
529
531
|
a2 = wp.zeros((dim_x, dim_x), dtype=wptype, device=device)
|
|
530
532
|
a3 = wp.zeros((dim_x, dim_x, dim_x), dtype=wptype, device=device)
|
|
@@ -558,7 +560,7 @@ def test_fill_scalar(test, device):
|
|
|
558
560
|
assert_np_equal(a3.numpy(), np.zeros(a3.shape, dtype=nptype))
|
|
559
561
|
assert_np_equal(a4.numpy(), np.zeros(a4.shape, dtype=nptype))
|
|
560
562
|
|
|
561
|
-
if wptype in wp.types.float_types:
|
|
563
|
+
if wptype in wp._src.types.float_types:
|
|
562
564
|
# fill with float value
|
|
563
565
|
fill_value = 13.37
|
|
564
566
|
|
|
@@ -591,13 +593,13 @@ def test_fill_vector(test, device):
|
|
|
591
593
|
|
|
592
594
|
dim_x = 4
|
|
593
595
|
|
|
594
|
-
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():
|
|
595
597
|
# vector types
|
|
596
598
|
vector_types = [
|
|
597
|
-
wp.types.vector(2, wptype),
|
|
598
|
-
wp.types.vector(3, wptype),
|
|
599
|
-
wp.types.vector(4, wptype),
|
|
600
|
-
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),
|
|
601
603
|
]
|
|
602
604
|
|
|
603
605
|
for vec_type in vector_types:
|
|
@@ -692,7 +694,7 @@ def test_fill_vector(test, device):
|
|
|
692
694
|
assert_np_equal(a3.numpy(), expected3)
|
|
693
695
|
assert_np_equal(a4.numpy(), expected4)
|
|
694
696
|
|
|
695
|
-
if wptype in wp.types.float_types:
|
|
697
|
+
if wptype in wp._src.types.float_types:
|
|
696
698
|
# fill with float scalar
|
|
697
699
|
fill_value = 13.37
|
|
698
700
|
|
|
@@ -730,19 +732,19 @@ def test_fill_matrix(test, device):
|
|
|
730
732
|
|
|
731
733
|
dim_x = 4
|
|
732
734
|
|
|
733
|
-
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():
|
|
734
736
|
# matrix types
|
|
735
737
|
matrix_types = [
|
|
736
738
|
# square matrices
|
|
737
|
-
wp.types.matrix((2, 2), wptype),
|
|
738
|
-
wp.types.matrix((3, 3), wptype),
|
|
739
|
-
wp.types.matrix((4, 4), wptype),
|
|
740
|
-
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),
|
|
741
743
|
# non-square matrices
|
|
742
|
-
wp.types.matrix((2, 3), wptype),
|
|
743
|
-
wp.types.matrix((3, 2), wptype),
|
|
744
|
-
wp.types.matrix((3, 4), wptype),
|
|
745
|
-
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),
|
|
746
748
|
]
|
|
747
749
|
|
|
748
750
|
for mat_type in matrix_types:
|
|
@@ -889,15 +891,15 @@ class FillStruct:
|
|
|
889
891
|
f4: wp.float32
|
|
890
892
|
f8: wp.float16
|
|
891
893
|
# vector members (make sure to test vectors of float16)
|
|
892
|
-
v2: wp.types.vector(2, wp.int64)
|
|
893
|
-
v3: wp.types.vector(3, wp.float32)
|
|
894
|
-
v4: wp.types.vector(4, wp.float16)
|
|
895
|
-
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)
|
|
896
898
|
# matrix members (make sure to test matrices of float16)
|
|
897
|
-
m2: wp.types.matrix((2, 2), wp.float64)
|
|
898
|
-
m3: wp.types.matrix((3, 3), wp.int32)
|
|
899
|
-
m4: wp.types.matrix((4, 4), wp.float16)
|
|
900
|
-
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)
|
|
901
903
|
# arrays
|
|
902
904
|
a1: wp.array(dtype=float)
|
|
903
905
|
a2: wp.array2d(dtype=float)
|
|
@@ -998,7 +1000,7 @@ def test_fill_slices(test, device):
|
|
|
998
1000
|
|
|
999
1001
|
dim_x = 8
|
|
1000
1002
|
|
|
1001
|
-
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():
|
|
1002
1004
|
a1 = wp.zeros(dim_x, dtype=wptype, device=device)
|
|
1003
1005
|
a2 = wp.zeros((dim_x, dim_x), dtype=wptype, device=device)
|
|
1004
1006
|
a3 = wp.zeros((dim_x, dim_x, dim_x), dtype=wptype, device=device)
|
|
@@ -1009,7 +1011,7 @@ def test_fill_slices(test, device):
|
|
|
1009
1011
|
assert_np_equal(a3.numpy(), np.zeros(a3.shape, dtype=nptype))
|
|
1010
1012
|
assert_np_equal(a4.numpy(), np.zeros(a4.shape, dtype=nptype))
|
|
1011
1013
|
|
|
1012
|
-
#
|
|
1014
|
+
# partition each array into even and odd slices
|
|
1013
1015
|
a1a = a1[::2]
|
|
1014
1016
|
a1b = a1[1::2]
|
|
1015
1017
|
a2a = a2[::2]
|
|
@@ -1106,7 +1108,7 @@ def test_full_scalar(test, device):
|
|
|
1106
1108
|
for ndim in range(1, 5):
|
|
1107
1109
|
shape = (dim,) * ndim
|
|
1108
1110
|
|
|
1109
|
-
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():
|
|
1110
1112
|
# fill with int value and specific dtype
|
|
1111
1113
|
fill_value = 42
|
|
1112
1114
|
a = wp.full(shape, fill_value, dtype=wptype, device=device)
|
|
@@ -1118,7 +1120,7 @@ def test_full_scalar(test, device):
|
|
|
1118
1120
|
test.assertEqual(na.dtype, nptype)
|
|
1119
1121
|
assert_np_equal(na, np.full(shape, fill_value, dtype=nptype))
|
|
1120
1122
|
|
|
1121
|
-
if wptype in wp.types.float_types:
|
|
1123
|
+
if wptype in wp._src.types.float_types:
|
|
1122
1124
|
# fill with float value and specific dtype
|
|
1123
1125
|
fill_value = 13.37
|
|
1124
1126
|
a = wp.full(shape, fill_value, dtype=wptype, device=device)
|
|
@@ -1163,8 +1165,8 @@ def test_full_vector(test, device):
|
|
|
1163
1165
|
for veclen in [2, 3, 4, 5]:
|
|
1164
1166
|
npshape = (*shape, veclen)
|
|
1165
1167
|
|
|
1166
|
-
for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
|
|
1167
|
-
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)
|
|
1168
1170
|
|
|
1169
1171
|
# fill with scalar int value and specific dtype
|
|
1170
1172
|
fill_value = 42
|
|
@@ -1177,7 +1179,7 @@ def test_full_vector(test, device):
|
|
|
1177
1179
|
test.assertEqual(na.dtype, nptype)
|
|
1178
1180
|
assert_np_equal(na, np.full(a.size * veclen, fill_value, dtype=nptype).reshape(npshape))
|
|
1179
1181
|
|
|
1180
|
-
if wptype in wp.types.float_types:
|
|
1182
|
+
if wptype in wp._src.types.float_types:
|
|
1181
1183
|
# fill with scalar float value and specific dtype
|
|
1182
1184
|
fill_value = 13.37
|
|
1183
1185
|
a = wp.full(shape, fill_value, dtype=vectype, device=device)
|
|
@@ -1222,8 +1224,8 @@ def test_full_vector(test, device):
|
|
|
1222
1224
|
veclen = len(fill_list)
|
|
1223
1225
|
npshape = (*shape, veclen)
|
|
1224
1226
|
|
|
1225
|
-
for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
|
|
1226
|
-
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)
|
|
1227
1229
|
|
|
1228
1230
|
# fill with list and specific dtype
|
|
1229
1231
|
a = wp.full(shape, fill_list, dtype=vectype, device=device)
|
|
@@ -1254,7 +1256,7 @@ def test_full_vector(test, device):
|
|
|
1254
1256
|
na = a.numpy()
|
|
1255
1257
|
|
|
1256
1258
|
test.assertEqual(a.shape, shape)
|
|
1257
|
-
test.assertTrue(wp.types.types_equal(a.dtype, vectype))
|
|
1259
|
+
test.assertTrue(wp._src.types.types_equal(a.dtype, vectype))
|
|
1258
1260
|
test.assertEqual(na.shape, npshape)
|
|
1259
1261
|
test.assertEqual(na.dtype, nptype)
|
|
1260
1262
|
assert_np_equal(na, expected)
|
|
@@ -1281,18 +1283,18 @@ def test_full_matrix(test, device):
|
|
|
1281
1283
|
for ndim in range(1, 5):
|
|
1282
1284
|
shape = (dim,) * ndim
|
|
1283
1285
|
|
|
1284
|
-
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():
|
|
1285
1287
|
matrix_types = [
|
|
1286
1288
|
# square matrices
|
|
1287
|
-
wp.types.matrix((2, 2), wptype),
|
|
1288
|
-
wp.types.matrix((3, 3), wptype),
|
|
1289
|
-
wp.types.matrix((4, 4), wptype),
|
|
1290
|
-
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),
|
|
1291
1293
|
# non-square matrices
|
|
1292
|
-
wp.types.matrix((2, 3), wptype),
|
|
1293
|
-
wp.types.matrix((3, 2), wptype),
|
|
1294
|
-
wp.types.matrix((3, 4), wptype),
|
|
1295
|
-
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),
|
|
1296
1298
|
]
|
|
1297
1299
|
|
|
1298
1300
|
for mattype in matrix_types:
|
|
@@ -1309,7 +1311,7 @@ def test_full_matrix(test, device):
|
|
|
1309
1311
|
test.assertEqual(na.dtype, nptype)
|
|
1310
1312
|
assert_np_equal(na, np.full(a.size * mattype._length_, fill_value, dtype=nptype).reshape(npshape))
|
|
1311
1313
|
|
|
1312
|
-
if wptype in wp.types.float_types:
|
|
1314
|
+
if wptype in wp._src.types.float_types:
|
|
1313
1315
|
# fill with scalar float value and specific dtype
|
|
1314
1316
|
fill_value = 13.37
|
|
1315
1317
|
a = wp.full(shape, fill_value, dtype=mattype, device=device)
|
|
@@ -1375,7 +1377,7 @@ def test_full_matrix(test, device):
|
|
|
1375
1377
|
na = a.numpy()
|
|
1376
1378
|
|
|
1377
1379
|
test.assertEqual(a.shape, shape)
|
|
1378
|
-
test.assertTrue(wp.types.types_equal(a.dtype, mattype))
|
|
1380
|
+
test.assertTrue(wp._src.types.types_equal(a.dtype, mattype))
|
|
1379
1381
|
test.assertEqual(na.shape, npshape)
|
|
1380
1382
|
test.assertEqual(na.dtype, nptype)
|
|
1381
1383
|
assert_np_equal(na, expected)
|
|
@@ -1505,7 +1507,7 @@ def test_ones_scalar(test, device):
|
|
|
1505
1507
|
for ndim in range(1, 5):
|
|
1506
1508
|
shape = (dim,) * ndim
|
|
1507
1509
|
|
|
1508
|
-
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():
|
|
1509
1511
|
a = wp.ones(shape, dtype=wptype, device=device)
|
|
1510
1512
|
na = a.numpy()
|
|
1511
1513
|
|
|
@@ -1525,8 +1527,8 @@ def test_ones_vector(test, device):
|
|
|
1525
1527
|
for veclen in [2, 3, 4, 5]:
|
|
1526
1528
|
npshape = (*shape, veclen)
|
|
1527
1529
|
|
|
1528
|
-
for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
|
|
1529
|
-
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)
|
|
1530
1532
|
|
|
1531
1533
|
a = wp.ones(shape, dtype=vectype, device=device)
|
|
1532
1534
|
na = a.numpy()
|
|
@@ -1544,18 +1546,18 @@ def test_ones_matrix(test, device):
|
|
|
1544
1546
|
for ndim in range(1, 5):
|
|
1545
1547
|
shape = (dim,) * ndim
|
|
1546
1548
|
|
|
1547
|
-
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():
|
|
1548
1550
|
matrix_types = [
|
|
1549
1551
|
# square matrices
|
|
1550
|
-
wp.types.matrix((2, 2), wptype),
|
|
1551
|
-
wp.types.matrix((3, 3), wptype),
|
|
1552
|
-
wp.types.matrix((4, 4), wptype),
|
|
1553
|
-
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),
|
|
1554
1556
|
# non-square matrices
|
|
1555
|
-
wp.types.matrix((2, 3), wptype),
|
|
1556
|
-
wp.types.matrix((3, 2), wptype),
|
|
1557
|
-
wp.types.matrix((3, 4), wptype),
|
|
1558
|
-
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),
|
|
1559
1561
|
]
|
|
1560
1562
|
|
|
1561
1563
|
for mattype in matrix_types:
|
|
@@ -1577,7 +1579,7 @@ def test_ones_like_scalar(test, device):
|
|
|
1577
1579
|
for ndim in range(1, 5):
|
|
1578
1580
|
shape = (dim,) * ndim
|
|
1579
1581
|
|
|
1580
|
-
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():
|
|
1581
1583
|
# source array
|
|
1582
1584
|
a = wp.zeros(shape, dtype=wptype, device=device)
|
|
1583
1585
|
na = a.numpy()
|
|
@@ -1606,8 +1608,8 @@ def test_ones_like_vector(test, device):
|
|
|
1606
1608
|
for veclen in [2, 3, 4, 5]:
|
|
1607
1609
|
npshape = (*shape, veclen)
|
|
1608
1610
|
|
|
1609
|
-
for nptype, wptype in wp.types.np_dtype_to_warp_type.items():
|
|
1610
|
-
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)
|
|
1611
1613
|
|
|
1612
1614
|
# source array
|
|
1613
1615
|
a = wp.zeros(shape, dtype=vectype, device=device)
|
|
@@ -1634,18 +1636,18 @@ def test_ones_like_matrix(test, device):
|
|
|
1634
1636
|
for ndim in range(1, 5):
|
|
1635
1637
|
shape = (dim,) * ndim
|
|
1636
1638
|
|
|
1637
|
-
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():
|
|
1638
1640
|
matrix_types = [
|
|
1639
1641
|
# square matrices
|
|
1640
|
-
wp.types.matrix((2, 2), wptype),
|
|
1641
|
-
wp.types.matrix((3, 3), wptype),
|
|
1642
|
-
wp.types.matrix((4, 4), wptype),
|
|
1643
|
-
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),
|
|
1644
1646
|
# non-square matrices
|
|
1645
|
-
wp.types.matrix((2, 3), wptype),
|
|
1646
|
-
wp.types.matrix((3, 2), wptype),
|
|
1647
|
-
wp.types.matrix((3, 4), wptype),
|
|
1648
|
-
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),
|
|
1649
1651
|
]
|
|
1650
1652
|
|
|
1651
1653
|
for mattype in matrix_types:
|
|
@@ -1674,7 +1676,7 @@ def test_round_trip(test, device):
|
|
|
1674
1676
|
rng = np.random.default_rng(123)
|
|
1675
1677
|
dim_x = 4
|
|
1676
1678
|
|
|
1677
|
-
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():
|
|
1678
1680
|
a_np = rng.standard_normal(size=dim_x).astype(nptype)
|
|
1679
1681
|
a = wp.array(a_np, device=device)
|
|
1680
1682
|
test.assertEqual(a.dtype, wptype)
|
|
@@ -1682,7 +1684,7 @@ def test_round_trip(test, device):
|
|
|
1682
1684
|
assert_np_equal(a.numpy(), a_np)
|
|
1683
1685
|
|
|
1684
1686
|
v_np = rng.standard_normal(size=(dim_x, 3)).astype(nptype)
|
|
1685
|
-
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)
|
|
1686
1688
|
|
|
1687
1689
|
assert_np_equal(v.numpy(), v_np)
|
|
1688
1690
|
|
|
@@ -1695,13 +1697,13 @@ def test_empty_array(test, device):
|
|
|
1695
1697
|
shape = (0,) * ndim
|
|
1696
1698
|
dtype_shape = ()
|
|
1697
1699
|
|
|
1698
|
-
if wptype in wp.types.scalar_types:
|
|
1700
|
+
if wptype in wp._src.types.scalar_types:
|
|
1699
1701
|
# scalar, vector, or matrix
|
|
1700
1702
|
if ncols > 0:
|
|
1701
1703
|
if nrows > 0:
|
|
1702
|
-
wptype = wp.types.matrix((nrows, ncols), wptype)
|
|
1704
|
+
wptype = wp._src.types.matrix((nrows, ncols), wptype)
|
|
1703
1705
|
else:
|
|
1704
|
-
wptype = wp.types.vector(ncols, wptype)
|
|
1706
|
+
wptype = wp._src.types.vector(ncols, wptype)
|
|
1705
1707
|
dtype_shape = wptype._shape_
|
|
1706
1708
|
fill_value = wptype(42)
|
|
1707
1709
|
else:
|
|
@@ -1743,7 +1745,7 @@ def test_empty_array(test, device):
|
|
|
1743
1745
|
|
|
1744
1746
|
for ndim in range(1, 5):
|
|
1745
1747
|
# test with scalars, vectors, and matrices
|
|
1746
|
-
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():
|
|
1747
1749
|
# scalars
|
|
1748
1750
|
test_empty_ops(ndim, 0, 0, wptype, nptype)
|
|
1749
1751
|
|
|
@@ -1772,9 +1774,9 @@ def test_empty_from_numpy(test, device):
|
|
|
1772
1774
|
|
|
1773
1775
|
if ncols > 0:
|
|
1774
1776
|
if nrows > 0:
|
|
1775
|
-
wptype = wp.types.matrix((nrows, ncols), wptype)
|
|
1777
|
+
wptype = wp._src.types.matrix((nrows, ncols), wptype)
|
|
1776
1778
|
else:
|
|
1777
|
-
wptype = wp.types.vector(ncols, wptype)
|
|
1779
|
+
wptype = wp._src.types.vector(ncols, wptype)
|
|
1778
1780
|
dtype_shape = wptype._shape_
|
|
1779
1781
|
|
|
1780
1782
|
npshape = (*shape, *dtype_shape)
|
|
@@ -1786,7 +1788,7 @@ def test_empty_from_numpy(test, device):
|
|
|
1786
1788
|
|
|
1787
1789
|
for ndim in range(1, 5):
|
|
1788
1790
|
# test with scalars, vectors, and matrices
|
|
1789
|
-
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():
|
|
1790
1792
|
# scalars
|
|
1791
1793
|
test_empty_from_data(ndim, 0, 0, wptype, nptype)
|
|
1792
1794
|
|
|
@@ -1809,16 +1811,16 @@ def test_empty_from_list(test, device):
|
|
|
1809
1811
|
def test_empty_from_data(nrows, ncols, wptype):
|
|
1810
1812
|
if ncols > 0:
|
|
1811
1813
|
if nrows > 0:
|
|
1812
|
-
wptype = wp.types.matrix((nrows, ncols), wptype)
|
|
1814
|
+
wptype = wp._src.types.matrix((nrows, ncols), wptype)
|
|
1813
1815
|
else:
|
|
1814
|
-
wptype = wp.types.vector(ncols, wptype)
|
|
1816
|
+
wptype = wp._src.types.vector(ncols, wptype)
|
|
1815
1817
|
|
|
1816
1818
|
a = wp.array([], dtype=wptype, device=device)
|
|
1817
1819
|
test.assertEqual(a.size, 0)
|
|
1818
1820
|
test.assertEqual(a.shape, (0,))
|
|
1819
1821
|
|
|
1820
1822
|
# test with scalars, vectors, and matrices
|
|
1821
|
-
for wptype in wp.types.scalar_types:
|
|
1823
|
+
for wptype in wp._src.types.scalar_types:
|
|
1822
1824
|
# scalars
|
|
1823
1825
|
test_empty_from_data(0, 0, wptype)
|
|
1824
1826
|
|
|
@@ -1842,7 +1844,7 @@ def test_to_list_scalar(test, device):
|
|
|
1842
1844
|
for ndim in range(1, 5):
|
|
1843
1845
|
shape = (dim,) * ndim
|
|
1844
1846
|
|
|
1845
|
-
for wptype in wp.types.scalar_types:
|
|
1847
|
+
for wptype in wp._src.types.scalar_types:
|
|
1846
1848
|
a = wp.full(shape, fill_value, dtype=wptype, device=device)
|
|
1847
1849
|
l = a.list()
|
|
1848
1850
|
|
|
@@ -1857,8 +1859,8 @@ def test_to_list_vector(test, device):
|
|
|
1857
1859
|
shape = (dim,) * ndim
|
|
1858
1860
|
|
|
1859
1861
|
for veclen in [2, 3, 4, 5]:
|
|
1860
|
-
for wptype in wp.types.scalar_types:
|
|
1861
|
-
vectype = wp.types.vector(veclen, wptype)
|
|
1862
|
+
for wptype in wp._src.types.scalar_types:
|
|
1863
|
+
vectype = wp._src.types.vector(veclen, wptype)
|
|
1862
1864
|
fill_value = vectype(42)
|
|
1863
1865
|
|
|
1864
1866
|
a = wp.full(shape, fill_value, dtype=vectype, device=device)
|
|
@@ -1874,18 +1876,18 @@ def test_to_list_matrix(test, device):
|
|
|
1874
1876
|
for ndim in range(1, 5):
|
|
1875
1877
|
shape = (dim,) * ndim
|
|
1876
1878
|
|
|
1877
|
-
for wptype in wp.types.scalar_types:
|
|
1879
|
+
for wptype in wp._src.types.scalar_types:
|
|
1878
1880
|
matrix_types = [
|
|
1879
1881
|
# square matrices
|
|
1880
|
-
wp.types.matrix((2, 2), wptype),
|
|
1881
|
-
wp.types.matrix((3, 3), wptype),
|
|
1882
|
-
wp.types.matrix((4, 4), wptype),
|
|
1883
|
-
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),
|
|
1884
1886
|
# non-square matrices
|
|
1885
|
-
wp.types.matrix((2, 3), wptype),
|
|
1886
|
-
wp.types.matrix((3, 2), wptype),
|
|
1887
|
-
wp.types.matrix((3, 4), wptype),
|
|
1888
|
-
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),
|
|
1889
1891
|
]
|
|
1890
1892
|
|
|
1891
1893
|
for mattype in matrix_types:
|
|
@@ -1912,9 +1914,9 @@ def test_to_list_struct(test, device):
|
|
|
1912
1914
|
vi: wp.vec2i
|
|
1913
1915
|
vf: wp.vec3f
|
|
1914
1916
|
vh: wp.vec4h
|
|
1915
|
-
mi: wp.types.matrix((2, 2), int)
|
|
1916
|
-
mf: wp.types.matrix((3, 3), float)
|
|
1917
|
-
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)
|
|
1918
1920
|
inner: Inner
|
|
1919
1921
|
a1: wp.array(dtype=int)
|
|
1920
1922
|
a2: wp.array2d(dtype=float)
|
|
@@ -2855,7 +2857,7 @@ def test_array_inplace_non_diff_ops(test, device):
|
|
|
2855
2857
|
wp.launch(inplace_div_1d, N, inputs=[x1, y1], device=device)
|
|
2856
2858
|
assert_np_equal(x1.numpy(), np.full(N, fill_value=2.0, dtype=float))
|
|
2857
2859
|
|
|
2858
|
-
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):
|
|
2859
2861
|
x = wp.full(N, value=0, dtype=dtype, device=device)
|
|
2860
2862
|
y = wp.full(N, value=1, dtype=dtype, device=device)
|
|
2861
2863
|
|
|
@@ -2978,7 +2980,7 @@ def test_numpy_array_interface(test, device):
|
|
|
2978
2980
|
|
|
2979
2981
|
n = 10
|
|
2980
2982
|
|
|
2981
|
-
scalar_types = wp.types.scalar_types
|
|
2983
|
+
scalar_types = wp._src.types.scalar_types
|
|
2982
2984
|
|
|
2983
2985
|
for dtype in scalar_types:
|
|
2984
2986
|
# test round trip
|
|
@@ -3078,7 +3080,7 @@ def test_alloc_strides(test, device):
|
|
|
3078
3080
|
a1 = wp.zeros(shape, dtype=dtype)
|
|
3079
3081
|
|
|
3080
3082
|
# allocate with contiguous strides
|
|
3081
|
-
strides = wp.types.strides_from_shape(shape, dtype)
|
|
3083
|
+
strides = wp._src.types.strides_from_shape(shape, dtype)
|
|
3082
3084
|
a2 = wp.zeros(shape, dtype=dtype, strides=strides)
|
|
3083
3085
|
|
|
3084
3086
|
# allocate with transposed (reversed) shape/strides
|
|
@@ -3167,6 +3169,428 @@ def test_cuda_interface_conversion(test, device):
|
|
|
3167
3169
|
assert wp_array.ptr != 0
|
|
3168
3170
|
|
|
3169
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
|
+
|
|
3170
3594
|
devices = get_test_devices()
|
|
3171
3595
|
|
|
3172
3596
|
|
|
@@ -3247,6 +3671,11 @@ add_function_test(TestArray, "test_array_len", test_array_len, devices=devices)
|
|
|
3247
3671
|
add_function_test(TestArray, "test_cuda_interface_conversion", test_cuda_interface_conversion, devices=devices)
|
|
3248
3672
|
add_function_test(TestArray, "test_array_from_data", test_array_from_data, devices=devices)
|
|
3249
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
|
+
|
|
3250
3679
|
try:
|
|
3251
3680
|
import torch
|
|
3252
3681
|
|