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
warp/tests/test_func.py
ADDED
|
@@ -0,0 +1,501 @@
|
|
|
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 math
|
|
17
|
+
import unittest
|
|
18
|
+
from typing import Any, Tuple
|
|
19
|
+
|
|
20
|
+
import numpy as np
|
|
21
|
+
|
|
22
|
+
import warp as wp
|
|
23
|
+
from warp.tests.unittest_utils import *
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@wp.func
|
|
27
|
+
def sqr(x: float):
|
|
28
|
+
return x * x
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# test nested user function calls
|
|
32
|
+
# and explicit return type hints
|
|
33
|
+
@wp.func
|
|
34
|
+
def cube(x: float) -> float:
|
|
35
|
+
return sqr(x) * x
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@wp.func
|
|
39
|
+
def custom(x: int):
|
|
40
|
+
return x + 1
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@wp.func
|
|
44
|
+
def custom(x: float):
|
|
45
|
+
return x + 1.0
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@wp.func
|
|
49
|
+
def custom(x: wp.vec3):
|
|
50
|
+
return x + wp.vec3(1.0, 0.0, 0.0)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@wp.func
|
|
54
|
+
def noreturn(x: wp.vec3):
|
|
55
|
+
x = x + wp.vec3(0.0, 1.0, 0.0)
|
|
56
|
+
|
|
57
|
+
wp.expect_eq(x, wp.vec3(1.0, 1.0, 0.0))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@wp.kernel
|
|
61
|
+
def test_overload_func():
|
|
62
|
+
# tests overloading a custom @wp.func
|
|
63
|
+
|
|
64
|
+
i = custom(1)
|
|
65
|
+
f = custom(1.0)
|
|
66
|
+
v = custom(wp.vec3(1.0, 0.0, 0.0))
|
|
67
|
+
|
|
68
|
+
wp.expect_eq(i, 2)
|
|
69
|
+
wp.expect_eq(f, 2.0)
|
|
70
|
+
wp.expect_eq(v, wp.vec3(2.0, 0.0, 0.0))
|
|
71
|
+
|
|
72
|
+
noreturn(wp.vec3(1.0, 0.0, 0.0))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@wp.func
|
|
76
|
+
def foo(x: int):
|
|
77
|
+
# This shouldn't be picked up.
|
|
78
|
+
return x * 2
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@wp.func
|
|
82
|
+
def foo(x: int):
|
|
83
|
+
return x * 3
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@wp.kernel
|
|
87
|
+
def test_override_func():
|
|
88
|
+
i = foo(1)
|
|
89
|
+
wp.expect_eq(i, 3)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_func_closure_capture(test, device):
|
|
93
|
+
def make_closure_kernel(func):
|
|
94
|
+
def closure_kernel_fn(data: wp.array(dtype=float), expected: float):
|
|
95
|
+
f = func(data[wp.tid()])
|
|
96
|
+
wp.expect_eq(f, expected)
|
|
97
|
+
|
|
98
|
+
return wp.Kernel(func=closure_kernel_fn)
|
|
99
|
+
|
|
100
|
+
sqr_closure = make_closure_kernel(sqr)
|
|
101
|
+
cube_closure = make_closure_kernel(cube)
|
|
102
|
+
|
|
103
|
+
data = wp.array([2.0], dtype=float, device=device)
|
|
104
|
+
expected_sqr = 4.0
|
|
105
|
+
expected_cube = 8.0
|
|
106
|
+
|
|
107
|
+
wp.launch(sqr_closure, dim=data.shape, inputs=[data, expected_sqr], device=device)
|
|
108
|
+
wp.launch(cube_closure, dim=data.shape, inputs=[data, expected_cube], device=device)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@wp.func
|
|
112
|
+
def test_func(param1: wp.int32, param2: wp.int32, param3: wp.int32) -> wp.float32:
|
|
113
|
+
return 1.0
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@wp.kernel
|
|
117
|
+
def test_return_kernel(test_data: wp.array(dtype=wp.float32)):
|
|
118
|
+
tid = wp.tid()
|
|
119
|
+
test_data[tid] = wp.lerp(test_func(0, 1, 2), test_func(0, 1, 2), 0.5)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_return_func(test, device):
|
|
123
|
+
test_data = wp.zeros(100, dtype=wp.float32, device=device)
|
|
124
|
+
wp.launch(kernel=test_return_kernel, dim=test_data.size, inputs=[test_data], device=device)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@wp.func
|
|
128
|
+
def multi_valued_func(a: wp.float32, b: wp.float32):
|
|
129
|
+
return a + b, a - b, a * b, a / b
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_multi_valued_func(test, device):
|
|
133
|
+
@wp.kernel
|
|
134
|
+
def test_multi_valued_kernel(test_data1: wp.array(dtype=wp.float32), test_data2: wp.array(dtype=wp.float32)):
|
|
135
|
+
tid = wp.tid()
|
|
136
|
+
d1, d2 = test_data1[tid], test_data2[tid]
|
|
137
|
+
a, b, c, d = multi_valued_func(d1, d2)
|
|
138
|
+
wp.expect_eq(a, d1 + d2)
|
|
139
|
+
wp.expect_eq(b, d1 - d2)
|
|
140
|
+
wp.expect_eq(c, d1 * d2)
|
|
141
|
+
wp.expect_eq(d, d1 / d2)
|
|
142
|
+
|
|
143
|
+
test_data1 = wp.array(np.arange(100), dtype=wp.float32, device=device)
|
|
144
|
+
test_data2 = wp.array(np.arange(100, 0, -1), dtype=wp.float32, device=device)
|
|
145
|
+
wp.launch(kernel=test_multi_valued_kernel, dim=test_data1.size, inputs=[test_data1, test_data2], device=device)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@wp.kernel
|
|
149
|
+
def test_func_defaults():
|
|
150
|
+
# test default as expected
|
|
151
|
+
wp.expect_near(1.0, 1.0 + 1.0e-6)
|
|
152
|
+
|
|
153
|
+
# test that changing tolerance still works
|
|
154
|
+
wp.expect_near(1.0, 1.1, 0.5)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@wp.func
|
|
158
|
+
def sign(x: float):
|
|
159
|
+
return 123.0
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@wp.kernel
|
|
163
|
+
def test_builtin_shadowing():
|
|
164
|
+
wp.expect_eq(sign(1.23), 123.0)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@wp.func
|
|
168
|
+
def user_func_with_defaults(a: int = 123, b: int = 234) -> int:
|
|
169
|
+
return a + b
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@wp.kernel
|
|
173
|
+
def user_func_with_defaults_kernel():
|
|
174
|
+
a = user_func_with_defaults()
|
|
175
|
+
wp.expect_eq(a, 357)
|
|
176
|
+
|
|
177
|
+
b = user_func_with_defaults(111)
|
|
178
|
+
wp.expect_eq(b, 345)
|
|
179
|
+
|
|
180
|
+
c = user_func_with_defaults(111, 222)
|
|
181
|
+
wp.expect_eq(c, 333)
|
|
182
|
+
|
|
183
|
+
d = user_func_with_defaults(a=111)
|
|
184
|
+
wp.expect_eq(d, 345)
|
|
185
|
+
|
|
186
|
+
e = user_func_with_defaults(b=111)
|
|
187
|
+
wp.expect_eq(e, 234)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def test_user_func_with_defaults(test, device):
|
|
191
|
+
wp.launch(user_func_with_defaults_kernel, dim=1, device=device)
|
|
192
|
+
|
|
193
|
+
a = user_func_with_defaults()
|
|
194
|
+
assert a == 357
|
|
195
|
+
|
|
196
|
+
b = user_func_with_defaults(111)
|
|
197
|
+
assert b == 345
|
|
198
|
+
|
|
199
|
+
c = user_func_with_defaults(111, 222)
|
|
200
|
+
assert c == 333
|
|
201
|
+
|
|
202
|
+
d = user_func_with_defaults(a=111)
|
|
203
|
+
assert d == 345
|
|
204
|
+
|
|
205
|
+
e = user_func_with_defaults(b=111)
|
|
206
|
+
assert e == 234
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@wp.func
|
|
210
|
+
def user_func_return_multiple_values(a: int, b: float) -> Tuple[int, float]:
|
|
211
|
+
return a + a, b * b
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@wp.kernel
|
|
215
|
+
def test_user_func_return_multiple_values():
|
|
216
|
+
a, b = user_func_return_multiple_values(123, 234.0)
|
|
217
|
+
wp.expect_eq(a, 246)
|
|
218
|
+
wp.expect_eq(b, 54756.0)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
@wp.func
|
|
222
|
+
def user_func_overload(
|
|
223
|
+
b: wp.array(dtype=Any),
|
|
224
|
+
i: int,
|
|
225
|
+
):
|
|
226
|
+
return b[i] * 2.0
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@wp.kernel
|
|
230
|
+
def user_func_overload_resolution_kernel(
|
|
231
|
+
a: wp.array(dtype=Any),
|
|
232
|
+
b: wp.array(dtype=Any),
|
|
233
|
+
):
|
|
234
|
+
i = wp.tid()
|
|
235
|
+
a[i] = user_func_overload(b, i)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def test_user_func_overload_resolution(test, device):
|
|
239
|
+
a0 = wp.array((1, 2, 3), dtype=wp.vec3)
|
|
240
|
+
b0 = wp.array((2, 3, 4), dtype=wp.vec3)
|
|
241
|
+
|
|
242
|
+
a1 = wp.array((5,), dtype=float)
|
|
243
|
+
b1 = wp.array((6,), dtype=float)
|
|
244
|
+
|
|
245
|
+
wp.launch(user_func_overload_resolution_kernel, a0.shape, (a0, b0))
|
|
246
|
+
wp.launch(user_func_overload_resolution_kernel, a1.shape, (a1, b1))
|
|
247
|
+
|
|
248
|
+
assert_np_equal(a0.numpy()[0], (4, 6, 8))
|
|
249
|
+
assert a1.numpy()[0] == 12
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@wp.func
|
|
253
|
+
def user_func_return_none() -> None:
|
|
254
|
+
pass
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
@wp.kernel
|
|
258
|
+
def test_return_annotation_none() -> None:
|
|
259
|
+
user_func_return_none()
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
@wp.func
|
|
263
|
+
def divide_by_zero(x: float):
|
|
264
|
+
return x / 0.0
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
@wp.func
|
|
268
|
+
def normalize_vector(vec_a: wp.vec3):
|
|
269
|
+
return wp.normalize(vec_a)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
@wp.func
|
|
273
|
+
def divide_float64(x: wp.float64):
|
|
274
|
+
return x / wp.float64(1.23)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@wp.func
|
|
278
|
+
def get_array_len(arr: wp.array(dtype=wp.float32)):
|
|
279
|
+
return len(arr)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class TestFunc(unittest.TestCase):
|
|
283
|
+
def test_user_func_export(self):
|
|
284
|
+
# tests calling overloaded user-defined functions from Python
|
|
285
|
+
i = custom(1)
|
|
286
|
+
f = custom(1.0)
|
|
287
|
+
v = custom(wp.vec3(1.0, 0.0, 0.0))
|
|
288
|
+
|
|
289
|
+
self.assertEqual(i, 2)
|
|
290
|
+
self.assertEqual(f, 2.0)
|
|
291
|
+
assert_np_equal(np.array([*v]), np.array([2.0, 0.0, 0.0]))
|
|
292
|
+
|
|
293
|
+
def test_native_func_export(self):
|
|
294
|
+
# tests calling native functions from Python
|
|
295
|
+
|
|
296
|
+
q = wp.quat(0.0, 0.0, 0.0, 1.0)
|
|
297
|
+
assert_np_equal(np.array([*q]), np.array([0.0, 0.0, 0.0, 1.0]))
|
|
298
|
+
|
|
299
|
+
r = wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 2.0)
|
|
300
|
+
assert_np_equal(np.array([*r]), np.array([0.8414709568023682, 0.0, 0.0, 0.5403022170066833]), tol=1.0e-3)
|
|
301
|
+
|
|
302
|
+
q = wp.quat(1.0, 2.0, 3.0, 4.0)
|
|
303
|
+
q = wp.normalize(q) * 2.0
|
|
304
|
+
assert_np_equal(
|
|
305
|
+
np.array([*q]),
|
|
306
|
+
np.array([0.18257418274879456, 0.3651483654975891, 0.547722578048706, 0.7302967309951782]) * 2.0,
|
|
307
|
+
tol=1.0e-3,
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
v2 = wp.vec2(1.0, 2.0)
|
|
311
|
+
v2 = wp.normalize(v2) * 2.0
|
|
312
|
+
assert_np_equal(np.array([*v2]), np.array([0.4472135901451111, 0.8944271802902222]) * 2.0, tol=1.0e-3)
|
|
313
|
+
|
|
314
|
+
v3 = wp.vec3(1.0, 2.0, 3.0)
|
|
315
|
+
v3 = wp.normalize(v3) * 2.0
|
|
316
|
+
assert_np_equal(
|
|
317
|
+
np.array([*v3]), np.array([0.26726123690605164, 0.5345224738121033, 0.8017836809158325]) * 2.0, tol=1.0e-3
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
v4 = wp.vec4(1.0, 2.0, 3.0, 4.0)
|
|
321
|
+
v4 = wp.normalize(v4) * 2.0
|
|
322
|
+
assert_np_equal(
|
|
323
|
+
np.array([*v4]),
|
|
324
|
+
np.array([0.18257418274879456, 0.3651483654975891, 0.547722578048706, 0.7302967309951782]) * 2.0,
|
|
325
|
+
tol=1.0e-3,
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
v = wp.vec2(0.0)
|
|
329
|
+
v += wp.vec2(1.0, 1.0)
|
|
330
|
+
assert v == wp.vec2(1.0, 1.0)
|
|
331
|
+
v -= wp.vec2(1.0, 1.0)
|
|
332
|
+
assert v == wp.vec2(0.0, 0.0)
|
|
333
|
+
v = wp.vec2(2.0, 2.0) - wp.vec2(1.0, 1.0)
|
|
334
|
+
assert v == wp.vec2(1.0, 1.0)
|
|
335
|
+
v *= 2.0
|
|
336
|
+
assert v == wp.vec2(2.0, 2.0)
|
|
337
|
+
v = v * 2.0
|
|
338
|
+
assert v == wp.vec2(4.0, 4.0)
|
|
339
|
+
v = v / 2.0
|
|
340
|
+
assert v == wp.vec2(2.0, 2.0)
|
|
341
|
+
v /= 2.0
|
|
342
|
+
assert v == wp.vec2(1.0, 1.0)
|
|
343
|
+
v = -v
|
|
344
|
+
assert v == wp.vec2(-1.0, -1.0)
|
|
345
|
+
v = +v
|
|
346
|
+
assert v == wp.vec2(-1.0, -1.0)
|
|
347
|
+
|
|
348
|
+
m22 = wp.mat22(1.0, 2.0, 3.0, 4.0)
|
|
349
|
+
m22 = m22 + m22
|
|
350
|
+
|
|
351
|
+
self.assertEqual(m22[1, 1], 8.0)
|
|
352
|
+
self.assertEqual(str(m22), "[[2.0, 4.0],\n [6.0, 8.0]]")
|
|
353
|
+
|
|
354
|
+
t = wp.transform(
|
|
355
|
+
wp.vec3(1.0, 2.0, 3.0),
|
|
356
|
+
wp.quat(4.0, 5.0, 6.0, 7.0),
|
|
357
|
+
)
|
|
358
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
359
|
+
self.assertSequenceEqual(
|
|
360
|
+
t * wp.transform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), (396.0, 432.0, 720.0, 56.0, 70.0, 84.0, -28.0)
|
|
361
|
+
)
|
|
362
|
+
self.assertSequenceEqual(
|
|
363
|
+
t * wp.transform((1.0, 2.0, 3.0), (4.0, 5.0, 6.0, 7.0)), (396.0, 432.0, 720.0, 56.0, 70.0, 84.0, -28.0)
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
t = wp.transform()
|
|
367
|
+
self.assertSequenceEqual(t, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0))
|
|
368
|
+
|
|
369
|
+
t = wp.transform(p=(1.0, 2.0, 3.0), q=(4.0, 5.0, 6.0, 7.0))
|
|
370
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
371
|
+
|
|
372
|
+
t = wp.transform(q=(4.0, 5.0, 6.0, 7.0), p=(1.0, 2.0, 3.0))
|
|
373
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
374
|
+
|
|
375
|
+
t = wp.transform((1.0, 2.0, 3.0), q=(4.0, 5.0, 6.0, 7.0))
|
|
376
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
377
|
+
|
|
378
|
+
t = wp.transform(p=(1.0, 2.0, 3.0))
|
|
379
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 1.0))
|
|
380
|
+
|
|
381
|
+
t = wp.transform(q=(4.0, 5.0, 6.0, 7.0))
|
|
382
|
+
self.assertSequenceEqual(t, (0.0, 0.0, 0.0, 4.0, 5.0, 6.0, 7.0))
|
|
383
|
+
|
|
384
|
+
t = wp.transform((1.0, 2.0, 3.0), (4.0, 5.0, 6.0, 7.0))
|
|
385
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
386
|
+
|
|
387
|
+
t = wp.transform(p=wp.vec3(1.0, 2.0, 3.0), q=wp.quat(4.0, 5.0, 6.0, 7.0))
|
|
388
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
389
|
+
|
|
390
|
+
t = wp.transform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)
|
|
391
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
392
|
+
|
|
393
|
+
t = wp.transform(wp.transform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
394
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
395
|
+
|
|
396
|
+
t = wp.transform(*wp.transform(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
397
|
+
self.assertSequenceEqual(t, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0))
|
|
398
|
+
|
|
399
|
+
transformf = wp._src.types.transformation(dtype=float)
|
|
400
|
+
|
|
401
|
+
t = wp.transformf((1.0, 2.0, 3.0), (4.0, 5.0, 6.0, 7.0))
|
|
402
|
+
self.assertSequenceEqual(
|
|
403
|
+
t + transformf((2.0, 3.0, 4.0), (5.0, 6.0, 7.0, 8.0)),
|
|
404
|
+
(3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0),
|
|
405
|
+
)
|
|
406
|
+
self.assertSequenceEqual(
|
|
407
|
+
t - transformf((2.0, 3.0, 4.0), (5.0, 6.0, 7.0, 8.0)),
|
|
408
|
+
(-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0),
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
with self.assertRaisesRegex(
|
|
412
|
+
TypeError,
|
|
413
|
+
r"^got an unexpected keyword argument 'pos'$",
|
|
414
|
+
):
|
|
415
|
+
wp.transform(pos=wp.vec3(), rot=wp.quat())
|
|
416
|
+
|
|
417
|
+
f = wp.sin(math.pi * 0.5)
|
|
418
|
+
self.assertAlmostEqual(f, 1.0, places=3)
|
|
419
|
+
|
|
420
|
+
m = wp.mat22(0.0, 0.0, 0.0, 0.0)
|
|
421
|
+
m += wp.mat22(1.0, 1.0, 1.0, 1.0)
|
|
422
|
+
assert m == wp.mat22(1.0, 1.0, 1.0, 1.0)
|
|
423
|
+
m -= wp.mat22(1.0, 1.0, 1.0, 1.0)
|
|
424
|
+
assert m == wp.mat22(0.0, 0.0, 0.0, 0.0)
|
|
425
|
+
m = wp.mat22(2.0, 2.0, 2.0, 2.0) - wp.mat22(1.0, 1.0, 1.0, 1.0)
|
|
426
|
+
assert m == wp.mat22(1.0, 1.0, 1.0, 1.0)
|
|
427
|
+
m *= 2.0
|
|
428
|
+
assert m == wp.mat22(2.0, 2.0, 2.0, 2.0)
|
|
429
|
+
m = m * 2.0
|
|
430
|
+
assert m == wp.mat22(4.0, 4.0, 4.0, 4.0)
|
|
431
|
+
m = m / 2.0
|
|
432
|
+
assert m == wp.mat22(2.0, 2.0, 2.0, 2.0)
|
|
433
|
+
m /= 2.0
|
|
434
|
+
assert m == wp.mat22(1.0, 1.0, 1.0, 1.0)
|
|
435
|
+
m = -m
|
|
436
|
+
assert m == wp.mat22(-1.0, -1.0, -1.0, -1.0)
|
|
437
|
+
m = +m
|
|
438
|
+
assert m == wp.mat22(-1.0, -1.0, -1.0, -1.0)
|
|
439
|
+
m = m * m
|
|
440
|
+
assert m == wp.mat22(2.0, 2.0, 2.0, 2.0)
|
|
441
|
+
|
|
442
|
+
def test_native_function_error_resolution(self):
|
|
443
|
+
a = wp.mat22f(1.0, 2.0, 3.0, 4.0)
|
|
444
|
+
b = wp.mat22d(1.0, 2.0, 3.0, 4.0)
|
|
445
|
+
with self.assertRaisesRegex(
|
|
446
|
+
RuntimeError,
|
|
447
|
+
r"^Couldn't find a function 'mul' compatible with the arguments 'mat22f, mat22d'$",
|
|
448
|
+
):
|
|
449
|
+
a * b
|
|
450
|
+
|
|
451
|
+
def test_cpython_call_user_function_with_error(self):
|
|
452
|
+
with self.assertRaises(ZeroDivisionError):
|
|
453
|
+
divide_by_zero(1.0)
|
|
454
|
+
|
|
455
|
+
def test_cpython_call_user_function_with_wrong_argument_types(self):
|
|
456
|
+
with self.assertRaisesRegex(
|
|
457
|
+
RuntimeError,
|
|
458
|
+
r"^Error calling function 'divide_float64', no overload found for arguments \(1.0,\)$",
|
|
459
|
+
):
|
|
460
|
+
divide_float64(1.0)
|
|
461
|
+
|
|
462
|
+
with self.assertRaisesRegex(
|
|
463
|
+
RuntimeError,
|
|
464
|
+
r"^Error calling function 'normalize_vector', no overload found for arguments \(1.0,\)$",
|
|
465
|
+
):
|
|
466
|
+
normalize_vector(1.0)
|
|
467
|
+
|
|
468
|
+
def test_cpython_call_user_function_with_array_type(self):
|
|
469
|
+
arr = wp.array((1, 2, 3, 4, 5, 6, 7, 8), dtype=wp.float32)
|
|
470
|
+
length = get_array_len(arr)
|
|
471
|
+
assert length == 8
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
devices = get_test_devices()
|
|
475
|
+
|
|
476
|
+
add_kernel_test(TestFunc, kernel=test_overload_func, name="test_overload_func", dim=1, devices=devices)
|
|
477
|
+
add_function_test(TestFunc, func=test_return_func, name="test_return_func", devices=devices)
|
|
478
|
+
add_kernel_test(TestFunc, kernel=test_override_func, name="test_override_func", dim=1, devices=devices)
|
|
479
|
+
add_function_test(TestFunc, func=test_func_closure_capture, name="test_func_closure_capture", devices=devices)
|
|
480
|
+
add_function_test(TestFunc, func=test_multi_valued_func, name="test_multi_valued_func", devices=devices)
|
|
481
|
+
add_kernel_test(TestFunc, kernel=test_func_defaults, name="test_func_defaults", dim=1, devices=devices)
|
|
482
|
+
add_kernel_test(TestFunc, kernel=test_builtin_shadowing, name="test_builtin_shadowing", dim=1, devices=devices)
|
|
483
|
+
add_function_test(TestFunc, func=test_user_func_with_defaults, name="test_user_func_with_defaults", devices=devices)
|
|
484
|
+
add_kernel_test(
|
|
485
|
+
TestFunc,
|
|
486
|
+
kernel=test_user_func_return_multiple_values,
|
|
487
|
+
name="test_user_func_return_multiple_values",
|
|
488
|
+
dim=1,
|
|
489
|
+
devices=devices,
|
|
490
|
+
)
|
|
491
|
+
add_function_test(
|
|
492
|
+
TestFunc, func=test_user_func_overload_resolution, name="test_user_func_overload_resolution", devices=devices
|
|
493
|
+
)
|
|
494
|
+
add_kernel_test(
|
|
495
|
+
TestFunc, kernel=test_return_annotation_none, name="test_return_annotation_none", dim=1, devices=devices
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
if __name__ == "__main__":
|
|
500
|
+
wp.clear_kernel_cache()
|
|
501
|
+
unittest.main(verbosity=2)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024 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
|
+
# This is what we are actually testing.
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import unittest
|
|
20
|
+
|
|
21
|
+
import warp as wp
|
|
22
|
+
from warp.tests.unittest_utils import *
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@wp.struct
|
|
26
|
+
class FooData:
|
|
27
|
+
x: float
|
|
28
|
+
y: float
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Foo:
|
|
32
|
+
Data = FooData
|
|
33
|
+
|
|
34
|
+
@wp.func
|
|
35
|
+
def compute():
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@wp.kernel
|
|
40
|
+
def kernel_1(
|
|
41
|
+
out: wp.array(dtype=float),
|
|
42
|
+
):
|
|
43
|
+
tid = wp.tid()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@wp.kernel
|
|
47
|
+
def kernel_2(
|
|
48
|
+
out: wp.array(dtype=float),
|
|
49
|
+
):
|
|
50
|
+
tid = wp.tid()
|
|
51
|
+
out[tid] = 1.23
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def create_kernel_3(foo: Foo):
|
|
55
|
+
def fn(
|
|
56
|
+
data: foo.Data,
|
|
57
|
+
out: wp.array(dtype=float),
|
|
58
|
+
):
|
|
59
|
+
tid = wp.tid()
|
|
60
|
+
|
|
61
|
+
# Referencing a variable in a type hint like `foo.Data` isn't officially
|
|
62
|
+
# accepted by Python but it's still being used in some places (e.g.: `warp.fem`)
|
|
63
|
+
# where it works only because the variable being referenced within the function,
|
|
64
|
+
# which causes it to be promoted to a closure variable. Without that,
|
|
65
|
+
# it wouldn't be possible to resolve `foo` and to evaluate the `foo.Data`
|
|
66
|
+
# string to its corresponding type.
|
|
67
|
+
foo.compute()
|
|
68
|
+
|
|
69
|
+
out[tid] = data.x + data.y
|
|
70
|
+
|
|
71
|
+
return wp.Kernel(func=fn)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_future_annotations(test, device):
|
|
75
|
+
foo = Foo()
|
|
76
|
+
foo_data = FooData()
|
|
77
|
+
foo_data.x = 1.23
|
|
78
|
+
foo_data.y = 2.34
|
|
79
|
+
|
|
80
|
+
out = wp.empty(1, dtype=float, device=device)
|
|
81
|
+
|
|
82
|
+
kernel_3 = create_kernel_3(foo)
|
|
83
|
+
|
|
84
|
+
wp.launch(kernel_1, dim=out.shape, outputs=(out,), device=device)
|
|
85
|
+
wp.launch(kernel_2, dim=out.shape, outputs=(out,), device=device)
|
|
86
|
+
wp.launch(kernel_3, dim=out.shape, inputs=(foo_data,), outputs=(out,), device=device)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class TestFutureAnnotations(unittest.TestCase):
|
|
90
|
+
pass
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
devices = get_test_devices()
|
|
94
|
+
|
|
95
|
+
add_function_test(TestFutureAnnotations, "test_future_annotations", test_future_annotations, devices=devices)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
wp.clear_kernel_cache()
|
|
100
|
+
unittest.main(verbosity=2)
|