warp-lang 1.10.0__py3-none-macosx_11_0_arm64.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 +334 -0
- warp/__init__.pyi +5856 -0
- warp/_src/__init__.py +14 -0
- warp/_src/autograd.py +1077 -0
- warp/_src/build.py +620 -0
- warp/_src/build_dll.py +642 -0
- warp/_src/builtins.py +10555 -0
- warp/_src/codegen.py +4361 -0
- warp/_src/config.py +178 -0
- warp/_src/constants.py +59 -0
- warp/_src/context.py +8352 -0
- warp/_src/dlpack.py +464 -0
- warp/_src/fabric.py +362 -0
- warp/_src/fem/__init__.py +14 -0
- warp/_src/fem/adaptivity.py +510 -0
- warp/_src/fem/cache.py +689 -0
- warp/_src/fem/dirichlet.py +190 -0
- warp/_src/fem/domain.py +553 -0
- warp/_src/fem/field/__init__.py +131 -0
- warp/_src/fem/field/field.py +703 -0
- warp/_src/fem/field/nodal_field.py +403 -0
- warp/_src/fem/field/restriction.py +39 -0
- warp/_src/fem/field/virtual.py +1021 -0
- warp/_src/fem/geometry/__init__.py +32 -0
- warp/_src/fem/geometry/adaptive_nanogrid.py +782 -0
- warp/_src/fem/geometry/closest_point.py +99 -0
- warp/_src/fem/geometry/deformed_geometry.py +277 -0
- warp/_src/fem/geometry/element.py +854 -0
- warp/_src/fem/geometry/geometry.py +693 -0
- warp/_src/fem/geometry/grid_2d.py +478 -0
- warp/_src/fem/geometry/grid_3d.py +539 -0
- warp/_src/fem/geometry/hexmesh.py +956 -0
- warp/_src/fem/geometry/nanogrid.py +660 -0
- warp/_src/fem/geometry/partition.py +483 -0
- warp/_src/fem/geometry/quadmesh.py +597 -0
- warp/_src/fem/geometry/tetmesh.py +762 -0
- warp/_src/fem/geometry/trimesh.py +588 -0
- warp/_src/fem/integrate.py +2507 -0
- warp/_src/fem/linalg.py +385 -0
- warp/_src/fem/operator.py +398 -0
- warp/_src/fem/polynomial.py +231 -0
- warp/_src/fem/quadrature/__init__.py +17 -0
- warp/_src/fem/quadrature/pic_quadrature.py +318 -0
- warp/_src/fem/quadrature/quadrature.py +665 -0
- warp/_src/fem/space/__init__.py +248 -0
- warp/_src/fem/space/basis_function_space.py +499 -0
- warp/_src/fem/space/basis_space.py +681 -0
- warp/_src/fem/space/dof_mapper.py +253 -0
- warp/_src/fem/space/function_space.py +312 -0
- warp/_src/fem/space/grid_2d_function_space.py +179 -0
- warp/_src/fem/space/grid_3d_function_space.py +229 -0
- warp/_src/fem/space/hexmesh_function_space.py +255 -0
- warp/_src/fem/space/nanogrid_function_space.py +199 -0
- warp/_src/fem/space/partition.py +435 -0
- warp/_src/fem/space/quadmesh_function_space.py +222 -0
- warp/_src/fem/space/restriction.py +221 -0
- warp/_src/fem/space/shape/__init__.py +152 -0
- warp/_src/fem/space/shape/cube_shape_function.py +1107 -0
- warp/_src/fem/space/shape/shape_function.py +134 -0
- warp/_src/fem/space/shape/square_shape_function.py +928 -0
- warp/_src/fem/space/shape/tet_shape_function.py +829 -0
- warp/_src/fem/space/shape/triangle_shape_function.py +674 -0
- warp/_src/fem/space/tetmesh_function_space.py +270 -0
- warp/_src/fem/space/topology.py +461 -0
- warp/_src/fem/space/trimesh_function_space.py +193 -0
- warp/_src/fem/types.py +114 -0
- warp/_src/fem/utils.py +488 -0
- warp/_src/jax.py +188 -0
- warp/_src/jax_experimental/__init__.py +14 -0
- warp/_src/jax_experimental/custom_call.py +389 -0
- warp/_src/jax_experimental/ffi.py +1286 -0
- warp/_src/jax_experimental/xla_ffi.py +658 -0
- warp/_src/marching_cubes.py +710 -0
- warp/_src/math.py +416 -0
- warp/_src/optim/__init__.py +14 -0
- warp/_src/optim/adam.py +165 -0
- warp/_src/optim/linear.py +1608 -0
- warp/_src/optim/sgd.py +114 -0
- warp/_src/paddle.py +408 -0
- warp/_src/render/__init__.py +14 -0
- warp/_src/render/imgui_manager.py +291 -0
- warp/_src/render/render_opengl.py +3638 -0
- warp/_src/render/render_usd.py +939 -0
- warp/_src/render/utils.py +162 -0
- warp/_src/sparse.py +2718 -0
- warp/_src/tape.py +1208 -0
- warp/_src/thirdparty/__init__.py +0 -0
- warp/_src/thirdparty/appdirs.py +598 -0
- warp/_src/thirdparty/dlpack.py +145 -0
- warp/_src/thirdparty/unittest_parallel.py +676 -0
- warp/_src/torch.py +393 -0
- warp/_src/types.py +5888 -0
- warp/_src/utils.py +1695 -0
- warp/autograd.py +33 -0
- warp/bin/libwarp-clang.dylib +0 -0
- warp/bin/libwarp.dylib +0 -0
- warp/build.py +29 -0
- warp/build_dll.py +24 -0
- warp/codegen.py +24 -0
- warp/constants.py +24 -0
- warp/context.py +33 -0
- warp/dlpack.py +24 -0
- warp/examples/__init__.py +24 -0
- warp/examples/assets/bear.usd +0 -0
- warp/examples/assets/bunny.usd +0 -0
- warp/examples/assets/cube.usd +0 -0
- warp/examples/assets/nonuniform.usd +0 -0
- warp/examples/assets/nvidia_logo.png +0 -0
- warp/examples/assets/pixel.jpg +0 -0
- warp/examples/assets/rocks.nvdb +0 -0
- warp/examples/assets/rocks.usd +0 -0
- warp/examples/assets/sphere.usd +0 -0
- warp/examples/assets/square_cloth.usd +0 -0
- warp/examples/benchmarks/benchmark_api.py +389 -0
- warp/examples/benchmarks/benchmark_cloth.py +296 -0
- warp/examples/benchmarks/benchmark_cloth_cupy.py +96 -0
- warp/examples/benchmarks/benchmark_cloth_jax.py +105 -0
- warp/examples/benchmarks/benchmark_cloth_numba.py +161 -0
- warp/examples/benchmarks/benchmark_cloth_numpy.py +85 -0
- warp/examples/benchmarks/benchmark_cloth_paddle.py +94 -0
- warp/examples/benchmarks/benchmark_cloth_pytorch.py +94 -0
- warp/examples/benchmarks/benchmark_cloth_taichi.py +120 -0
- warp/examples/benchmarks/benchmark_cloth_warp.py +153 -0
- warp/examples/benchmarks/benchmark_gemm.py +164 -0
- warp/examples/benchmarks/benchmark_interop_paddle.py +166 -0
- warp/examples/benchmarks/benchmark_interop_torch.py +166 -0
- warp/examples/benchmarks/benchmark_launches.py +301 -0
- warp/examples/benchmarks/benchmark_tile_load_store.py +103 -0
- warp/examples/benchmarks/benchmark_tile_sort.py +155 -0
- warp/examples/browse.py +37 -0
- warp/examples/core/example_cupy.py +86 -0
- warp/examples/core/example_dem.py +241 -0
- warp/examples/core/example_fluid.py +299 -0
- warp/examples/core/example_graph_capture.py +150 -0
- warp/examples/core/example_marching_cubes.py +195 -0
- warp/examples/core/example_mesh.py +180 -0
- warp/examples/core/example_mesh_intersect.py +211 -0
- warp/examples/core/example_nvdb.py +182 -0
- warp/examples/core/example_raycast.py +111 -0
- warp/examples/core/example_raymarch.py +205 -0
- warp/examples/core/example_render_opengl.py +290 -0
- warp/examples/core/example_sample_mesh.py +300 -0
- warp/examples/core/example_sph.py +411 -0
- warp/examples/core/example_spin_lock.py +93 -0
- warp/examples/core/example_torch.py +211 -0
- warp/examples/core/example_wave.py +269 -0
- warp/examples/core/example_work_queue.py +118 -0
- warp/examples/distributed/example_jacobi_mpi.py +506 -0
- warp/examples/fem/example_adaptive_grid.py +286 -0
- warp/examples/fem/example_apic_fluid.py +469 -0
- warp/examples/fem/example_burgers.py +261 -0
- warp/examples/fem/example_convection_diffusion.py +181 -0
- warp/examples/fem/example_convection_diffusion_dg.py +225 -0
- warp/examples/fem/example_darcy_ls_optimization.py +489 -0
- warp/examples/fem/example_deformed_geometry.py +172 -0
- warp/examples/fem/example_diffusion.py +196 -0
- warp/examples/fem/example_diffusion_3d.py +225 -0
- warp/examples/fem/example_diffusion_mgpu.py +225 -0
- warp/examples/fem/example_distortion_energy.py +228 -0
- warp/examples/fem/example_elastic_shape_optimization.py +387 -0
- warp/examples/fem/example_magnetostatics.py +242 -0
- warp/examples/fem/example_mixed_elasticity.py +293 -0
- warp/examples/fem/example_navier_stokes.py +263 -0
- warp/examples/fem/example_nonconforming_contact.py +300 -0
- warp/examples/fem/example_stokes.py +213 -0
- warp/examples/fem/example_stokes_transfer.py +262 -0
- warp/examples/fem/example_streamlines.py +357 -0
- warp/examples/fem/utils.py +1047 -0
- warp/examples/interop/example_jax_callable.py +146 -0
- warp/examples/interop/example_jax_ffi_callback.py +132 -0
- warp/examples/interop/example_jax_kernel.py +232 -0
- warp/examples/optim/example_diffray.py +561 -0
- warp/examples/optim/example_fluid_checkpoint.py +497 -0
- warp/examples/tile/example_tile_block_cholesky.py +502 -0
- warp/examples/tile/example_tile_cholesky.py +88 -0
- warp/examples/tile/example_tile_convolution.py +66 -0
- warp/examples/tile/example_tile_fft.py +55 -0
- warp/examples/tile/example_tile_filtering.py +113 -0
- warp/examples/tile/example_tile_matmul.py +85 -0
- warp/examples/tile/example_tile_mcgp.py +191 -0
- warp/examples/tile/example_tile_mlp.py +385 -0
- warp/examples/tile/example_tile_nbody.py +199 -0
- warp/fabric.py +24 -0
- warp/fem/__init__.py +173 -0
- warp/fem/adaptivity.py +26 -0
- warp/fem/cache.py +30 -0
- warp/fem/dirichlet.py +24 -0
- warp/fem/field/__init__.py +24 -0
- warp/fem/field/field.py +26 -0
- warp/fem/geometry/__init__.py +21 -0
- warp/fem/geometry/closest_point.py +31 -0
- warp/fem/linalg.py +38 -0
- warp/fem/operator.py +32 -0
- warp/fem/polynomial.py +29 -0
- warp/fem/space/__init__.py +22 -0
- warp/fem/space/basis_space.py +24 -0
- warp/fem/space/shape/__init__.py +68 -0
- warp/fem/space/topology.py +24 -0
- warp/fem/types.py +24 -0
- warp/fem/utils.py +32 -0
- warp/jax.py +29 -0
- warp/jax_experimental/__init__.py +29 -0
- warp/jax_experimental/custom_call.py +29 -0
- warp/jax_experimental/ffi.py +39 -0
- warp/jax_experimental/xla_ffi.py +24 -0
- warp/marching_cubes.py +24 -0
- warp/math.py +37 -0
- warp/native/array.h +1687 -0
- warp/native/builtin.h +2327 -0
- warp/native/bvh.cpp +562 -0
- warp/native/bvh.cu +826 -0
- warp/native/bvh.h +555 -0
- warp/native/clang/clang.cpp +541 -0
- warp/native/coloring.cpp +622 -0
- warp/native/crt.cpp +51 -0
- warp/native/crt.h +568 -0
- warp/native/cuda_crt.h +1058 -0
- warp/native/cuda_util.cpp +677 -0
- warp/native/cuda_util.h +313 -0
- warp/native/error.cpp +77 -0
- warp/native/error.h +36 -0
- warp/native/exports.h +2023 -0
- warp/native/fabric.h +246 -0
- warp/native/hashgrid.cpp +311 -0
- warp/native/hashgrid.cu +89 -0
- warp/native/hashgrid.h +240 -0
- warp/native/initializer_array.h +41 -0
- warp/native/intersect.h +1253 -0
- warp/native/intersect_adj.h +375 -0
- warp/native/intersect_tri.h +348 -0
- warp/native/mat.h +5189 -0
- warp/native/mathdx.cpp +93 -0
- warp/native/matnn.h +221 -0
- warp/native/mesh.cpp +266 -0
- warp/native/mesh.cu +406 -0
- warp/native/mesh.h +2097 -0
- warp/native/nanovdb/GridHandle.h +533 -0
- warp/native/nanovdb/HostBuffer.h +591 -0
- warp/native/nanovdb/NanoVDB.h +6246 -0
- warp/native/nanovdb/NodeManager.h +323 -0
- warp/native/nanovdb/PNanoVDB.h +3390 -0
- warp/native/noise.h +859 -0
- warp/native/quat.h +1664 -0
- warp/native/rand.h +342 -0
- warp/native/range.h +145 -0
- warp/native/reduce.cpp +174 -0
- warp/native/reduce.cu +363 -0
- warp/native/runlength_encode.cpp +79 -0
- warp/native/runlength_encode.cu +61 -0
- warp/native/scan.cpp +47 -0
- warp/native/scan.cu +55 -0
- warp/native/scan.h +23 -0
- warp/native/solid_angle.h +466 -0
- warp/native/sort.cpp +251 -0
- warp/native/sort.cu +286 -0
- warp/native/sort.h +35 -0
- warp/native/sparse.cpp +241 -0
- warp/native/sparse.cu +435 -0
- warp/native/spatial.h +1306 -0
- warp/native/svd.h +727 -0
- warp/native/temp_buffer.h +46 -0
- warp/native/tile.h +4124 -0
- warp/native/tile_radix_sort.h +1112 -0
- warp/native/tile_reduce.h +838 -0
- warp/native/tile_scan.h +240 -0
- warp/native/tuple.h +189 -0
- warp/native/vec.h +2199 -0
- warp/native/version.h +23 -0
- warp/native/volume.cpp +501 -0
- warp/native/volume.cu +68 -0
- warp/native/volume.h +970 -0
- warp/native/volume_builder.cu +483 -0
- warp/native/volume_builder.h +52 -0
- warp/native/volume_impl.h +70 -0
- warp/native/warp.cpp +1143 -0
- warp/native/warp.cu +4604 -0
- warp/native/warp.h +358 -0
- warp/optim/__init__.py +20 -0
- warp/optim/adam.py +24 -0
- warp/optim/linear.py +35 -0
- warp/optim/sgd.py +24 -0
- warp/paddle.py +24 -0
- warp/py.typed +0 -0
- warp/render/__init__.py +22 -0
- warp/render/imgui_manager.py +29 -0
- warp/render/render_opengl.py +24 -0
- warp/render/render_usd.py +24 -0
- warp/render/utils.py +24 -0
- warp/sparse.py +51 -0
- warp/tape.py +24 -0
- warp/tests/__init__.py +1 -0
- warp/tests/__main__.py +4 -0
- warp/tests/assets/curlnoise_golden.npy +0 -0
- warp/tests/assets/mlp_golden.npy +0 -0
- warp/tests/assets/pixel.npy +0 -0
- warp/tests/assets/pnoise_golden.npy +0 -0
- warp/tests/assets/spiky.usd +0 -0
- warp/tests/assets/test_grid.nvdb +0 -0
- warp/tests/assets/test_index_grid.nvdb +0 -0
- warp/tests/assets/test_int32_grid.nvdb +0 -0
- warp/tests/assets/test_vec_grid.nvdb +0 -0
- warp/tests/assets/torus.nvdb +0 -0
- warp/tests/assets/torus.usda +105 -0
- warp/tests/aux_test_class_kernel.py +34 -0
- warp/tests/aux_test_compile_consts_dummy.py +18 -0
- warp/tests/aux_test_conditional_unequal_types_kernels.py +29 -0
- warp/tests/aux_test_dependent.py +29 -0
- warp/tests/aux_test_grad_customs.py +29 -0
- warp/tests/aux_test_instancing_gc.py +26 -0
- warp/tests/aux_test_module_aot.py +7 -0
- warp/tests/aux_test_module_unload.py +23 -0
- warp/tests/aux_test_name_clash1.py +40 -0
- warp/tests/aux_test_name_clash2.py +40 -0
- warp/tests/aux_test_reference.py +9 -0
- warp/tests/aux_test_reference_reference.py +8 -0
- warp/tests/aux_test_square.py +16 -0
- warp/tests/aux_test_unresolved_func.py +22 -0
- warp/tests/aux_test_unresolved_symbol.py +22 -0
- warp/tests/cuda/__init__.py +0 -0
- warp/tests/cuda/test_async.py +676 -0
- warp/tests/cuda/test_conditional_captures.py +1147 -0
- warp/tests/cuda/test_ipc.py +124 -0
- warp/tests/cuda/test_mempool.py +233 -0
- warp/tests/cuda/test_multigpu.py +169 -0
- warp/tests/cuda/test_peer.py +139 -0
- warp/tests/cuda/test_pinned.py +84 -0
- warp/tests/cuda/test_streams.py +691 -0
- warp/tests/geometry/__init__.py +0 -0
- warp/tests/geometry/test_bvh.py +335 -0
- warp/tests/geometry/test_hash_grid.py +259 -0
- warp/tests/geometry/test_marching_cubes.py +294 -0
- warp/tests/geometry/test_mesh.py +318 -0
- warp/tests/geometry/test_mesh_query_aabb.py +392 -0
- warp/tests/geometry/test_mesh_query_point.py +935 -0
- warp/tests/geometry/test_mesh_query_ray.py +323 -0
- warp/tests/geometry/test_volume.py +1103 -0
- warp/tests/geometry/test_volume_write.py +346 -0
- warp/tests/interop/__init__.py +0 -0
- warp/tests/interop/test_dlpack.py +730 -0
- warp/tests/interop/test_jax.py +1673 -0
- warp/tests/interop/test_paddle.py +800 -0
- warp/tests/interop/test_torch.py +1001 -0
- warp/tests/run_coverage_serial.py +39 -0
- warp/tests/test_adam.py +162 -0
- warp/tests/test_arithmetic.py +1096 -0
- warp/tests/test_array.py +3756 -0
- warp/tests/test_array_reduce.py +156 -0
- warp/tests/test_assert.py +303 -0
- warp/tests/test_atomic.py +336 -0
- warp/tests/test_atomic_bitwise.py +209 -0
- warp/tests/test_atomic_cas.py +312 -0
- warp/tests/test_bool.py +220 -0
- warp/tests/test_builtins_resolution.py +732 -0
- warp/tests/test_closest_point_edge_edge.py +327 -0
- warp/tests/test_codegen.py +974 -0
- warp/tests/test_codegen_instancing.py +1495 -0
- warp/tests/test_compile_consts.py +215 -0
- warp/tests/test_conditional.py +298 -0
- warp/tests/test_context.py +35 -0
- warp/tests/test_copy.py +319 -0
- warp/tests/test_ctypes.py +618 -0
- warp/tests/test_dense.py +73 -0
- warp/tests/test_devices.py +127 -0
- warp/tests/test_enum.py +136 -0
- warp/tests/test_examples.py +424 -0
- warp/tests/test_fabricarray.py +998 -0
- warp/tests/test_fast_math.py +72 -0
- warp/tests/test_fem.py +2204 -0
- warp/tests/test_fixedarray.py +229 -0
- warp/tests/test_fp16.py +136 -0
- warp/tests/test_func.py +501 -0
- warp/tests/test_future_annotations.py +100 -0
- warp/tests/test_generics.py +656 -0
- warp/tests/test_grad.py +893 -0
- warp/tests/test_grad_customs.py +339 -0
- warp/tests/test_grad_debug.py +341 -0
- warp/tests/test_implicit_init.py +411 -0
- warp/tests/test_import.py +45 -0
- warp/tests/test_indexedarray.py +1140 -0
- warp/tests/test_intersect.py +103 -0
- warp/tests/test_iter.py +76 -0
- warp/tests/test_large.py +177 -0
- warp/tests/test_launch.py +411 -0
- warp/tests/test_lerp.py +151 -0
- warp/tests/test_linear_solvers.py +223 -0
- warp/tests/test_lvalue.py +427 -0
- warp/tests/test_map.py +526 -0
- warp/tests/test_mat.py +3515 -0
- warp/tests/test_mat_assign_copy.py +178 -0
- warp/tests/test_mat_constructors.py +573 -0
- warp/tests/test_mat_lite.py +122 -0
- warp/tests/test_mat_scalar_ops.py +2913 -0
- warp/tests/test_math.py +212 -0
- warp/tests/test_module_aot.py +287 -0
- warp/tests/test_module_hashing.py +258 -0
- warp/tests/test_modules_lite.py +70 -0
- warp/tests/test_noise.py +252 -0
- warp/tests/test_operators.py +299 -0
- warp/tests/test_options.py +129 -0
- warp/tests/test_overwrite.py +551 -0
- warp/tests/test_print.py +408 -0
- warp/tests/test_quat.py +2653 -0
- warp/tests/test_quat_assign_copy.py +145 -0
- warp/tests/test_rand.py +339 -0
- warp/tests/test_reload.py +303 -0
- warp/tests/test_rounding.py +157 -0
- warp/tests/test_runlength_encode.py +196 -0
- warp/tests/test_scalar_ops.py +133 -0
- warp/tests/test_smoothstep.py +108 -0
- warp/tests/test_snippet.py +318 -0
- warp/tests/test_sparse.py +845 -0
- warp/tests/test_spatial.py +2859 -0
- warp/tests/test_spatial_assign_copy.py +160 -0
- warp/tests/test_special_values.py +361 -0
- warp/tests/test_static.py +640 -0
- warp/tests/test_struct.py +901 -0
- warp/tests/test_tape.py +242 -0
- warp/tests/test_transient_module.py +93 -0
- warp/tests/test_triangle_closest_point.py +192 -0
- warp/tests/test_tuple.py +361 -0
- warp/tests/test_types.py +615 -0
- warp/tests/test_utils.py +594 -0
- warp/tests/test_vec.py +1408 -0
- warp/tests/test_vec_assign_copy.py +143 -0
- warp/tests/test_vec_constructors.py +325 -0
- warp/tests/test_vec_lite.py +80 -0
- warp/tests/test_vec_scalar_ops.py +2327 -0
- warp/tests/test_verify_fp.py +100 -0
- warp/tests/test_version.py +75 -0
- warp/tests/tile/__init__.py +0 -0
- warp/tests/tile/test_tile.py +1519 -0
- warp/tests/tile/test_tile_atomic_bitwise.py +403 -0
- warp/tests/tile/test_tile_cholesky.py +608 -0
- warp/tests/tile/test_tile_load.py +724 -0
- warp/tests/tile/test_tile_mathdx.py +156 -0
- warp/tests/tile/test_tile_matmul.py +179 -0
- warp/tests/tile/test_tile_mlp.py +400 -0
- warp/tests/tile/test_tile_reduce.py +950 -0
- warp/tests/tile/test_tile_shared_memory.py +376 -0
- warp/tests/tile/test_tile_sort.py +121 -0
- warp/tests/tile/test_tile_view.py +173 -0
- warp/tests/unittest_serial.py +47 -0
- warp/tests/unittest_suites.py +430 -0
- warp/tests/unittest_utils.py +469 -0
- warp/tests/walkthrough_debug.py +95 -0
- warp/torch.py +24 -0
- warp/types.py +51 -0
- warp/utils.py +31 -0
- warp_lang-1.10.0.dist-info/METADATA +459 -0
- warp_lang-1.10.0.dist-info/RECORD +468 -0
- warp_lang-1.10.0.dist-info/WHEEL +5 -0
- warp_lang-1.10.0.dist-info/licenses/LICENSE.md +176 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/Gaia-LICENSE.txt +6 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/appdirs-LICENSE.txt +22 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/asset_pixel_jpg-LICENSE.txt +3 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/cuda-LICENSE.txt +1582 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/dlpack-LICENSE.txt +201 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/fp16-LICENSE.txt +28 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/libmathdx-LICENSE.txt +220 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/llvm-LICENSE.txt +279 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/moller-LICENSE.txt +16 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/nanovdb-LICENSE.txt +2 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/nvrtc-LICENSE.txt +1592 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/svd-LICENSE.txt +23 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/unittest_parallel-LICENSE.txt +21 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/usd-LICENSE.txt +213 -0
- warp_lang-1.10.0.dist-info/licenses/licenses/windingnumber-LICENSE.txt +21 -0
- warp_lang-1.10.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
import sys
|
|
17
|
+
import unittest
|
|
18
|
+
from typing import Tuple
|
|
19
|
+
|
|
20
|
+
import warp as wp
|
|
21
|
+
from warp.tests.unittest_utils import *
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@wp.kernel
|
|
25
|
+
def test_expect():
|
|
26
|
+
a = 1.0
|
|
27
|
+
a += 2.0
|
|
28
|
+
|
|
29
|
+
wp.expect_eq(123, 123)
|
|
30
|
+
wp.expect_neq(123, 234)
|
|
31
|
+
|
|
32
|
+
wp.expect_eq(wp.vec2(1.0, 2.0), wp.vec2(1.0, 2.0))
|
|
33
|
+
wp.expect_neq(wp.vec2(1.0, 2.0), wp.vec2(2.0, 3.0))
|
|
34
|
+
|
|
35
|
+
wp.expect_eq(wp.mat22(1.0, 2.0, 3.0, 4.0), wp.mat22(1.0, 2.0, 3.0, 4.0))
|
|
36
|
+
wp.expect_neq(wp.mat22(1.0, 2.0, 3.0, 4.0), wp.mat22(2.0, 3.0, 4.0, 5.0))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@wp.kernel
|
|
40
|
+
def test_rename():
|
|
41
|
+
a = 0
|
|
42
|
+
b = 1
|
|
43
|
+
|
|
44
|
+
a = b
|
|
45
|
+
a = 2
|
|
46
|
+
|
|
47
|
+
wp.expect_eq(a, 2)
|
|
48
|
+
wp.expect_eq(b, 1)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@wp.kernel
|
|
52
|
+
def test_inplace():
|
|
53
|
+
a = 1.0
|
|
54
|
+
a += 2.0
|
|
55
|
+
|
|
56
|
+
wp.expect_eq(a, 3.0)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@wp.kernel
|
|
60
|
+
def test_constant(c: float):
|
|
61
|
+
a = 0.0
|
|
62
|
+
a = c + 1.0
|
|
63
|
+
|
|
64
|
+
wp.expect_eq(a, 2.0)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@wp.kernel
|
|
68
|
+
def test_dynamic_for_rename(n: int):
|
|
69
|
+
f0 = int(0.0)
|
|
70
|
+
f1 = int(1.0)
|
|
71
|
+
|
|
72
|
+
for _i in range(0, n):
|
|
73
|
+
f = f0 + f1
|
|
74
|
+
|
|
75
|
+
f0 = f1
|
|
76
|
+
f1 = f
|
|
77
|
+
|
|
78
|
+
wp.expect_eq(f1, 89)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@wp.kernel
|
|
82
|
+
def test_dynamic_for_inplace(n: int):
|
|
83
|
+
a = float(0.0)
|
|
84
|
+
|
|
85
|
+
for _i in range(0, n):
|
|
86
|
+
a += 1.0
|
|
87
|
+
|
|
88
|
+
wp.expect_eq(a, float(n))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@wp.kernel
|
|
92
|
+
def test_reassign():
|
|
93
|
+
f0 = 1.0
|
|
94
|
+
f1 = f0
|
|
95
|
+
|
|
96
|
+
f1 = f1 + 2.0
|
|
97
|
+
|
|
98
|
+
wp.expect_eq(f1, 3.0)
|
|
99
|
+
wp.expect_eq(f0, 1.0)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@wp.kernel
|
|
103
|
+
def test_dynamic_reassign(n: int):
|
|
104
|
+
f0 = wp.vec3()
|
|
105
|
+
f1 = f0
|
|
106
|
+
|
|
107
|
+
for _i in range(0, n):
|
|
108
|
+
f1 = f1 - wp.vec3(2.0, 0.0, 0.0)
|
|
109
|
+
|
|
110
|
+
wp.expect_eq(f1, wp.vec3(-4.0, 0.0, 0.0))
|
|
111
|
+
wp.expect_eq(f0, wp.vec3())
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@wp.kernel
|
|
115
|
+
def test_range_static_sum(result: wp.array(dtype=int)):
|
|
116
|
+
a = int(0)
|
|
117
|
+
for _i in range(10):
|
|
118
|
+
a = a + 1
|
|
119
|
+
|
|
120
|
+
b = int(0)
|
|
121
|
+
for _i in range(0, 10):
|
|
122
|
+
b = b + 1
|
|
123
|
+
|
|
124
|
+
c = int(0)
|
|
125
|
+
for _i in range(0, 20, 2):
|
|
126
|
+
c = c + 1
|
|
127
|
+
|
|
128
|
+
result[0] = a
|
|
129
|
+
result[1] = b
|
|
130
|
+
result[2] = c
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@wp.kernel
|
|
134
|
+
def test_range_dynamic_sum(start: int, end: int, step: int, result: wp.array(dtype=int)):
|
|
135
|
+
a = int(0)
|
|
136
|
+
for _i in range(end):
|
|
137
|
+
a = a + 1
|
|
138
|
+
|
|
139
|
+
b = int(0)
|
|
140
|
+
for _i in range(start, end):
|
|
141
|
+
b = b + 1
|
|
142
|
+
|
|
143
|
+
c = int(0)
|
|
144
|
+
for _i in range(start, end * step, step):
|
|
145
|
+
c = c + 1
|
|
146
|
+
|
|
147
|
+
d = int(0)
|
|
148
|
+
for _i in range(end * step, start, -step):
|
|
149
|
+
d = d + 1
|
|
150
|
+
|
|
151
|
+
result[0] = a
|
|
152
|
+
result[1] = b
|
|
153
|
+
result[2] = c
|
|
154
|
+
result[3] = d
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@wp.kernel
|
|
158
|
+
def test_range_dynamic(start: int, end: int, step: int, result: wp.array(dtype=int)):
|
|
159
|
+
output = int(0)
|
|
160
|
+
for i in range(start, end, step):
|
|
161
|
+
result[output] = i
|
|
162
|
+
output += 1
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
@wp.kernel
|
|
166
|
+
def test_range_dynamic_nested(n: int):
|
|
167
|
+
sum1 = float(0.0)
|
|
168
|
+
sum2 = float(0.0)
|
|
169
|
+
sum3 = float(0.0)
|
|
170
|
+
|
|
171
|
+
for _i in range(n):
|
|
172
|
+
sum1 = sum1 + 1.0
|
|
173
|
+
sum3 = sum3 + 1.0
|
|
174
|
+
|
|
175
|
+
for _j in range(n):
|
|
176
|
+
sum2 = sum2 + 1.0
|
|
177
|
+
sum3 = sum3 + 1.0
|
|
178
|
+
|
|
179
|
+
sum3 = sum3 + 1.0
|
|
180
|
+
|
|
181
|
+
wp.expect_eq(sum1, float(n))
|
|
182
|
+
wp.expect_eq(sum2, float(n * n))
|
|
183
|
+
wp.expect_eq(sum3, float(n * n + 2 * n))
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
@wp.kernel
|
|
187
|
+
def test_while(n: int):
|
|
188
|
+
i = int(0)
|
|
189
|
+
|
|
190
|
+
while i < n:
|
|
191
|
+
i = i + 1
|
|
192
|
+
|
|
193
|
+
wp.expect_eq(i, n)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@wp.kernel
|
|
197
|
+
def test_pass(n: int):
|
|
198
|
+
i = int(0)
|
|
199
|
+
|
|
200
|
+
while i < n:
|
|
201
|
+
if False:
|
|
202
|
+
pass
|
|
203
|
+
else:
|
|
204
|
+
i = i + 1
|
|
205
|
+
|
|
206
|
+
wp.expect_eq(i, n)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@wp.kernel
|
|
210
|
+
def test_break(n: int):
|
|
211
|
+
a = int(0)
|
|
212
|
+
|
|
213
|
+
for _i in range(0, n):
|
|
214
|
+
if a == 5:
|
|
215
|
+
break
|
|
216
|
+
|
|
217
|
+
a += 1
|
|
218
|
+
|
|
219
|
+
wp.expect_eq(a, 5)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@wp.kernel
|
|
223
|
+
def test_break_early(n: int):
|
|
224
|
+
a = int(0)
|
|
225
|
+
|
|
226
|
+
for i in range(0, n):
|
|
227
|
+
if i > 5:
|
|
228
|
+
a = 1
|
|
229
|
+
break
|
|
230
|
+
|
|
231
|
+
wp.expect_eq(a, 1)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
@wp.kernel
|
|
235
|
+
def test_break_unroll():
|
|
236
|
+
a = int(0)
|
|
237
|
+
|
|
238
|
+
for i in range(0, 10):
|
|
239
|
+
if i > 5:
|
|
240
|
+
a = i
|
|
241
|
+
break
|
|
242
|
+
|
|
243
|
+
wp.expect_eq(a, 6)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
@wp.kernel
|
|
247
|
+
def test_break_while():
|
|
248
|
+
a = int(0)
|
|
249
|
+
|
|
250
|
+
while a < 10:
|
|
251
|
+
if a > 5:
|
|
252
|
+
break
|
|
253
|
+
a += 1
|
|
254
|
+
|
|
255
|
+
wp.expect_eq(a, 6)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
@wp.kernel
|
|
259
|
+
def test_break_multiple(n: int):
|
|
260
|
+
a = int(0)
|
|
261
|
+
|
|
262
|
+
for i in range(0, n):
|
|
263
|
+
if i == 6:
|
|
264
|
+
a = 1
|
|
265
|
+
break
|
|
266
|
+
|
|
267
|
+
if i == 5:
|
|
268
|
+
a = 2
|
|
269
|
+
break
|
|
270
|
+
|
|
271
|
+
if i == 7:
|
|
272
|
+
a = 3
|
|
273
|
+
break
|
|
274
|
+
|
|
275
|
+
wp.expect_eq(a, 2)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
@wp.kernel
|
|
279
|
+
def test_continue(n: int):
|
|
280
|
+
a = int(0)
|
|
281
|
+
|
|
282
|
+
for i in range(0, n):
|
|
283
|
+
if i == 5:
|
|
284
|
+
continue
|
|
285
|
+
|
|
286
|
+
a += 1
|
|
287
|
+
|
|
288
|
+
wp.expect_eq(a, n - 1)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
@wp.kernel
|
|
292
|
+
def test_continue_unroll():
|
|
293
|
+
a = int(0)
|
|
294
|
+
|
|
295
|
+
for i in range(0, 10):
|
|
296
|
+
if i == 5:
|
|
297
|
+
continue
|
|
298
|
+
|
|
299
|
+
a += 1
|
|
300
|
+
|
|
301
|
+
wp.expect_eq(a, 9)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
lower = wp.constant(-3)
|
|
305
|
+
upper = wp.constant(3)
|
|
306
|
+
step = wp.constant(2)
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
# test unrolling of loops with constant size params
|
|
310
|
+
# we can't easily test if unrolling has occurred
|
|
311
|
+
# so just verify correctness at this stage
|
|
312
|
+
@wp.kernel
|
|
313
|
+
def test_range_constant():
|
|
314
|
+
s = 0
|
|
315
|
+
for i in range(upper):
|
|
316
|
+
s += i
|
|
317
|
+
|
|
318
|
+
# sum [0, 3)
|
|
319
|
+
wp.expect_eq(s, 3)
|
|
320
|
+
|
|
321
|
+
s = 0
|
|
322
|
+
for i in range(lower, upper):
|
|
323
|
+
s += i
|
|
324
|
+
|
|
325
|
+
# sum [-3, 3)
|
|
326
|
+
wp.expect_eq(s, -3)
|
|
327
|
+
|
|
328
|
+
s = 0
|
|
329
|
+
for i in range(lower, upper, step):
|
|
330
|
+
s += i
|
|
331
|
+
|
|
332
|
+
# sum [-3, 3)
|
|
333
|
+
wp.expect_eq(s, -3)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
N = wp.constant(3)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
# test a dynamic loop nested between loops expected to be unrolled.
|
|
340
|
+
@wp.kernel
|
|
341
|
+
def test_range_constant_dynamic_nested(m: int):
|
|
342
|
+
s = int(0)
|
|
343
|
+
for _i in range(N):
|
|
344
|
+
for _k in range(m):
|
|
345
|
+
for _j in range(N):
|
|
346
|
+
s += 1
|
|
347
|
+
|
|
348
|
+
wp.expect_eq(s, N * m * N)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
@wp.kernel
|
|
352
|
+
def test_range_expression():
|
|
353
|
+
idx = 1
|
|
354
|
+
batch_size = 100
|
|
355
|
+
|
|
356
|
+
a = wp.float(0.0)
|
|
357
|
+
c = wp.float(1.0)
|
|
358
|
+
|
|
359
|
+
# constant expression with a function
|
|
360
|
+
for _i in range(4 * idx, wp.min(4 * idx + 4, batch_size)):
|
|
361
|
+
a += c
|
|
362
|
+
|
|
363
|
+
for _i in range(4 * idx, min(4 * idx + 4, batch_size)):
|
|
364
|
+
a += c
|
|
365
|
+
|
|
366
|
+
tid = wp.tid()
|
|
367
|
+
|
|
368
|
+
# dynamic expression with a function
|
|
369
|
+
for _i in range(4 * idx, wp.min(4 * idx, tid + 1000)):
|
|
370
|
+
a += c
|
|
371
|
+
|
|
372
|
+
for _i in range(4 * idx, min(4 * idx, tid + 1000)):
|
|
373
|
+
a += c
|
|
374
|
+
|
|
375
|
+
wp.expect_eq(a, 8.0)
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def test_unresolved_func(test, device):
|
|
379
|
+
# kernel with unresolved function must be in a separate module, otherwise the current module would fail to load
|
|
380
|
+
from warp.tests.aux_test_unresolved_func import unresolved_func_kernel
|
|
381
|
+
|
|
382
|
+
# ensure that an appropriate exception is raised when the bad module gets loaded
|
|
383
|
+
with test.assertRaisesRegex(RuntimeError, "Could not find function wp.missing_func"):
|
|
384
|
+
wp.launch(unresolved_func_kernel, dim=1, inputs=[], device=device)
|
|
385
|
+
|
|
386
|
+
# remove all references to the bad module so that subsequent calls to wp.force_load()
|
|
387
|
+
# won't try to load it unless we explicitly re-import it again
|
|
388
|
+
del wp._src.context.user_modules["warp.tests.aux_test_unresolved_func"]
|
|
389
|
+
del sys.modules["warp.tests.aux_test_unresolved_func"]
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def test_unresolved_symbol(test, device):
|
|
393
|
+
# kernel with unresolved symbol must be in a separate module, otherwise the current module would fail to load
|
|
394
|
+
from warp.tests.aux_test_unresolved_symbol import unresolved_symbol_kernel
|
|
395
|
+
|
|
396
|
+
# ensure that an appropriate exception is raised when the bad module gets loaded
|
|
397
|
+
with test.assertRaisesRegex(KeyError, "Referencing undefined symbol: missing_symbol"):
|
|
398
|
+
wp.launch(unresolved_symbol_kernel, dim=1, inputs=[], device=device)
|
|
399
|
+
|
|
400
|
+
# remove all references to the bad module so that subsequent calls to wp.force_load()
|
|
401
|
+
# won't try to load it unless we explicitly re-import it again
|
|
402
|
+
del wp._src.context.user_modules["warp.tests.aux_test_unresolved_symbol"]
|
|
403
|
+
del sys.modules["warp.tests.aux_test_unresolved_symbol"]
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
def test_error_global_var(test, device):
|
|
407
|
+
arr = wp.array((1.0, 2.0, 3.0), dtype=float, device=device)
|
|
408
|
+
|
|
409
|
+
def kernel_1_fn(out: wp.array(dtype=float)):
|
|
410
|
+
out[0] = arr[0]
|
|
411
|
+
|
|
412
|
+
def kernel_2_fn(out: wp.array(dtype=float)):
|
|
413
|
+
out[0] = arr
|
|
414
|
+
|
|
415
|
+
def kernel_3_fn(out: wp.array(dtype=float)):
|
|
416
|
+
out[0] = wp.lower_bound(arr, 2.0)
|
|
417
|
+
|
|
418
|
+
out = wp.empty_like(arr)
|
|
419
|
+
|
|
420
|
+
kernel = wp.Kernel(func=kernel_1_fn)
|
|
421
|
+
with test.assertRaisesRegex(TypeError, r"Invalid external reference type: <class 'warp._src.types.array'>"):
|
|
422
|
+
wp.launch(kernel, dim=out.shape, inputs=(), outputs=(out,), device=device)
|
|
423
|
+
|
|
424
|
+
kernel = wp.Kernel(func=kernel_2_fn)
|
|
425
|
+
with test.assertRaisesRegex(TypeError, r"Invalid external reference type: <class 'warp._src.types.array'>"):
|
|
426
|
+
wp.launch(kernel, dim=out.shape, inputs=(), outputs=(out,), device=device)
|
|
427
|
+
|
|
428
|
+
kernel = wp.Kernel(func=kernel_3_fn)
|
|
429
|
+
with test.assertRaisesRegex(TypeError, r"Invalid external reference type: <class 'warp._src.types.array'>"):
|
|
430
|
+
wp.launch(kernel, dim=out.shape, inputs=(), outputs=(out,), device=device)
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def test_error_collection_construct(test, device):
|
|
434
|
+
def kernel_1_fn():
|
|
435
|
+
x = [1.0, 2.0, 3.0]
|
|
436
|
+
|
|
437
|
+
def kernel_2_fn():
|
|
438
|
+
x = {"a": 1.0, "b": 2.0, "c": 3.0}
|
|
439
|
+
|
|
440
|
+
kernel = wp.Kernel(func=kernel_1_fn)
|
|
441
|
+
with test.assertRaisesRegex(
|
|
442
|
+
RuntimeError,
|
|
443
|
+
r"List constructs are not supported in kernels. Use vectors like `wp.vec3\(\)` for small collections instead.",
|
|
444
|
+
):
|
|
445
|
+
wp.launch(kernel, dim=1, device=device)
|
|
446
|
+
|
|
447
|
+
kernel = wp.Kernel(func=kernel_2_fn)
|
|
448
|
+
with test.assertRaisesRegex(RuntimeError, r"Construct `ast.Dict` not supported in kernels."):
|
|
449
|
+
wp.launch(kernel, dim=1, device=device)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def test_error_unmatched_arguments(test, device):
|
|
453
|
+
def kernel_1_fn():
|
|
454
|
+
a = 1 * 1.0
|
|
455
|
+
|
|
456
|
+
def kernel_2_fn():
|
|
457
|
+
x = wp.dot(wp.vec2(1.0, 2.0), wp.vec2h(wp.float16(1.0), wp.float16(2.0)))
|
|
458
|
+
|
|
459
|
+
kernel = wp.Kernel(func=kernel_1_fn)
|
|
460
|
+
with test.assertRaisesRegex(RuntimeError, r"Input types must be the same, got \['int32', 'float32'\]"):
|
|
461
|
+
wp.launch(kernel, dim=1, device=device)
|
|
462
|
+
|
|
463
|
+
kernel = wp.Kernel(func=kernel_2_fn)
|
|
464
|
+
with test.assertRaisesRegex(
|
|
465
|
+
RuntimeError,
|
|
466
|
+
r"Input types must be exactly the same, got \['vec2f', 'vec2h'\]",
|
|
467
|
+
):
|
|
468
|
+
wp.launch(kernel, dim=1, device=device)
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def test_error_mutating_constant_in_dynamic_loop(test, device):
|
|
472
|
+
@wp.kernel
|
|
473
|
+
def dynamic_loop_kernel(n: int, input: wp.array(dtype=float)):
|
|
474
|
+
my_constant = 0.0
|
|
475
|
+
for i in range(n):
|
|
476
|
+
my_constant += input[i]
|
|
477
|
+
|
|
478
|
+
inputs = wp.array([1.0, 2.0, 3.0], dtype=float, device=device)
|
|
479
|
+
with test.assertRaisesRegex(
|
|
480
|
+
wp._src.codegen.WarpCodegenError,
|
|
481
|
+
r"Error mutating a constant my_constant inside a dynamic loop, use the following syntax\: pi = float\(3\.141\) to declare a dynamic variable",
|
|
482
|
+
):
|
|
483
|
+
wp.launch(dynamic_loop_kernel, dim=1, inputs=[3, inputs], device=device)
|
|
484
|
+
|
|
485
|
+
# the following nested loop must not raise an error
|
|
486
|
+
const_a = 7
|
|
487
|
+
const_b = 5
|
|
488
|
+
|
|
489
|
+
@wp.kernel
|
|
490
|
+
def mixed_dyn_static_loop_kernel(dyn_a: int, dyn_b: int, dyn_c: int, output: wp.array(dtype=float, ndim=2)):
|
|
491
|
+
tid = wp.tid()
|
|
492
|
+
for i in range(const_a + 1):
|
|
493
|
+
for j in range(dyn_a + 1):
|
|
494
|
+
for k in range(dyn_b + 1):
|
|
495
|
+
for l in range(const_b + 1):
|
|
496
|
+
for m in range(dyn_c + 1):
|
|
497
|
+
coeff = i + j + k + l + m
|
|
498
|
+
output[tid, coeff] = 1.0
|
|
499
|
+
|
|
500
|
+
dyn_a, dyn_b, dyn_c = 3, 4, 5
|
|
501
|
+
num_threads = 10
|
|
502
|
+
output = wp.empty([num_threads, const_a + const_b + dyn_a + dyn_b + dyn_c + 1], dtype=float, device=device)
|
|
503
|
+
wp.launch(
|
|
504
|
+
mixed_dyn_static_loop_kernel,
|
|
505
|
+
num_threads,
|
|
506
|
+
inputs=[
|
|
507
|
+
dyn_a,
|
|
508
|
+
dyn_b,
|
|
509
|
+
dyn_c,
|
|
510
|
+
],
|
|
511
|
+
outputs=[output],
|
|
512
|
+
device=device,
|
|
513
|
+
)
|
|
514
|
+
assert_np_equal(output.numpy(), np.ones([num_threads, const_a + const_b + dyn_a + dyn_b + dyn_c + 1]))
|
|
515
|
+
|
|
516
|
+
@wp.kernel
|
|
517
|
+
def static_then_dynamic_loop_kernel(mats: wp.array(dtype=wp.mat33d)):
|
|
518
|
+
tid = wp.tid()
|
|
519
|
+
mat = wp.mat33d()
|
|
520
|
+
for i in range(3):
|
|
521
|
+
for j in range(3):
|
|
522
|
+
mat[i, j] = wp.float64(0.0)
|
|
523
|
+
|
|
524
|
+
dim = 2
|
|
525
|
+
for i in range(dim + 1):
|
|
526
|
+
for j in range(dim + 1):
|
|
527
|
+
mat[i, j] = wp.float64(1.0)
|
|
528
|
+
|
|
529
|
+
mats[tid] = mat
|
|
530
|
+
|
|
531
|
+
mats = wp.empty(1, dtype=wp.mat33d, device=device)
|
|
532
|
+
wp.launch(static_then_dynamic_loop_kernel, dim=1, inputs=[mats], device=device)
|
|
533
|
+
assert_np_equal(mats.numpy(), np.ones((1, 3, 3)))
|
|
534
|
+
|
|
535
|
+
@wp.kernel
|
|
536
|
+
def dynamic_then_static_loop_kernel(mats: wp.array(dtype=wp.mat33d)):
|
|
537
|
+
tid = wp.tid()
|
|
538
|
+
mat = wp.mat33d()
|
|
539
|
+
|
|
540
|
+
dim = 2
|
|
541
|
+
for i in range(dim + 1):
|
|
542
|
+
for j in range(dim + 1):
|
|
543
|
+
mat[i, j] = wp.float64(1.0)
|
|
544
|
+
|
|
545
|
+
for i in range(3):
|
|
546
|
+
for j in range(3):
|
|
547
|
+
mat[i, j] = wp.float64(0.0)
|
|
548
|
+
|
|
549
|
+
mats[tid] = mat
|
|
550
|
+
|
|
551
|
+
mats = wp.empty(1, dtype=wp.mat33d, device=device)
|
|
552
|
+
wp.launch(dynamic_then_static_loop_kernel, dim=1, inputs=[mats], device=device)
|
|
553
|
+
assert_np_equal(mats.numpy(), np.zeros((1, 3, 3)))
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
def test_error_return_annotation_mismatch(test, device):
|
|
557
|
+
@wp.func
|
|
558
|
+
def foo_1(x: wp.int32) -> wp.int16:
|
|
559
|
+
return wp.int8(x)
|
|
560
|
+
|
|
561
|
+
def kernel_1_fn():
|
|
562
|
+
x = foo_1(123)
|
|
563
|
+
|
|
564
|
+
@wp.func
|
|
565
|
+
def foo_2(x: int) -> int:
|
|
566
|
+
return (x + x, x * x)
|
|
567
|
+
|
|
568
|
+
def kernel_2_fn():
|
|
569
|
+
x = foo_2(123)
|
|
570
|
+
|
|
571
|
+
@wp.func
|
|
572
|
+
def foo_3(x: int) -> Tuple[int, int]:
|
|
573
|
+
return (x, 1.23)
|
|
574
|
+
|
|
575
|
+
def kernel_3_fn():
|
|
576
|
+
x, y = foo_3(123)
|
|
577
|
+
|
|
578
|
+
@wp.func
|
|
579
|
+
def foo_4(x: int) -> Tuple[int, int, int]:
|
|
580
|
+
return (x + x, x * x)
|
|
581
|
+
|
|
582
|
+
def kernel_4_fn():
|
|
583
|
+
x, y, z = foo_4(123)
|
|
584
|
+
|
|
585
|
+
kernel = wp.Kernel(func=kernel_1_fn)
|
|
586
|
+
with test.assertRaisesRegex(
|
|
587
|
+
wp._src.codegen.WarpCodegenError,
|
|
588
|
+
r"The function `foo_1` has its return type annotated as `int16` but the code returns a value of type `int8`.",
|
|
589
|
+
):
|
|
590
|
+
wp.launch(kernel, dim=1, device=device)
|
|
591
|
+
|
|
592
|
+
kernel = wp.Kernel(func=kernel_2_fn)
|
|
593
|
+
with test.assertRaisesRegex(
|
|
594
|
+
wp._src.codegen.WarpCodegenError,
|
|
595
|
+
r"The function `foo_2` has its return type annotated as `int` but the code returns 2 values.",
|
|
596
|
+
):
|
|
597
|
+
wp.launch(kernel, dim=1, device=device)
|
|
598
|
+
|
|
599
|
+
kernel = wp.Kernel(func=kernel_3_fn)
|
|
600
|
+
with test.assertRaisesRegex(
|
|
601
|
+
wp._src.codegen.WarpCodegenError,
|
|
602
|
+
r"The function `foo_3` has its return type annotated as `Tuple\[int, int\]` but the code returns a tuple with types `\(int32, float32\)`.",
|
|
603
|
+
):
|
|
604
|
+
wp.launch(kernel, dim=1, device=device)
|
|
605
|
+
|
|
606
|
+
kernel = wp.Kernel(func=kernel_4_fn)
|
|
607
|
+
with test.assertRaisesRegex(
|
|
608
|
+
wp._src.codegen.WarpCodegenError,
|
|
609
|
+
r"The function `foo_4` has its return type annotated as a tuple of 3 elements but the code returns 2 values.",
|
|
610
|
+
):
|
|
611
|
+
wp.launch(kernel, dim=1, device=device)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
@wp.kernel
|
|
615
|
+
def test_call_syntax():
|
|
616
|
+
expected_pow = 16.0
|
|
617
|
+
wp.expect_eq(wp.pow(2.0, 4.0), expected_pow)
|
|
618
|
+
wp.expect_eq(wp.pow(x=2.0, y=4.0), expected_pow)
|
|
619
|
+
wp.expect_eq(wp.pow(2.0, y=4.0), expected_pow)
|
|
620
|
+
wp.expect_eq(wp.pow(y=4.0, x=2.0), expected_pow)
|
|
621
|
+
|
|
622
|
+
expected_matrix = wp.mat44(2.0, 0.0, 0.0, 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 0.0, 4.0, 3.0, 0.0, 0.0, 0.0, 1.0)
|
|
623
|
+
pos = wp.vec3(1.0, 2.0, 3.0)
|
|
624
|
+
rot = wp.quat(0.0, 0.0, 0.0, 1.0)
|
|
625
|
+
scale = wp.vec3(2.0, 3.0, 4.0)
|
|
626
|
+
wp.expect_eq(wp.transform_compose(pos, rot, scale), expected_matrix)
|
|
627
|
+
wp.expect_eq(wp.transform_compose(position=pos, rotation=rot, scale=scale), expected_matrix)
|
|
628
|
+
wp.expect_eq(wp.transform_compose(rotation=rot, position=pos, scale=scale), expected_matrix)
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
# test shadowing builtin functions
|
|
632
|
+
@wp.func
|
|
633
|
+
def sum(a: wp.vec3) -> float:
|
|
634
|
+
return a[0] + a[1] + a[2]
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
@wp.kernel
|
|
638
|
+
def test_shadow_builtin():
|
|
639
|
+
wp.expect_eq(sum(wp.vec3(1.0)), 3.0)
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
@wp.struct
|
|
643
|
+
class Iterator:
|
|
644
|
+
valid: wp.bool
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
@wp.kernel(enable_backward=False)
|
|
648
|
+
def test_while_condition_eval():
|
|
649
|
+
it = Iterator()
|
|
650
|
+
it.valid = True
|
|
651
|
+
while it.valid:
|
|
652
|
+
it.valid = False
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
@wp.kernel
|
|
656
|
+
def conditional_return_or_sum(result: wp.array(dtype=wp.int32)):
|
|
657
|
+
tid = wp.tid()
|
|
658
|
+
|
|
659
|
+
if tid < 256:
|
|
660
|
+
return
|
|
661
|
+
|
|
662
|
+
wp.atomic_add(result, 0, 1)
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
def test_codegen_return_in_kernel(test, device):
|
|
666
|
+
result = wp.zeros(1, dtype=wp.int32, device=device)
|
|
667
|
+
|
|
668
|
+
grid_size = 1024
|
|
669
|
+
|
|
670
|
+
# On CUDA devices, this becomes a grid-stride loop
|
|
671
|
+
wp.launch(conditional_return_or_sum, dim=grid_size, inputs=[result], block_dim=256, max_blocks=1, device=device)
|
|
672
|
+
|
|
673
|
+
test.assertEqual(result.numpy()[0], grid_size - 256)
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
@wp.kernel
|
|
677
|
+
def conditional_ifexp(x: float, result: wp.array(dtype=wp.int32)):
|
|
678
|
+
wp.atomic_add(result, 0, 1) if x > 0.0 else wp.atomic_add(result, 1, 1)
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
def test_ifexp_only_executes_one_branch(test, device):
|
|
682
|
+
result = wp.zeros(2, dtype=wp.int32, device=device)
|
|
683
|
+
|
|
684
|
+
wp.launch(conditional_ifexp, dim=1, inputs=[1.0, result], device=device)
|
|
685
|
+
|
|
686
|
+
values = result.numpy()
|
|
687
|
+
# Only first branch is taken
|
|
688
|
+
test.assertEqual(values[0], 1)
|
|
689
|
+
test.assertEqual(values[1], 0)
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
@wp.kernel
|
|
693
|
+
def test_multiple_return_values_quat_to_axis_angle_kernel(
|
|
694
|
+
q: wp.quath,
|
|
695
|
+
expected_axis: wp.vec3h,
|
|
696
|
+
expected_angle: wp.float16,
|
|
697
|
+
):
|
|
698
|
+
axis, angle = wp.quat_to_axis_angle(q)
|
|
699
|
+
|
|
700
|
+
wp.expect_near(axis[0], expected_axis[0], tolerance=wp.float16(1e-3))
|
|
701
|
+
wp.expect_near(axis[1], expected_axis[1], tolerance=wp.float16(1e-3))
|
|
702
|
+
wp.expect_near(axis[2], expected_axis[2], tolerance=wp.float16(1e-3))
|
|
703
|
+
|
|
704
|
+
wp.expect_near(angle, expected_angle, tolerance=wp.float16(1e-3))
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
@wp.kernel
|
|
708
|
+
def test_multiple_return_values_svd3_kernel(
|
|
709
|
+
A: wp.mat33f,
|
|
710
|
+
expected_U: wp.mat33f,
|
|
711
|
+
expected_sigma: wp.vec3f,
|
|
712
|
+
expected_V: wp.mat33f,
|
|
713
|
+
):
|
|
714
|
+
U, sigma, V = wp.svd3(A)
|
|
715
|
+
|
|
716
|
+
wp.expect_near(U[0][0], expected_U[0][0], tolerance=1e-5)
|
|
717
|
+
wp.expect_near(U[0][1], expected_U[0][1], tolerance=1e-5)
|
|
718
|
+
wp.expect_near(U[0][2], expected_U[0][2], tolerance=1e-5)
|
|
719
|
+
wp.expect_near(U[1][0], expected_U[1][0], tolerance=1e-5)
|
|
720
|
+
wp.expect_near(U[1][1], expected_U[1][1], tolerance=1e-5)
|
|
721
|
+
wp.expect_near(U[1][2], expected_U[1][2], tolerance=1e-5)
|
|
722
|
+
wp.expect_near(U[2][0], expected_U[2][0], tolerance=1e-5)
|
|
723
|
+
wp.expect_near(U[2][1], expected_U[2][1], tolerance=1e-5)
|
|
724
|
+
wp.expect_near(U[2][2], expected_U[2][2], tolerance=1e-5)
|
|
725
|
+
|
|
726
|
+
wp.expect_near(sigma[0], expected_sigma[0], tolerance=1e-5)
|
|
727
|
+
wp.expect_near(sigma[1], expected_sigma[1], tolerance=1e-5)
|
|
728
|
+
wp.expect_near(sigma[2], expected_sigma[2], tolerance=1e-5)
|
|
729
|
+
|
|
730
|
+
wp.expect_near(V[0][0], expected_V[0][0], tolerance=1e-5)
|
|
731
|
+
wp.expect_near(V[0][1], expected_V[0][1], tolerance=1e-5)
|
|
732
|
+
wp.expect_near(V[0][2], expected_V[0][2], tolerance=1e-5)
|
|
733
|
+
wp.expect_near(V[1][0], expected_V[1][0], tolerance=1e-5)
|
|
734
|
+
wp.expect_near(V[1][1], expected_V[1][1], tolerance=1e-5)
|
|
735
|
+
wp.expect_near(V[1][2], expected_V[1][2], tolerance=1e-5)
|
|
736
|
+
wp.expect_near(V[2][0], expected_V[2][0], tolerance=1e-5)
|
|
737
|
+
wp.expect_near(V[2][1], expected_V[2][1], tolerance=1e-5)
|
|
738
|
+
wp.expect_near(V[2][2], expected_V[2][2], tolerance=1e-5)
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
def test_multiple_return_values(test, device):
|
|
742
|
+
q = wp.quath(1.0, 2.0, 3.0, 4.0)
|
|
743
|
+
expected_axis = wp.vec3h(0.26726124, 0.53452247, 0.80178368)
|
|
744
|
+
expected_angle = 1.50408018
|
|
745
|
+
|
|
746
|
+
axis, angle = wp.quat_to_axis_angle(q)
|
|
747
|
+
|
|
748
|
+
test.assertAlmostEqual(axis[0], expected_axis[0], places=3)
|
|
749
|
+
test.assertAlmostEqual(axis[1], expected_axis[1], places=3)
|
|
750
|
+
test.assertAlmostEqual(axis[2], expected_axis[2], places=3)
|
|
751
|
+
|
|
752
|
+
test.assertAlmostEqual(angle, expected_angle, places=3)
|
|
753
|
+
|
|
754
|
+
wp.launch(
|
|
755
|
+
test_multiple_return_values_quat_to_axis_angle_kernel,
|
|
756
|
+
dim=1,
|
|
757
|
+
inputs=(q, expected_axis, expected_angle),
|
|
758
|
+
device=device,
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
# fmt: off
|
|
762
|
+
A = wp.mat33(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)
|
|
763
|
+
expected_U = wp.mat33(
|
|
764
|
+
0.21483721, 0.88723058, -0.40824816,
|
|
765
|
+
0.52058744, 0.24964368, 0.81649637,
|
|
766
|
+
0.82633746, -0.38794267, -0.40824834,
|
|
767
|
+
)
|
|
768
|
+
expected_sigma = wp.vec3(16.84809875, 1.06836915, 0.00000019)
|
|
769
|
+
expected_V = wp.mat33(
|
|
770
|
+
0.47967088, -0.77669406, 0.40824246,
|
|
771
|
+
0.57236743, -0.07568054, -0.81649727,
|
|
772
|
+
0.66506463, 0.62531471, 0.40825251,
|
|
773
|
+
)
|
|
774
|
+
# fmt: on
|
|
775
|
+
|
|
776
|
+
U, sigma, V = wp.svd3(A)
|
|
777
|
+
|
|
778
|
+
test.assertAlmostEqual(U[0][0], expected_U[0][0], places=5)
|
|
779
|
+
test.assertAlmostEqual(U[0][1], expected_U[0][1], places=5)
|
|
780
|
+
test.assertAlmostEqual(U[0][2], expected_U[0][2], places=5)
|
|
781
|
+
test.assertAlmostEqual(U[1][0], expected_U[1][0], places=5)
|
|
782
|
+
test.assertAlmostEqual(U[1][1], expected_U[1][1], places=5)
|
|
783
|
+
test.assertAlmostEqual(U[1][2], expected_U[1][2], places=5)
|
|
784
|
+
test.assertAlmostEqual(U[2][0], expected_U[2][0], places=5)
|
|
785
|
+
test.assertAlmostEqual(U[2][1], expected_U[2][1], places=5)
|
|
786
|
+
test.assertAlmostEqual(U[2][2], expected_U[2][2], places=5)
|
|
787
|
+
|
|
788
|
+
test.assertAlmostEqual(sigma[0], expected_sigma[0], places=5)
|
|
789
|
+
test.assertAlmostEqual(sigma[1], expected_sigma[1], places=5)
|
|
790
|
+
test.assertAlmostEqual(sigma[2], expected_sigma[2], places=5)
|
|
791
|
+
|
|
792
|
+
test.assertAlmostEqual(V[0][0], expected_V[0][0], places=5)
|
|
793
|
+
test.assertAlmostEqual(V[0][1], expected_V[0][1], places=5)
|
|
794
|
+
test.assertAlmostEqual(V[0][2], expected_V[0][2], places=4) # precision issue on ARM64 (GH-905)
|
|
795
|
+
test.assertAlmostEqual(V[1][0], expected_V[1][0], places=5)
|
|
796
|
+
test.assertAlmostEqual(V[1][1], expected_V[1][1], places=4) # precision issue on ARM64 (GH-905)
|
|
797
|
+
test.assertAlmostEqual(V[1][2], expected_V[1][2], places=5)
|
|
798
|
+
test.assertAlmostEqual(V[2][0], expected_V[2][0], places=5)
|
|
799
|
+
test.assertAlmostEqual(V[2][1], expected_V[2][1], places=5)
|
|
800
|
+
test.assertAlmostEqual(V[2][2], expected_V[2][2], places=5)
|
|
801
|
+
|
|
802
|
+
wp.launch(
|
|
803
|
+
test_multiple_return_values_svd3_kernel,
|
|
804
|
+
dim=1,
|
|
805
|
+
inputs=(A, expected_U, expected_sigma, expected_V),
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
@wp.struct
|
|
810
|
+
class Pun:
|
|
811
|
+
f: wp.float16
|
|
812
|
+
i: wp.int16
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
@wp.kernel
|
|
816
|
+
def test_cast():
|
|
817
|
+
x = wp.int32(0x3FA00000)
|
|
818
|
+
x_casted = wp.cast(x, wp.float32)
|
|
819
|
+
wp.expect_eq(x_casted, 1.25)
|
|
820
|
+
|
|
821
|
+
p = Pun()
|
|
822
|
+
p.f = wp.float16(2.0)
|
|
823
|
+
p.i = wp.int16(123)
|
|
824
|
+
p_casted = wp.cast(p, wp.int32)
|
|
825
|
+
wp.expect_eq(p_casted, 0x007B4000)
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
class TestCodeGen(unittest.TestCase):
|
|
829
|
+
pass
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
devices = get_test_devices()
|
|
833
|
+
|
|
834
|
+
add_kernel_test(TestCodeGen, name="test_expect", kernel=test_expect, dim=1, devices=devices)
|
|
835
|
+
add_kernel_test(TestCodeGen, name="test_inplace", kernel=test_inplace, dim=1, devices=devices)
|
|
836
|
+
add_kernel_test(TestCodeGen, name="test_rename", kernel=test_rename, dim=1, devices=devices)
|
|
837
|
+
add_kernel_test(TestCodeGen, name="test_constant", kernel=test_constant, inputs=[1.0], dim=1, devices=devices)
|
|
838
|
+
add_kernel_test(
|
|
839
|
+
TestCodeGen, name="test_dynamic_for_rename", kernel=test_dynamic_for_rename, inputs=[10], dim=1, devices=devices
|
|
840
|
+
)
|
|
841
|
+
add_kernel_test(
|
|
842
|
+
TestCodeGen, name="test_dynamic_for_inplace", kernel=test_dynamic_for_inplace, inputs=[10], dim=1, devices=devices
|
|
843
|
+
)
|
|
844
|
+
add_kernel_test(TestCodeGen, name="test_reassign", kernel=test_reassign, dim=1, devices=devices)
|
|
845
|
+
add_kernel_test(
|
|
846
|
+
TestCodeGen, name="test_dynamic_reassign", kernel=test_dynamic_reassign, inputs=[2], dim=1, devices=devices
|
|
847
|
+
)
|
|
848
|
+
|
|
849
|
+
add_kernel_test(
|
|
850
|
+
TestCodeGen,
|
|
851
|
+
name="test_range_dynamic_forward",
|
|
852
|
+
kernel=test_range_dynamic,
|
|
853
|
+
dim=1,
|
|
854
|
+
inputs=[0, 4, 1],
|
|
855
|
+
expect=[0, 1, 2, 3],
|
|
856
|
+
devices=devices,
|
|
857
|
+
)
|
|
858
|
+
add_kernel_test(
|
|
859
|
+
TestCodeGen,
|
|
860
|
+
name="test_range_dynamic_reverse",
|
|
861
|
+
kernel=test_range_dynamic,
|
|
862
|
+
dim=1,
|
|
863
|
+
inputs=[4, 0, -1],
|
|
864
|
+
expect=[4, 3, 2, 1],
|
|
865
|
+
devices=devices,
|
|
866
|
+
)
|
|
867
|
+
add_kernel_test(
|
|
868
|
+
TestCodeGen,
|
|
869
|
+
name="test_range_dynamic_forward_step",
|
|
870
|
+
kernel=test_range_dynamic,
|
|
871
|
+
dim=1,
|
|
872
|
+
inputs=[0, 8, 2],
|
|
873
|
+
expect=[0, 2, 4, 6],
|
|
874
|
+
devices=devices,
|
|
875
|
+
)
|
|
876
|
+
add_kernel_test(
|
|
877
|
+
TestCodeGen,
|
|
878
|
+
name="test_range_dynamic_reverse_step",
|
|
879
|
+
kernel=test_range_dynamic,
|
|
880
|
+
dim=1,
|
|
881
|
+
inputs=[8, 0, -2],
|
|
882
|
+
expect=[8, 6, 4, 2],
|
|
883
|
+
devices=devices,
|
|
884
|
+
)
|
|
885
|
+
|
|
886
|
+
add_kernel_test(
|
|
887
|
+
TestCodeGen, name="test_range_static_sum", kernel=test_range_static_sum, dim=1, expect=[10, 10, 10], devices=devices
|
|
888
|
+
)
|
|
889
|
+
add_kernel_test(
|
|
890
|
+
TestCodeGen,
|
|
891
|
+
name="test_range_dynamic_sum",
|
|
892
|
+
kernel=test_range_dynamic_sum,
|
|
893
|
+
dim=1,
|
|
894
|
+
inputs=[0, 10, 2],
|
|
895
|
+
expect=[10, 10, 10, 10],
|
|
896
|
+
devices=devices,
|
|
897
|
+
)
|
|
898
|
+
add_kernel_test(
|
|
899
|
+
TestCodeGen,
|
|
900
|
+
name="test_range_dynamic_sum_zero",
|
|
901
|
+
kernel=test_range_dynamic_sum,
|
|
902
|
+
dim=1,
|
|
903
|
+
inputs=[0, 0, 1],
|
|
904
|
+
expect=[0, 0, 0, 0],
|
|
905
|
+
devices=devices,
|
|
906
|
+
)
|
|
907
|
+
add_kernel_test(TestCodeGen, name="test_range_constant", kernel=test_range_constant, dim=1, devices=devices)
|
|
908
|
+
add_kernel_test(
|
|
909
|
+
TestCodeGen,
|
|
910
|
+
name="test_range_constant_dynamic_nested",
|
|
911
|
+
kernel=test_range_constant_dynamic_nested,
|
|
912
|
+
dim=1,
|
|
913
|
+
inputs=[10],
|
|
914
|
+
devices=devices,
|
|
915
|
+
)
|
|
916
|
+
add_kernel_test(
|
|
917
|
+
TestCodeGen, name="test_range_dynamic_nested", kernel=test_range_dynamic_nested, dim=1, inputs=[4], devices=devices
|
|
918
|
+
)
|
|
919
|
+
add_kernel_test(TestCodeGen, name="test_range_expression", kernel=test_range_expression, dim=1, devices=devices)
|
|
920
|
+
|
|
921
|
+
add_kernel_test(TestCodeGen, name="test_while_zero", kernel=test_while, dim=1, inputs=[0], devices=devices)
|
|
922
|
+
add_kernel_test(TestCodeGen, name="test_while_positive", kernel=test_while, dim=1, inputs=[16], devices=devices)
|
|
923
|
+
add_kernel_test(TestCodeGen, name="test_pass", kernel=test_pass, dim=1, inputs=[16], devices=devices)
|
|
924
|
+
|
|
925
|
+
add_kernel_test(TestCodeGen, name="test_break", kernel=test_break, dim=1, inputs=[10], devices=devices)
|
|
926
|
+
add_kernel_test(TestCodeGen, name="test_break_early", kernel=test_break_early, dim=1, inputs=[10], devices=devices)
|
|
927
|
+
add_kernel_test(TestCodeGen, name="test_break_unroll", kernel=test_break_unroll, dim=1, devices=devices)
|
|
928
|
+
add_kernel_test(TestCodeGen, name="test_break_while", kernel=test_break_while, dim=1, devices=devices)
|
|
929
|
+
add_kernel_test(
|
|
930
|
+
TestCodeGen, name="test_break_multiple", kernel=test_break_multiple, dim=1, inputs=[10], devices=devices
|
|
931
|
+
)
|
|
932
|
+
add_kernel_test(TestCodeGen, name="test_continue", kernel=test_continue, dim=1, inputs=[10], devices=devices)
|
|
933
|
+
add_kernel_test(TestCodeGen, name="test_continue_unroll", kernel=test_continue_unroll, dim=1, devices=devices)
|
|
934
|
+
|
|
935
|
+
add_function_test(TestCodeGen, func=test_unresolved_func, name="test_unresolved_func", devices=devices)
|
|
936
|
+
add_function_test(TestCodeGen, func=test_unresolved_symbol, name="test_unresolved_symbol", devices=devices)
|
|
937
|
+
add_function_test(TestCodeGen, func=test_error_global_var, name="test_error_global_var", devices=devices)
|
|
938
|
+
add_function_test(
|
|
939
|
+
TestCodeGen, func=test_error_collection_construct, name="test_error_collection_construct", devices=devices
|
|
940
|
+
)
|
|
941
|
+
add_function_test(
|
|
942
|
+
TestCodeGen, func=test_error_unmatched_arguments, name="test_error_unmatched_arguments", devices=devices
|
|
943
|
+
)
|
|
944
|
+
add_function_test(
|
|
945
|
+
TestCodeGen,
|
|
946
|
+
func=test_error_mutating_constant_in_dynamic_loop,
|
|
947
|
+
name="test_error_mutating_constant_in_dynamic_loop",
|
|
948
|
+
devices=devices,
|
|
949
|
+
)
|
|
950
|
+
add_function_test(
|
|
951
|
+
TestCodeGen,
|
|
952
|
+
func=test_error_return_annotation_mismatch,
|
|
953
|
+
name="test_error_return_annotation_mismatch",
|
|
954
|
+
devices=devices,
|
|
955
|
+
)
|
|
956
|
+
add_kernel_test(TestCodeGen, name="test_call_syntax", kernel=test_call_syntax, dim=1, devices=devices)
|
|
957
|
+
add_kernel_test(TestCodeGen, name="test_shadow_builtin", kernel=test_shadow_builtin, dim=1, devices=devices)
|
|
958
|
+
add_kernel_test(TestCodeGen, name="test_while_condition_eval", kernel=test_while_condition_eval, dim=1, devices=devices)
|
|
959
|
+
add_function_test(TestCodeGen, "test_codegen_return_in_kernel", test_codegen_return_in_kernel, devices=devices)
|
|
960
|
+
add_function_test(
|
|
961
|
+
TestCodeGen, "test_ifexp_only_executes_one_branch", test_ifexp_only_executes_one_branch, devices=devices
|
|
962
|
+
)
|
|
963
|
+
add_function_test(
|
|
964
|
+
TestCodeGen,
|
|
965
|
+
func=test_multiple_return_values,
|
|
966
|
+
name="test_multiple_return_values",
|
|
967
|
+
devices=devices,
|
|
968
|
+
)
|
|
969
|
+
add_kernel_test(TestCodeGen, name="test_cast", kernel=test_cast, dim=1, devices=devices)
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
if __name__ == "__main__":
|
|
973
|
+
wp.clear_kernel_cache()
|
|
974
|
+
unittest.main(verbosity=2)
|