warp-lang 0.10.1__py3-none-win_amd64.whl → 0.11.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/__init__.py +10 -4
- warp/__init__.pyi +1 -0
- warp/bin/warp-clang.dll +0 -0
- warp/bin/warp.dll +0 -0
- warp/build.py +5 -3
- warp/build_dll.py +29 -9
- warp/builtins.py +868 -507
- warp/codegen.py +1074 -638
- warp/config.py +3 -3
- warp/constants.py +6 -0
- warp/context.py +715 -222
- warp/fabric.py +326 -0
- warp/fem/__init__.py +27 -0
- warp/fem/cache.py +389 -0
- warp/fem/dirichlet.py +181 -0
- warp/fem/domain.py +263 -0
- warp/fem/field/__init__.py +101 -0
- warp/fem/field/field.py +149 -0
- warp/fem/field/nodal_field.py +299 -0
- warp/fem/field/restriction.py +21 -0
- warp/fem/field/test.py +181 -0
- warp/fem/field/trial.py +183 -0
- warp/fem/geometry/__init__.py +19 -0
- warp/fem/geometry/closest_point.py +70 -0
- warp/fem/geometry/deformed_geometry.py +271 -0
- warp/fem/geometry/element.py +744 -0
- warp/fem/geometry/geometry.py +186 -0
- warp/fem/geometry/grid_2d.py +373 -0
- warp/fem/geometry/grid_3d.py +435 -0
- warp/fem/geometry/hexmesh.py +953 -0
- warp/fem/geometry/partition.py +376 -0
- warp/fem/geometry/quadmesh_2d.py +532 -0
- warp/fem/geometry/tetmesh.py +840 -0
- warp/fem/geometry/trimesh_2d.py +577 -0
- warp/fem/integrate.py +1616 -0
- warp/fem/operator.py +191 -0
- warp/fem/polynomial.py +213 -0
- warp/fem/quadrature/__init__.py +2 -0
- warp/fem/quadrature/pic_quadrature.py +245 -0
- warp/fem/quadrature/quadrature.py +294 -0
- warp/fem/space/__init__.py +292 -0
- warp/fem/space/basis_space.py +489 -0
- warp/fem/space/collocated_function_space.py +105 -0
- warp/fem/space/dof_mapper.py +236 -0
- warp/fem/space/function_space.py +145 -0
- warp/fem/space/grid_2d_function_space.py +267 -0
- warp/fem/space/grid_3d_function_space.py +306 -0
- warp/fem/space/hexmesh_function_space.py +352 -0
- warp/fem/space/partition.py +350 -0
- warp/fem/space/quadmesh_2d_function_space.py +369 -0
- warp/fem/space/restriction.py +160 -0
- warp/fem/space/shape/__init__.py +15 -0
- warp/fem/space/shape/cube_shape_function.py +738 -0
- warp/fem/space/shape/shape_function.py +103 -0
- warp/fem/space/shape/square_shape_function.py +611 -0
- warp/fem/space/shape/tet_shape_function.py +567 -0
- warp/fem/space/shape/triangle_shape_function.py +429 -0
- warp/fem/space/tetmesh_function_space.py +292 -0
- warp/fem/space/topology.py +295 -0
- warp/fem/space/trimesh_2d_function_space.py +221 -0
- warp/fem/types.py +77 -0
- warp/fem/utils.py +495 -0
- warp/native/array.h +147 -44
- warp/native/builtin.h +122 -149
- warp/native/bvh.cpp +73 -325
- warp/native/bvh.cu +406 -23
- warp/native/bvh.h +34 -43
- warp/native/clang/clang.cpp +13 -8
- warp/native/crt.h +2 -0
- warp/native/cuda_crt.h +5 -0
- warp/native/cuda_util.cpp +15 -3
- warp/native/cuda_util.h +3 -1
- warp/native/cutlass/tools/library/scripts/conv2d_operation.py +463 -0
- warp/native/cutlass/tools/library/scripts/conv3d_operation.py +321 -0
- warp/native/cutlass/tools/library/scripts/gemm_operation.py +988 -0
- warp/native/cutlass/tools/library/scripts/generator.py +4625 -0
- warp/native/cutlass/tools/library/scripts/library.py +799 -0
- warp/native/cutlass/tools/library/scripts/manifest.py +402 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/docs/source/conf.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/profile/conv/conv2d_f16_sm80.py +106 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/profile/gemm/gemm_f32_sm80.py +91 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/setup.py +80 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/__init__.py +48 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/arguments.py +118 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/c_types.py +241 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/compiler.py +432 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/conv2d_operation.py +631 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/epilogue.py +1026 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/frontend.py +104 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/gemm_operation.py +1276 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/library.py +744 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/memory_manager.py +74 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/operation.py +110 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/parser.py +619 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/reduction_operation.py +398 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/tensor_ref.py +70 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/__init__.py +4 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/conv2d_testbed.py +646 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_grouped_testbed.py +235 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/gemm_testbed.py +557 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/test/profiler.py +70 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/type_hint.py +39 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/__init__.py +1 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/device.py +76 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/src/pycutlass/utils/reference_model.py +255 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/__init__.py +0 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +201 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +177 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +98 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_dgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +95 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_few_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +163 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_fixed_channels_f16nhwc_f16nhwc_f16nhwc_tensor_op_f32_sm80.py +187 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +309 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +54 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_fprop_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_strided_dgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +253 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f16nhwc_tensor_op_f16_sm80.py +97 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f16nhwc_f16nhwc_f32nhwc_tensor_op_f32_sm80.py +242 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_f32nhwc_f32nhwc_f32nhwc_simt_f32_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/conv2d_wgrad_implicit_gemm_tf32nhwc_tf32nhwc_f32nhwc_tensor_op_f32_sm80.py +107 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/conv/run_all_tests.py +10 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/frontend/test_frontend.py +146 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/__init__.py +0 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_bf16_sm80.py +96 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f16_sm80.py +447 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f32_sm80.py +146 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_f64_sm80.py +102 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_grouped_sm80.py +203 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/gemm_s8_sm80.py +229 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/gemm/run_all_tests.py +9 -0
- warp/native/cutlass/tools/library/scripts/pycutlass/test/unit/test_sm80.py +453 -0
- warp/native/cutlass/tools/library/scripts/rank_2k_operation.py +398 -0
- warp/native/cutlass/tools/library/scripts/rank_k_operation.py +387 -0
- warp/native/cutlass/tools/library/scripts/rt.py +796 -0
- warp/native/cutlass/tools/library/scripts/symm_operation.py +400 -0
- warp/native/cutlass/tools/library/scripts/trmm_operation.py +407 -0
- warp/native/cutlass_gemm.cu +5 -3
- warp/native/exports.h +1240 -952
- warp/native/fabric.h +228 -0
- warp/native/hashgrid.cpp +4 -4
- warp/native/hashgrid.h +22 -2
- warp/native/intersect.h +22 -7
- warp/native/intersect_adj.h +8 -8
- warp/native/intersect_tri.h +1 -1
- warp/native/marching.cu +157 -161
- warp/native/mat.h +80 -19
- warp/native/matnn.h +2 -2
- warp/native/mesh.cpp +33 -108
- warp/native/mesh.cu +114 -23
- warp/native/mesh.h +446 -46
- warp/native/noise.h +272 -329
- warp/native/quat.h +51 -8
- warp/native/rand.h +45 -35
- warp/native/range.h +6 -2
- warp/native/reduce.cpp +1 -1
- warp/native/reduce.cu +10 -12
- warp/native/runlength_encode.cu +6 -10
- warp/native/scan.cu +8 -11
- warp/native/sparse.cpp +4 -4
- warp/native/sparse.cu +164 -154
- warp/native/spatial.h +2 -2
- warp/native/temp_buffer.h +14 -30
- warp/native/vec.h +107 -23
- warp/native/volume.h +120 -0
- warp/native/warp.cpp +560 -30
- warp/native/warp.cu +431 -44
- warp/native/warp.h +13 -4
- warp/optim/__init__.py +1 -0
- warp/optim/linear.py +922 -0
- warp/optim/sgd.py +92 -0
- warp/render/render_opengl.py +335 -119
- warp/render/render_usd.py +11 -11
- warp/sim/__init__.py +2 -2
- warp/sim/articulation.py +385 -185
- warp/sim/collide.py +8 -0
- warp/sim/import_mjcf.py +297 -106
- warp/sim/import_urdf.py +389 -210
- warp/sim/import_usd.py +198 -97
- warp/sim/inertia.py +17 -18
- warp/sim/integrator_euler.py +14 -8
- warp/sim/integrator_xpbd.py +158 -16
- warp/sim/model.py +795 -291
- warp/sim/render.py +3 -3
- warp/sim/utils.py +3 -0
- warp/sparse.py +640 -150
- warp/stubs.py +606 -267
- warp/tape.py +61 -10
- warp/tests/__main__.py +3 -6
- warp/tests/assets/curlnoise_golden.npy +0 -0
- warp/tests/assets/pnoise_golden.npy +0 -0
- warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
- warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
- warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
- warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
- warp/tests/aux_test_unresolved_func.py +14 -0
- warp/tests/aux_test_unresolved_symbol.py +14 -0
- warp/tests/disabled_kinematics.py +239 -0
- warp/tests/run_coverage_serial.py +31 -0
- warp/tests/test_adam.py +103 -106
- warp/tests/test_arithmetic.py +128 -74
- warp/tests/test_array.py +212 -97
- warp/tests/test_array_reduce.py +57 -23
- warp/tests/test_atomic.py +64 -28
- warp/tests/test_bool.py +99 -0
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +42 -18
- warp/tests/test_closest_point_edge_edge.py +54 -57
- warp/tests/test_codegen.py +208 -130
- warp/tests/test_compile_consts.py +28 -20
- warp/tests/test_conditional.py +108 -24
- warp/tests/test_copy.py +10 -12
- warp/tests/test_ctypes.py +112 -88
- warp/tests/test_dense.py +21 -14
- warp/tests/test_devices.py +98 -0
- warp/tests/test_dlpack.py +75 -75
- warp/tests/test_examples.py +277 -0
- warp/tests/test_fabricarray.py +955 -0
- warp/tests/test_fast_math.py +15 -11
- warp/tests/test_fem.py +1271 -0
- warp/tests/test_fp16.py +53 -19
- warp/tests/test_func.py +187 -86
- warp/tests/test_generics.py +194 -49
- warp/tests/test_grad.py +178 -109
- warp/tests/test_grad_customs.py +176 -0
- warp/tests/test_hash_grid.py +52 -37
- warp/tests/test_import.py +10 -23
- warp/tests/test_indexedarray.py +32 -31
- warp/tests/test_intersect.py +18 -9
- warp/tests/test_large.py +141 -0
- warp/tests/test_launch.py +14 -41
- warp/tests/test_lerp.py +64 -65
- warp/tests/test_linear_solvers.py +154 -0
- warp/tests/test_lvalue.py +493 -0
- warp/tests/test_marching_cubes.py +12 -13
- warp/tests/test_mat.py +517 -2898
- warp/tests/test_mat_lite.py +115 -0
- warp/tests/test_mat_scalar_ops.py +2889 -0
- warp/tests/test_math.py +103 -9
- warp/tests/test_matmul.py +305 -69
- warp/tests/test_matmul_lite.py +410 -0
- warp/tests/test_mesh.py +71 -14
- warp/tests/test_mesh_query_aabb.py +41 -25
- warp/tests/test_mesh_query_point.py +140 -22
- warp/tests/test_mesh_query_ray.py +39 -22
- warp/tests/test_mlp.py +30 -22
- warp/tests/test_model.py +92 -89
- warp/tests/test_modules_lite.py +39 -0
- warp/tests/test_multigpu.py +88 -114
- warp/tests/test_noise.py +12 -11
- warp/tests/test_operators.py +16 -20
- warp/tests/test_options.py +11 -11
- warp/tests/test_pinned.py +17 -18
- warp/tests/test_print.py +32 -11
- warp/tests/test_quat.py +275 -129
- warp/tests/test_rand.py +18 -16
- warp/tests/test_reload.py +38 -34
- warp/tests/test_rounding.py +50 -43
- warp/tests/test_runlength_encode.py +168 -20
- warp/tests/test_smoothstep.py +9 -11
- warp/tests/test_snippet.py +143 -0
- warp/tests/test_sparse.py +261 -63
- warp/tests/test_spatial.py +276 -243
- warp/tests/test_streams.py +110 -85
- warp/tests/test_struct.py +268 -63
- warp/tests/test_tape.py +39 -21
- warp/tests/test_torch.py +118 -89
- warp/tests/test_transient_module.py +12 -13
- warp/tests/test_types.py +614 -0
- warp/tests/test_utils.py +494 -0
- warp/tests/test_vec.py +354 -2050
- warp/tests/test_vec_lite.py +73 -0
- warp/tests/test_vec_scalar_ops.py +2099 -0
- warp/tests/test_volume.py +457 -293
- warp/tests/test_volume_write.py +124 -134
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +341 -0
- warp/tests/unittest_utils.py +568 -0
- warp/tests/unused_test_misc.py +71 -0
- warp/tests/{test_debug.py → walkthough_debug.py} +3 -17
- warp/thirdparty/appdirs.py +36 -45
- warp/thirdparty/unittest_parallel.py +549 -0
- warp/torch.py +9 -6
- warp/types.py +1089 -366
- warp/utils.py +93 -387
- warp_lang-0.11.0.dist-info/METADATA +238 -0
- warp_lang-0.11.0.dist-info/RECORD +332 -0
- {warp_lang-0.10.1.dist-info → warp_lang-0.11.0.dist-info}/WHEEL +1 -1
- warp/tests/test_all.py +0 -219
- warp/tests/test_array_scan.py +0 -60
- warp/tests/test_base.py +0 -208
- warp/tests/test_unresolved_func.py +0 -7
- warp/tests/test_unresolved_symbol.py +0 -7
- warp_lang-0.10.1.dist-info/METADATA +0 -21
- warp_lang-0.10.1.dist-info/RECORD +0 -188
- /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
- /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
- /warp/tests/{test_square.py → aux_test_square.py} +0 -0
- {warp_lang-0.10.1.dist-info → warp_lang-0.11.0.dist-info}/LICENSE.md +0 -0
- {warp_lang-0.10.1.dist-info → warp_lang-0.11.0.dist-info}/top_level.txt +0 -0
warp/utils.py
CHANGED
|
@@ -5,168 +5,42 @@
|
|
|
5
5
|
# distribution of this software and related documentation without an express
|
|
6
6
|
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
7
|
|
|
8
|
-
import os
|
|
9
|
-
import math
|
|
10
|
-
import timeit
|
|
11
8
|
import cProfile
|
|
9
|
+
import sys
|
|
10
|
+
import timeit
|
|
11
|
+
import warnings
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
12
14
|
import numpy as np
|
|
13
|
-
from typing import Union, Tuple, Any
|
|
14
15
|
|
|
15
16
|
import warp as wp
|
|
16
17
|
import warp.types
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
return np.linalg.norm(a)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def length_sq(a):
|
|
24
|
-
return np.dot(a, a)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def cross(a, b):
|
|
28
|
-
return np.array((a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]), dtype=np.float32)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# NumPy has no normalize() method..
|
|
32
|
-
def normalize(v):
|
|
33
|
-
norm = np.linalg.norm(v)
|
|
34
|
-
if norm == 0.0:
|
|
35
|
-
return v
|
|
36
|
-
return v / norm
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def skew(v):
|
|
40
|
-
return np.array([[0, -v[2], v[1]], [v[2], 0, -v[0]], [-v[1], v[0], 0]])
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# math utils
|
|
44
|
-
# def quat(i, j, k, w):
|
|
45
|
-
# return np.array([i, j, k, w])
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def quat_identity():
|
|
49
|
-
return np.array((0.0, 0.0, 0.0, 1.0))
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def quat_inverse(q):
|
|
53
|
-
return np.array((-q[0], -q[1], -q[2], q[3]))
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def quat_from_axis_angle(axis, angle):
|
|
57
|
-
v = normalize(np.array(axis))
|
|
58
|
-
|
|
59
|
-
half = angle * 0.5
|
|
60
|
-
w = math.cos(half)
|
|
61
|
-
|
|
62
|
-
sin_theta_over_two = math.sin(half)
|
|
63
|
-
v *= sin_theta_over_two
|
|
20
|
+
warnings_seen = set()
|
|
64
21
|
|
|
65
|
-
return np.array((v[0], v[1], v[2], w))
|
|
66
22
|
|
|
23
|
+
def warp_showwarning(message, category, filename, lineno, file=None, line=None):
|
|
24
|
+
"""Version of warnings.showwarning that always prints to sys.stdout."""
|
|
25
|
+
sys.stdout.write(warnings.formatwarning(message, category, filename, lineno, line=line))
|
|
67
26
|
|
|
68
|
-
def quat_to_axis_angle(quat):
|
|
69
|
-
w2 = quat[3] * quat[3]
|
|
70
|
-
if w2 > 1 - 1e-7:
|
|
71
|
-
return np.zeros(3), 0.0
|
|
72
|
-
|
|
73
|
-
angle = 2 * np.arccos(quat[3])
|
|
74
|
-
xyz = quat[:3] / np.sqrt(1 - w2)
|
|
75
|
-
return xyz, angle
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# quat_rotate a vector
|
|
79
|
-
def quat_rotate(q, x):
|
|
80
|
-
x = np.array(x)
|
|
81
|
-
axis = np.array((q[0], q[1], q[2]))
|
|
82
|
-
return x * (2.0 * q[3] * q[3] - 1.0) + np.cross(axis, x) * q[3] * 2.0 + axis * np.dot(axis, x) * 2.0
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# multiply two quats
|
|
86
|
-
def quat_multiply(a, b):
|
|
87
|
-
return np.array(
|
|
88
|
-
(
|
|
89
|
-
a[3] * b[0] + b[3] * a[0] + a[1] * b[2] - b[1] * a[2],
|
|
90
|
-
a[3] * b[1] + b[3] * a[1] + a[2] * b[0] - b[2] * a[0],
|
|
91
|
-
a[3] * b[2] + b[3] * a[2] + a[0] * b[1] - b[0] * a[1],
|
|
92
|
-
a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],
|
|
93
|
-
)
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
# convert to mat33
|
|
98
|
-
def quat_to_matrix(q):
|
|
99
|
-
c1 = quat_rotate(q, np.array((1.0, 0.0, 0.0)))
|
|
100
|
-
c2 = quat_rotate(q, np.array((0.0, 1.0, 0.0)))
|
|
101
|
-
c3 = quat_rotate(q, np.array((0.0, 0.0, 1.0)))
|
|
102
|
-
|
|
103
|
-
return np.array([c1, c2, c3]).T
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def quat_rpy(roll, pitch, yaw):
|
|
107
|
-
cy = math.cos(yaw * 0.5)
|
|
108
|
-
sy = math.sin(yaw * 0.5)
|
|
109
|
-
cr = math.cos(roll * 0.5)
|
|
110
|
-
sr = math.sin(roll * 0.5)
|
|
111
|
-
cp = math.cos(pitch * 0.5)
|
|
112
|
-
sp = math.sin(pitch * 0.5)
|
|
113
|
-
|
|
114
|
-
w = cy * cr * cp + sy * sr * sp
|
|
115
|
-
x = cy * sr * cp - sy * cr * sp
|
|
116
|
-
y = cy * cr * sp + sy * sr * cp
|
|
117
|
-
z = sy * cr * cp - cy * sr * sp
|
|
118
|
-
|
|
119
|
-
return (x, y, z, w)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def quat_from_matrix(m):
|
|
123
|
-
tr = m[0, 0] + m[1, 1] + m[2, 2]
|
|
124
|
-
h = 0.0
|
|
125
|
-
|
|
126
|
-
if tr >= 0.0:
|
|
127
|
-
h = math.sqrt(tr + 1.0)
|
|
128
|
-
w = 0.5 * h
|
|
129
|
-
h = 0.5 / h
|
|
130
|
-
|
|
131
|
-
x = (m[2, 1] - m[1, 2]) * h
|
|
132
|
-
y = (m[0, 2] - m[2, 0]) * h
|
|
133
|
-
z = (m[1, 0] - m[0, 1]) * h
|
|
134
|
-
|
|
135
|
-
else:
|
|
136
|
-
i = 0
|
|
137
|
-
if m[1, 1] > m[0, 0]:
|
|
138
|
-
i = 1
|
|
139
|
-
if m[2, 2] > m[i, i]:
|
|
140
|
-
i = 2
|
|
141
|
-
|
|
142
|
-
if i == 0:
|
|
143
|
-
h = math.sqrt((m[0, 0] - (m[1, 1] + m[2, 2])) + 1.0)
|
|
144
|
-
x = 0.5 * h
|
|
145
|
-
h = 0.5 / h
|
|
146
27
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
28
|
+
def warn(message, category=None, stacklevel=1):
|
|
29
|
+
if (category, message) in warnings_seen:
|
|
30
|
+
return
|
|
150
31
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
32
|
+
with warnings.catch_warnings():
|
|
33
|
+
warnings.simplefilter("default") # Change the filter in this process
|
|
34
|
+
warnings.showwarning = warp_showwarning
|
|
35
|
+
warnings.warn(message, category, stacklevel + 1) # Increment stacklevel by 1 since we are in a wrapper
|
|
155
36
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
w = (m[0, 2] - m[2, 0]) * h
|
|
37
|
+
if category is DeprecationWarning:
|
|
38
|
+
warnings_seen.add((category, message))
|
|
159
39
|
|
|
160
|
-
elif i == 2:
|
|
161
|
-
h = math.sqrt((m[2, 2] - (m[0, 0] + m[1, 1])) + 1.0)
|
|
162
|
-
z = 0.5 * h
|
|
163
|
-
h = 0.5 / h
|
|
164
40
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return normalize(np.array([x, y, z, w]))
|
|
41
|
+
# expand a 7-vec to a tuple of arrays
|
|
42
|
+
def transform_expand(t):
|
|
43
|
+
return wp.transform(np.array(t[0:3]), np.array(t[3:7]))
|
|
170
44
|
|
|
171
45
|
|
|
172
46
|
@wp.func
|
|
@@ -182,210 +56,6 @@ def quat_between_vectors(a: wp.vec3, b: wp.vec3) -> wp.quat:
|
|
|
182
56
|
return wp.normalize(q)
|
|
183
57
|
|
|
184
58
|
|
|
185
|
-
# rigid body transform
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
# def transform(x, r):
|
|
189
|
-
# return (np.array(x), np.array(r))
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
def transform_identity():
|
|
193
|
-
return wp.transform(np.array((0.0, 0.0, 0.0)), quat_identity())
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
# se(3) -> SE(3), Park & Lynch pg. 105, screw in [w, v] normalized form
|
|
197
|
-
def transform_exp(s, angle):
|
|
198
|
-
w = np.array(s[0:3])
|
|
199
|
-
v = np.array(s[3:6])
|
|
200
|
-
|
|
201
|
-
if length(w) < 1.0:
|
|
202
|
-
r = quat_identity()
|
|
203
|
-
else:
|
|
204
|
-
r = quat_from_axis_angle(w, angle)
|
|
205
|
-
|
|
206
|
-
t = v * angle + (1.0 - math.cos(angle)) * np.cross(w, v) + (angle - math.sin(angle)) * np.cross(w, np.cross(w, v))
|
|
207
|
-
|
|
208
|
-
return (t, r)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
def transform_inverse(t):
|
|
212
|
-
q_inv = quat_inverse(t.q)
|
|
213
|
-
return wp.transform(-quat_rotate(q_inv, t.p), q_inv)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
def transform_vector(t, v):
|
|
217
|
-
return quat_rotate(t.q, v)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
def transform_point(t, p):
|
|
221
|
-
return np.array(t.p) + quat_rotate(t.q, p)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
def transform_multiply(t, u):
|
|
225
|
-
return wp.transform(quat_rotate(t.q, u.p) + t.p, quat_multiply(t.q, u.q))
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
# flatten an array of transforms (p,q) format to a 7-vector
|
|
229
|
-
def transform_flatten(t):
|
|
230
|
-
return np.array([*t.p, *t.q])
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
# expand a 7-vec to a tuple of arrays
|
|
234
|
-
def transform_expand(t):
|
|
235
|
-
return wp.transform(np.array(t[0:3]), np.array(t[3:7]))
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
# convert array of transforms to a array of 7-vecs
|
|
239
|
-
def transform_flatten_list(xforms):
|
|
240
|
-
exp = lambda t: transform_flatten(t)
|
|
241
|
-
return list(map(exp, xforms))
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
def transform_expand_list(xforms):
|
|
245
|
-
exp = lambda t: transform_expand(t)
|
|
246
|
-
return list(map(exp, xforms))
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
def transform_inertia(m, I, p, q):
|
|
250
|
-
"""
|
|
251
|
-
Transforms the inertia tensor described by the given mass and 3x3 inertia
|
|
252
|
-
matrix to a new frame described by the given position and orientation.
|
|
253
|
-
"""
|
|
254
|
-
R = quat_to_matrix(q)
|
|
255
|
-
|
|
256
|
-
# Steiner's theorem
|
|
257
|
-
return R @ I @ R.T + m * (np.dot(p, p) * np.eye(3) - np.outer(p, p))
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
# spatial operators
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
# AdT
|
|
264
|
-
def spatial_adjoint(t):
|
|
265
|
-
R = quat_to_matrix(t.q)
|
|
266
|
-
w = skew(t.p)
|
|
267
|
-
|
|
268
|
-
A = np.zeros((6, 6))
|
|
269
|
-
A[0:3, 0:3] = R
|
|
270
|
-
A[3:6, 0:3] = np.dot(w, R)
|
|
271
|
-
A[3:6, 3:6] = R
|
|
272
|
-
|
|
273
|
-
return A
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
# (AdT)^-T
|
|
277
|
-
def spatial_adjoint_dual(t):
|
|
278
|
-
R = quat_to_matrix(t.q)
|
|
279
|
-
w = skew(t.p)
|
|
280
|
-
|
|
281
|
-
A = np.zeros((6, 6))
|
|
282
|
-
A[0:3, 0:3] = R
|
|
283
|
-
A[0:3, 3:6] = np.dot(w, R)
|
|
284
|
-
A[3:6, 3:6] = R
|
|
285
|
-
|
|
286
|
-
return A
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
# AdT*s
|
|
290
|
-
def transform_twist(t_ab, s_b):
|
|
291
|
-
return np.dot(spatial_adjoint(t_ab), s_b)
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
# AdT^{-T}*s
|
|
295
|
-
def transform_wrench(t_ab, f_b):
|
|
296
|
-
return np.dot(spatial_adjoint_dual(t_ab), f_b)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
# transform spatial inertia (6x6) in b frame to a frame
|
|
300
|
-
def transform_spatial_inertia(t_ab, I_b):
|
|
301
|
-
t_ba = transform_inverse(t_ab)
|
|
302
|
-
|
|
303
|
-
# todo: write specialized method
|
|
304
|
-
I_a = np.dot(np.dot(spatial_adjoint(t_ba).T, I_b), spatial_adjoint(t_ba))
|
|
305
|
-
return I_a
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
def translate_twist(p_ab, s_b):
|
|
309
|
-
w = s_b[0:3]
|
|
310
|
-
v = np.cross(p_ab, s_b[0:3]) + s_b[3:6]
|
|
311
|
-
|
|
312
|
-
return np.array((*w, *v))
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
def translate_wrench(p_ab, s_b):
|
|
316
|
-
w = s_b[0:3] + np.cross(p_ab, s_b[3:6])
|
|
317
|
-
v = s_b[3:6]
|
|
318
|
-
|
|
319
|
-
return np.array((*w, *v))
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
# def spatial_vector(v=(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)):
|
|
323
|
-
# return np.array(v)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
# ad_V pg. 289 L&P, pg. 25 Featherstone
|
|
327
|
-
def spatial_cross(a, b):
|
|
328
|
-
w = np.cross(a[0:3], b[0:3])
|
|
329
|
-
v = np.cross(a[3:6], b[0:3]) + np.cross(a[0:3], b[3:6])
|
|
330
|
-
|
|
331
|
-
return np.array((*w, *v))
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
# ad_V^T pg. 290 L&P, pg. 25 Featurestone, note this does not includes the sign flip in the definition
|
|
335
|
-
def spatial_cross_dual(a, b):
|
|
336
|
-
w = np.cross(a[0:3], b[0:3]) + np.cross(a[3:6], b[3:6])
|
|
337
|
-
v = np.cross(a[0:3], b[3:6])
|
|
338
|
-
|
|
339
|
-
return np.array((*w, *v))
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
def spatial_dot(a, b):
|
|
343
|
-
return np.dot(a, b)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
def spatial_outer(a, b):
|
|
347
|
-
return np.outer(a, b)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
# def spatial_matrix():
|
|
351
|
-
# return np.zeros((6, 6))
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
def spatial_matrix_from_inertia(I, m):
|
|
355
|
-
G = spatial_matrix()
|
|
356
|
-
|
|
357
|
-
G[0:3, 0:3] = I
|
|
358
|
-
G[3, 3] = m
|
|
359
|
-
G[4, 4] = m
|
|
360
|
-
G[5, 5] = m
|
|
361
|
-
|
|
362
|
-
return G
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
# solves x = I^(-1)b
|
|
366
|
-
def spatial_solve(I, b):
|
|
367
|
-
return np.dot(np.linalg.inv(I), b)
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
# helper to retrive body angular velocity from a twist v_s in se(3)
|
|
371
|
-
def get_body_angular_velocity(v_s):
|
|
372
|
-
return v_s[0:3]
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
# helper to compute velocity of a point p on a body given it's spatial twist v_s
|
|
376
|
-
def get_body_linear_velocity(v_s, p):
|
|
377
|
-
dpdt = v_s[3:6] + np.cross(v_s[0:3], p)
|
|
378
|
-
return dpdt
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
# helper to build a body twist given the angular and linear velocity of
|
|
382
|
-
# the center of mass specified in the world frame, returns the body
|
|
383
|
-
# twist with respect to the origin (v_s)
|
|
384
|
-
def get_body_twist(w_m, v_m, p_m):
|
|
385
|
-
lin = v_m + np.cross(p_m, w_m)
|
|
386
|
-
return (*w_m, *lin)
|
|
387
|
-
|
|
388
|
-
|
|
389
59
|
def array_scan(in_array, out_array, inclusive=True):
|
|
390
60
|
if in_array.device != out_array.device:
|
|
391
61
|
raise RuntimeError("Array storage devices do not match")
|
|
@@ -396,6 +66,9 @@ def array_scan(in_array, out_array, inclusive=True):
|
|
|
396
66
|
if in_array.dtype != out_array.dtype:
|
|
397
67
|
raise RuntimeError("Array data types do not match")
|
|
398
68
|
|
|
69
|
+
if in_array.size == 0:
|
|
70
|
+
return
|
|
71
|
+
|
|
399
72
|
from warp.context import runtime
|
|
400
73
|
|
|
401
74
|
if in_array.device.is_cpu:
|
|
@@ -418,6 +91,9 @@ def radix_sort_pairs(keys, values, count: int):
|
|
|
418
91
|
if keys.device != values.device:
|
|
419
92
|
raise RuntimeError("Array storage devices do not match")
|
|
420
93
|
|
|
94
|
+
if count == 0:
|
|
95
|
+
return
|
|
96
|
+
|
|
421
97
|
if keys.size < 2 * count or values.size < 2 * count:
|
|
422
98
|
raise RuntimeError("Array storage must be large enough to contain 2*count elements")
|
|
423
99
|
|
|
@@ -454,14 +130,19 @@ def runlength_encode(values, run_values, run_lengths, run_count=None, value_coun
|
|
|
454
130
|
# User can provide a device output array for storing the number of runs
|
|
455
131
|
# For convenience, if no such array is provided, number of runs is returned on host
|
|
456
132
|
if run_count is None:
|
|
457
|
-
|
|
133
|
+
if value_count == 0:
|
|
134
|
+
return 0
|
|
458
135
|
run_count = wp.empty(shape=(1,), dtype=int, device=values.device)
|
|
136
|
+
host_return = True
|
|
459
137
|
else:
|
|
460
|
-
host_return = False
|
|
461
138
|
if run_count.device != values.device:
|
|
462
|
-
raise RuntimeError("run_count storage
|
|
139
|
+
raise RuntimeError("run_count storage device does not match other arrays")
|
|
463
140
|
if run_count.dtype != wp.int32:
|
|
464
141
|
raise RuntimeError("run_count array must be of type int32")
|
|
142
|
+
if value_count == 0:
|
|
143
|
+
run_count.zero_()
|
|
144
|
+
return 0
|
|
145
|
+
host_return = False
|
|
465
146
|
|
|
466
147
|
from warp.context import runtime
|
|
467
148
|
|
|
@@ -517,6 +198,12 @@ def array_sum(values, out=None, value_count=None, axis=None):
|
|
|
517
198
|
if out.shape != output_shape:
|
|
518
199
|
raise RuntimeError(f"out array should have shape {output_shape}")
|
|
519
200
|
|
|
201
|
+
if value_count == 0:
|
|
202
|
+
out.zero_()
|
|
203
|
+
if axis is None and host_return:
|
|
204
|
+
return out.numpy()[0]
|
|
205
|
+
return out
|
|
206
|
+
|
|
520
207
|
from warp.context import runtime
|
|
521
208
|
|
|
522
209
|
if values.device.is_cpu:
|
|
@@ -563,7 +250,7 @@ def array_inner(a, b, out=None, count=None, axis=None):
|
|
|
563
250
|
raise RuntimeError("Array storage sizes do not match")
|
|
564
251
|
|
|
565
252
|
if a.device != b.device:
|
|
566
|
-
raise RuntimeError("Array storage
|
|
253
|
+
raise RuntimeError("Array storage devices do not match")
|
|
567
254
|
|
|
568
255
|
if a.dtype != b.dtype:
|
|
569
256
|
raise RuntimeError("Array data types do not match")
|
|
@@ -600,6 +287,12 @@ def array_inner(a, b, out=None, count=None, axis=None):
|
|
|
600
287
|
if out.shape != output_shape:
|
|
601
288
|
raise RuntimeError(f"out array should have shape {output_shape}")
|
|
602
289
|
|
|
290
|
+
if count == 0:
|
|
291
|
+
if axis is None and host_return:
|
|
292
|
+
return 0.0
|
|
293
|
+
out.zero_()
|
|
294
|
+
return out
|
|
295
|
+
|
|
603
296
|
from warp.context import runtime
|
|
604
297
|
|
|
605
298
|
if a.device.is_cpu:
|
|
@@ -647,28 +340,16 @@ def array_inner(a, b, out=None, count=None, axis=None):
|
|
|
647
340
|
return out
|
|
648
341
|
|
|
649
342
|
|
|
650
|
-
|
|
343
|
+
@wp.kernel
|
|
344
|
+
def _array_cast_kernel(
|
|
345
|
+
dest: Any,
|
|
346
|
+
src: Any,
|
|
347
|
+
):
|
|
348
|
+
i = wp.tid()
|
|
349
|
+
dest[i] = dest.dtype(src[i])
|
|
651
350
|
|
|
652
351
|
|
|
653
352
|
def array_cast(in_array, out_array, count=None):
|
|
654
|
-
def make_copy_kernel(dest_dtype, src_dtype):
|
|
655
|
-
import re
|
|
656
|
-
import warp.context
|
|
657
|
-
|
|
658
|
-
def copy_kernel(
|
|
659
|
-
dest: Any,
|
|
660
|
-
src: Any,
|
|
661
|
-
):
|
|
662
|
-
dest[wp.tid()] = dest_dtype(src[wp.tid()])
|
|
663
|
-
|
|
664
|
-
module = wp.get_module(copy_kernel.__module__)
|
|
665
|
-
key = f"{copy_kernel.__name__}_{warp.context.type_str(src_dtype)}_{warp.context.type_str(dest_dtype)}"
|
|
666
|
-
key = re.sub("[^0-9a-zA-Z_]+", "", key)
|
|
667
|
-
|
|
668
|
-
if key not in _copy_kernel_cache:
|
|
669
|
-
_copy_kernel_cache[key] = wp.Kernel(func=copy_kernel, key=key, module=module)
|
|
670
|
-
return _copy_kernel_cache[key]
|
|
671
|
-
|
|
672
353
|
if in_array.device != out_array.device:
|
|
673
354
|
raise RuntimeError("Array storage devices do not match")
|
|
674
355
|
|
|
@@ -723,8 +404,7 @@ def array_cast(in_array, out_array, count=None):
|
|
|
723
404
|
# Same data type, can simply copy
|
|
724
405
|
wp.copy(dest=out_array, src=in_array, count=count)
|
|
725
406
|
else:
|
|
726
|
-
|
|
727
|
-
wp.launch(kernel=copy_kernel, dim=dim, inputs=[out_array, in_array], device=out_array.device)
|
|
407
|
+
wp.launch(kernel=_array_cast_kernel, dim=dim, inputs=[out_array, in_array], device=out_array.device)
|
|
728
408
|
|
|
729
409
|
|
|
730
410
|
# code snippet for invoking cProfile
|
|
@@ -738,6 +418,25 @@ def array_cast(in_array, out_array, count=None):
|
|
|
738
418
|
# exit(0)
|
|
739
419
|
|
|
740
420
|
|
|
421
|
+
# helper kernels for initializing NVDB volumes from a dense array
|
|
422
|
+
@wp.kernel
|
|
423
|
+
def copy_dense_volume_to_nano_vdb_v(volume: wp.uint64, values: wp.array(dtype=wp.vec3, ndim=3)):
|
|
424
|
+
i, j, k = wp.tid()
|
|
425
|
+
wp.volume_store_v(volume, i, j, k, values[i, j, k])
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
@wp.kernel
|
|
429
|
+
def copy_dense_volume_to_nano_vdb_f(volume: wp.uint64, values: wp.array(dtype=wp.float32, ndim=3)):
|
|
430
|
+
i, j, k = wp.tid()
|
|
431
|
+
wp.volume_store_f(volume, i, j, k, values[i, j, k])
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
@wp.kernel
|
|
435
|
+
def copy_dense_volume_to_nano_vdb_i(volume: wp.uint64, values: wp.array(dtype=wp.int32, ndim=3)):
|
|
436
|
+
i, j, k = wp.tid()
|
|
437
|
+
wp.volume_store_i(volume, i, j, k, values[i, j, k])
|
|
438
|
+
|
|
439
|
+
|
|
741
440
|
# represent an edge between v0, v1 with connected faces f0, f1, and opposite vertex o0, and o1
|
|
742
441
|
# winding is such that first tri can be reconstructed as {v0, v1, o0}, and second tri as { v1, v0, o1 }
|
|
743
442
|
class MeshEdge:
|
|
@@ -781,11 +480,8 @@ class MeshAdjacency:
|
|
|
781
480
|
|
|
782
481
|
self.edges[key] = edge
|
|
783
482
|
|
|
784
|
-
def opposite_vertex(self, edge):
|
|
785
|
-
pass
|
|
786
483
|
|
|
787
|
-
|
|
788
|
-
def mem_report():
|
|
484
|
+
def mem_report(): #pragma: no cover
|
|
789
485
|
def _mem_report(tensors, mem_type):
|
|
790
486
|
"""Print the selected tensors of type
|
|
791
487
|
There are two major storage types in our major concern:
|
|
@@ -821,6 +517,7 @@ def mem_report():
|
|
|
821
517
|
print("Type: %s Total Tensors: %d \tUsed Memory Space: %.2f MBytes" % (mem_type, total_numel, total_mem))
|
|
822
518
|
|
|
823
519
|
import gc
|
|
520
|
+
|
|
824
521
|
import torch
|
|
825
522
|
|
|
826
523
|
gc.collect()
|
|
@@ -836,12 +533,6 @@ def mem_report():
|
|
|
836
533
|
print("=" * LEN)
|
|
837
534
|
|
|
838
535
|
|
|
839
|
-
def lame_parameters(E, nu):
|
|
840
|
-
l = (E * nu) / ((1.0 + nu) * (1.0 - 2.0 * nu))
|
|
841
|
-
mu = E / (2.0 * (1.0 + nu))
|
|
842
|
-
|
|
843
|
-
return (l, mu)
|
|
844
|
-
|
|
845
536
|
|
|
846
537
|
class ScopedDevice:
|
|
847
538
|
def __init__(self, device):
|
|
@@ -946,7 +637,8 @@ class ScopedTimer:
|
|
|
946
637
|
return
|
|
947
638
|
|
|
948
639
|
self.start = timeit.default_timer()
|
|
949
|
-
|
|
640
|
+
if self.print:
|
|
641
|
+
ScopedTimer.indent += 1
|
|
950
642
|
|
|
951
643
|
if self.detailed:
|
|
952
644
|
self.cp = cProfile.Profile()
|
|
@@ -983,3 +675,17 @@ class ScopedTimer:
|
|
|
983
675
|
print("{}{} took {:.2f} ms".format(indent, self.name, self.elapsed))
|
|
984
676
|
|
|
985
677
|
ScopedTimer.indent -= 1
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
# helper kernels for adj_matmul
|
|
681
|
+
@wp.kernel
|
|
682
|
+
def add_kernel_2d(x: wp.array2d(dtype=Any), acc: wp.array2d(dtype=Any), beta: Any):
|
|
683
|
+
i, j = wp.tid()
|
|
684
|
+
|
|
685
|
+
x[i,j] = x[i,j] + beta * acc[i,j]
|
|
686
|
+
|
|
687
|
+
@wp.kernel
|
|
688
|
+
def add_kernel_3d(x: wp.array3d(dtype=Any), acc: wp.array3d(dtype=Any), beta: Any):
|
|
689
|
+
i, j, k = wp.tid()
|
|
690
|
+
|
|
691
|
+
x[i,j,k] = x[i,j,k] + beta * acc[i,j,k]
|