warp-lang 1.0.0b2__py3-none-win_amd64.whl → 1.0.0b6__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.
- docs/conf.py +17 -5
- examples/env/env_ant.py +1 -1
- examples/env/env_cartpole.py +1 -1
- examples/env/env_humanoid.py +1 -1
- examples/env/env_usd.py +4 -1
- examples/env/environment.py +8 -9
- examples/example_dem.py +34 -33
- examples/example_diffray.py +364 -337
- examples/example_fluid.py +32 -23
- examples/example_jacobian_ik.py +97 -93
- examples/example_marching_cubes.py +6 -16
- examples/example_mesh.py +6 -16
- examples/example_mesh_intersect.py +16 -14
- examples/example_nvdb.py +14 -16
- examples/example_raycast.py +14 -13
- examples/example_raymarch.py +16 -23
- examples/example_render_opengl.py +19 -10
- examples/example_sim_cartpole.py +82 -78
- examples/example_sim_cloth.py +45 -48
- examples/example_sim_fk_grad.py +51 -44
- examples/example_sim_fk_grad_torch.py +47 -40
- examples/example_sim_grad_bounce.py +108 -133
- examples/example_sim_grad_cloth.py +99 -113
- examples/example_sim_granular.py +5 -6
- examples/{example_sim_sdf_shape.py → example_sim_granular_collision_sdf.py} +37 -26
- examples/example_sim_neo_hookean.py +51 -55
- examples/example_sim_particle_chain.py +4 -4
- examples/example_sim_quadruped.py +126 -81
- examples/example_sim_rigid_chain.py +54 -61
- examples/example_sim_rigid_contact.py +66 -70
- examples/example_sim_rigid_fem.py +3 -3
- examples/example_sim_rigid_force.py +1 -1
- examples/example_sim_rigid_gyroscopic.py +3 -4
- examples/example_sim_rigid_kinematics.py +28 -39
- examples/example_sim_trajopt.py +112 -110
- examples/example_sph.py +9 -8
- examples/example_wave.py +7 -7
- examples/fem/bsr_utils.py +30 -17
- examples/fem/example_apic_fluid.py +85 -69
- examples/fem/example_convection_diffusion.py +97 -93
- examples/fem/example_convection_diffusion_dg.py +142 -149
- examples/fem/example_convection_diffusion_dg0.py +141 -136
- examples/fem/example_deformed_geometry.py +146 -0
- examples/fem/example_diffusion.py +115 -84
- examples/fem/example_diffusion_3d.py +116 -86
- examples/fem/example_diffusion_mgpu.py +102 -79
- examples/fem/example_mixed_elasticity.py +139 -100
- examples/fem/example_navier_stokes.py +175 -162
- examples/fem/example_stokes.py +143 -111
- examples/fem/example_stokes_transfer.py +186 -157
- examples/fem/mesh_utils.py +59 -97
- examples/fem/plot_utils.py +138 -17
- tools/ci/publishing/build_nodes_info.py +54 -0
- warp/__init__.py +4 -3
- 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 +836 -492
- warp/codegen.py +864 -553
- warp/config.py +3 -1
- warp/context.py +389 -172
- warp/fem/__init__.py +24 -6
- warp/fem/cache.py +318 -25
- warp/fem/dirichlet.py +7 -3
- warp/fem/domain.py +14 -0
- warp/fem/field/__init__.py +30 -38
- warp/fem/field/field.py +149 -0
- warp/fem/field/nodal_field.py +244 -138
- warp/fem/field/restriction.py +8 -6
- warp/fem/field/test.py +127 -59
- warp/fem/field/trial.py +117 -60
- warp/fem/geometry/__init__.py +5 -1
- warp/fem/geometry/deformed_geometry.py +271 -0
- warp/fem/geometry/element.py +24 -1
- warp/fem/geometry/geometry.py +86 -14
- warp/fem/geometry/grid_2d.py +112 -54
- warp/fem/geometry/grid_3d.py +134 -65
- warp/fem/geometry/hexmesh.py +953 -0
- warp/fem/geometry/partition.py +85 -33
- warp/fem/geometry/quadmesh_2d.py +532 -0
- warp/fem/geometry/tetmesh.py +451 -115
- warp/fem/geometry/trimesh_2d.py +197 -92
- warp/fem/integrate.py +534 -268
- warp/fem/operator.py +58 -31
- warp/fem/polynomial.py +11 -0
- warp/fem/quadrature/__init__.py +1 -1
- warp/fem/quadrature/pic_quadrature.py +150 -58
- warp/fem/quadrature/quadrature.py +209 -57
- warp/fem/space/__init__.py +230 -53
- warp/fem/space/basis_space.py +489 -0
- warp/fem/space/collocated_function_space.py +105 -0
- warp/fem/space/dof_mapper.py +49 -2
- warp/fem/space/function_space.py +90 -39
- warp/fem/space/grid_2d_function_space.py +149 -496
- warp/fem/space/grid_3d_function_space.py +173 -538
- warp/fem/space/hexmesh_function_space.py +352 -0
- warp/fem/space/partition.py +129 -76
- warp/fem/space/quadmesh_2d_function_space.py +369 -0
- warp/fem/space/restriction.py +46 -34
- 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 +132 -1039
- warp/fem/space/topology.py +295 -0
- warp/fem/space/trimesh_2d_function_space.py +104 -742
- warp/fem/types.py +13 -11
- warp/fem/utils.py +335 -60
- warp/native/array.h +120 -34
- warp/native/builtin.h +101 -72
- warp/native/bvh.cpp +73 -325
- warp/native/bvh.cu +406 -23
- warp/native/bvh.h +22 -40
- warp/native/clang/clang.cpp +1 -0
- warp/native/crt.h +2 -0
- warp/native/cuda_util.cpp +8 -3
- warp/native/cuda_util.h +1 -0
- warp/native/exports.h +1522 -1243
- warp/native/intersect.h +19 -4
- warp/native/intersect_adj.h +8 -8
- warp/native/mat.h +76 -17
- warp/native/mesh.cpp +33 -108
- warp/native/mesh.cu +114 -18
- warp/native/mesh.h +395 -40
- warp/native/noise.h +272 -329
- warp/native/quat.h +51 -8
- warp/native/rand.h +44 -34
- warp/native/reduce.cpp +1 -1
- warp/native/sparse.cpp +4 -4
- warp/native/sparse.cu +163 -155
- warp/native/spatial.h +2 -2
- warp/native/temp_buffer.h +18 -14
- warp/native/vec.h +103 -21
- warp/native/warp.cpp +2 -1
- warp/native/warp.cu +28 -3
- warp/native/warp.h +4 -3
- warp/render/render_opengl.py +261 -109
- warp/sim/__init__.py +1 -2
- warp/sim/articulation.py +385 -185
- warp/sim/import_mjcf.py +59 -48
- warp/sim/import_urdf.py +15 -15
- warp/sim/import_usd.py +174 -102
- warp/sim/inertia.py +17 -18
- warp/sim/integrator_xpbd.py +4 -3
- warp/sim/model.py +330 -250
- warp/sim/render.py +1 -1
- warp/sparse.py +625 -152
- warp/stubs.py +341 -309
- warp/tape.py +9 -6
- 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 +94 -74
- warp/tests/test_array.py +82 -101
- warp/tests/test_array_reduce.py +57 -23
- warp/tests/test_atomic.py +64 -28
- warp/tests/test_bool.py +22 -12
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +18 -18
- warp/tests/test_closest_point_edge_edge.py +54 -57
- warp/tests/test_codegen.py +165 -134
- 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 +237 -0
- warp/tests/test_fabricarray.py +22 -24
- warp/tests/test_fast_math.py +15 -11
- warp/tests/test_fem.py +1034 -124
- warp/tests/test_fp16.py +23 -16
- warp/tests/test_func.py +187 -86
- warp/tests/test_generics.py +194 -49
- warp/tests/test_grad.py +123 -181
- warp/tests/test_grad_customs.py +176 -0
- warp/tests/test_hash_grid.py +35 -34
- warp/tests/test_import.py +10 -23
- warp/tests/test_indexedarray.py +24 -25
- 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_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 +304 -69
- warp/tests/test_matmul_lite.py +410 -0
- warp/tests/test_mesh.py +60 -22
- warp/tests/test_mesh_query_aabb.py +21 -25
- warp/tests/test_mesh_query_point.py +111 -22
- warp/tests/test_mesh_query_ray.py +12 -24
- 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 +90 -86
- warp/tests/test_transient_module.py +10 -12
- warp/tests/test_types.py +363 -0
- warp/tests/test_utils.py +451 -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 +418 -376
- warp/tests/test_volume_write.py +124 -134
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +291 -0
- warp/tests/unittest_utils.py +342 -0
- warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
- warp/tests/{test_debug.py → walkthough_debug.py} +3 -17
- warp/thirdparty/appdirs.py +36 -45
- warp/thirdparty/unittest_parallel.py +589 -0
- warp/types.py +622 -211
- warp/utils.py +54 -393
- warp_lang-1.0.0b6.dist-info/METADATA +238 -0
- warp_lang-1.0.0b6.dist-info/RECORD +409 -0
- {warp_lang-1.0.0b2.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
- examples/example_cache_management.py +0 -40
- examples/example_multigpu.py +0 -54
- examples/example_struct.py +0 -65
- examples/fem/example_stokes_transfer_3d.py +0 -210
- warp/bin/warp-clang.so +0 -0
- warp/bin/warp.so +0 -0
- warp/fem/field/discrete_field.py +0 -80
- warp/fem/space/nodal_function_space.py +0 -233
- warp/tests/test_all.py +0 -223
- 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-1.0.0b2.dist-info/METADATA +0 -26
- warp_lang-1.0.0b2.dist-info/RECORD +0 -380
- /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-1.0.0b2.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.0.0b2.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
warp/tests/test_spatial.py
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2023 NVIDIA CORPORATION. All rights reserved.
|
|
2
|
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
|
3
|
+
# and proprietary rights in and to this software, related documentation
|
|
4
|
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
|
5
|
+
# distribution of this software and related documentation without an express
|
|
6
|
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
|
+
|
|
8
|
+
import unittest
|
|
9
|
+
|
|
1
10
|
import numpy as np
|
|
2
|
-
import math
|
|
3
11
|
|
|
4
12
|
import warp as wp
|
|
5
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
6
14
|
|
|
7
15
|
wp.init()
|
|
8
16
|
|
|
@@ -12,10 +20,9 @@ kernel_cache = dict()
|
|
|
12
20
|
|
|
13
21
|
|
|
14
22
|
def getkernel(func, suffix=""):
|
|
15
|
-
module = wp.get_module(func.__module__)
|
|
16
23
|
key = func.__name__ + "_" + suffix
|
|
17
24
|
if key not in kernel_cache:
|
|
18
|
-
kernel_cache[key] = wp.Kernel(func=func, key=key
|
|
25
|
+
kernel_cache[key] = wp.Kernel(func=func, key=key)
|
|
19
26
|
return kernel_cache[key]
|
|
20
27
|
|
|
21
28
|
|
|
@@ -34,7 +41,7 @@ def get_select_kernel(dtype):
|
|
|
34
41
|
|
|
35
42
|
|
|
36
43
|
def test_spatial_vector_constructors(test, device, dtype, register_kernels=False):
|
|
37
|
-
np.random.
|
|
44
|
+
rng = np.random.default_rng(123)
|
|
38
45
|
|
|
39
46
|
tol = {
|
|
40
47
|
np.float16: 5.0e-3,
|
|
@@ -81,7 +88,7 @@ def test_spatial_vector_constructors(test, device, dtype, register_kernels=False
|
|
|
81
88
|
if register_kernels:
|
|
82
89
|
return
|
|
83
90
|
|
|
84
|
-
input = wp.array(
|
|
91
|
+
input = wp.array(rng.standard_normal(size=6).astype(dtype), requires_grad=True, device=device)
|
|
85
92
|
output = wp.zeros_like(input)
|
|
86
93
|
wp.launch(kernel, dim=1, inputs=[input], outputs=[output], device=device)
|
|
87
94
|
|
|
@@ -99,7 +106,7 @@ def test_spatial_vector_constructors(test, device, dtype, register_kernels=False
|
|
|
99
106
|
assert_np_equal(tape.gradients[input].numpy(), expectedgrads)
|
|
100
107
|
tape.zero()
|
|
101
108
|
|
|
102
|
-
input = wp.array(
|
|
109
|
+
input = wp.array(rng.standard_normal(size=6).astype(dtype), requires_grad=True, device=device)
|
|
103
110
|
output = wp.zeros_like(input)
|
|
104
111
|
wp.launch(vec_kernel, dim=1, inputs=[input], outputs=[output], device=device)
|
|
105
112
|
|
|
@@ -119,7 +126,7 @@ def test_spatial_vector_constructors(test, device, dtype, register_kernels=False
|
|
|
119
126
|
|
|
120
127
|
|
|
121
128
|
def test_spatial_vector_indexing(test, device, dtype, register_kernels=False):
|
|
122
|
-
np.random.
|
|
129
|
+
rng = np.random.default_rng(123)
|
|
123
130
|
|
|
124
131
|
tol = {
|
|
125
132
|
np.float16: 5.0e-3,
|
|
@@ -148,7 +155,9 @@ def test_spatial_vector_indexing(test, device, dtype, register_kernels=False):
|
|
|
148
155
|
if register_kernels:
|
|
149
156
|
return
|
|
150
157
|
|
|
151
|
-
input = wp.array(
|
|
158
|
+
input = wp.array(
|
|
159
|
+
rng.standard_normal(size=(1, 6)).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device
|
|
160
|
+
)
|
|
152
161
|
outcmps = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
153
162
|
|
|
154
163
|
wp.launch(kernel, dim=1, inputs=[input], outputs=[outcmps], device=device)
|
|
@@ -169,7 +178,7 @@ def test_spatial_vector_indexing(test, device, dtype, register_kernels=False):
|
|
|
169
178
|
|
|
170
179
|
|
|
171
180
|
def test_spatial_vector_scalar_multiplication(test, device, dtype, register_kernels=False):
|
|
172
|
-
np.random.
|
|
181
|
+
rng = np.random.default_rng(123)
|
|
173
182
|
|
|
174
183
|
tol = {
|
|
175
184
|
np.float16: 5.0e-3,
|
|
@@ -200,8 +209,10 @@ def test_spatial_vector_scalar_multiplication(test, device, dtype, register_kern
|
|
|
200
209
|
if register_kernels:
|
|
201
210
|
return
|
|
202
211
|
|
|
203
|
-
s = wp.array(
|
|
204
|
-
q = wp.array(
|
|
212
|
+
s = wp.array(rng.standard_normal(size=1).astype(dtype), requires_grad=True, device=device)
|
|
213
|
+
q = wp.array(
|
|
214
|
+
rng.standard_normal(size=(1, 6)).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device
|
|
215
|
+
)
|
|
205
216
|
|
|
206
217
|
outcmps_l = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
207
218
|
outcmps_r = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -237,7 +248,7 @@ def test_spatial_vector_scalar_multiplication(test, device, dtype, register_kern
|
|
|
237
248
|
|
|
238
249
|
|
|
239
250
|
def test_spatial_vector_add_sub(test, device, dtype, register_kernels=False):
|
|
240
|
-
np.random.
|
|
251
|
+
rng = np.random.default_rng(123)
|
|
241
252
|
|
|
242
253
|
tol = {
|
|
243
254
|
np.float16: 5.0e-3,
|
|
@@ -265,8 +276,8 @@ def test_spatial_vector_add_sub(test, device, dtype, register_kernels=False):
|
|
|
265
276
|
if register_kernels:
|
|
266
277
|
return
|
|
267
278
|
|
|
268
|
-
q = wp.array(
|
|
269
|
-
v = wp.array(
|
|
279
|
+
q = wp.array(rng.standard_normal(size=6).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device)
|
|
280
|
+
v = wp.array(rng.standard_normal(size=6).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device)
|
|
270
281
|
|
|
271
282
|
outputs_add = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
272
283
|
outputs_sub = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -313,7 +324,7 @@ def test_spatial_vector_add_sub(test, device, dtype, register_kernels=False):
|
|
|
313
324
|
|
|
314
325
|
|
|
315
326
|
def test_spatial_dot(test, device, dtype, register_kernels=False):
|
|
316
|
-
np.random.
|
|
327
|
+
rng = np.random.default_rng(123)
|
|
317
328
|
|
|
318
329
|
tol = {
|
|
319
330
|
np.float16: 1.0e-2,
|
|
@@ -335,8 +346,8 @@ def test_spatial_dot(test, device, dtype, register_kernels=False):
|
|
|
335
346
|
if register_kernels:
|
|
336
347
|
return
|
|
337
348
|
|
|
338
|
-
s = wp.array(
|
|
339
|
-
v = wp.array(
|
|
349
|
+
s = wp.array(rng.standard_normal(size=6).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device)
|
|
350
|
+
v = wp.array(rng.standard_normal(size=6).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device)
|
|
340
351
|
dot = wp.zeros(1, dtype=wptype, requires_grad=True, device=device)
|
|
341
352
|
|
|
342
353
|
tape = wp.Tape()
|
|
@@ -365,7 +376,7 @@ def test_spatial_dot(test, device, dtype, register_kernels=False):
|
|
|
365
376
|
|
|
366
377
|
|
|
367
378
|
def test_spatial_cross(test, device, dtype, register_kernels=False):
|
|
368
|
-
np.random.
|
|
379
|
+
rng = np.random.default_rng(123)
|
|
369
380
|
|
|
370
381
|
tol = {
|
|
371
382
|
np.float16: 5.0e-3,
|
|
@@ -416,8 +427,8 @@ def test_spatial_cross(test, device, dtype, register_kernels=False):
|
|
|
416
427
|
if register_kernels:
|
|
417
428
|
return
|
|
418
429
|
|
|
419
|
-
s = wp.array(
|
|
420
|
-
v = wp.array(
|
|
430
|
+
s = wp.array(rng.standard_normal(size=6).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device)
|
|
431
|
+
v = wp.array(rng.standard_normal(size=6).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device)
|
|
421
432
|
outputs = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
422
433
|
outputs_dual = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
423
434
|
outputs_wcrossw = wp.zeros(3, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -519,7 +530,7 @@ def test_spatial_cross(test, device, dtype, register_kernels=False):
|
|
|
519
530
|
|
|
520
531
|
|
|
521
532
|
def test_spatial_top_bottom(test, device, dtype, register_kernels=False):
|
|
522
|
-
np.random.
|
|
533
|
+
rng = np.random.default_rng(123)
|
|
523
534
|
|
|
524
535
|
tol = {
|
|
525
536
|
np.float16: 1.0e-2,
|
|
@@ -551,7 +562,7 @@ def test_spatial_top_bottom(test, device, dtype, register_kernels=False):
|
|
|
551
562
|
if register_kernels:
|
|
552
563
|
return
|
|
553
564
|
|
|
554
|
-
s = wp.array(
|
|
565
|
+
s = wp.array(rng.standard_normal(size=6).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device)
|
|
555
566
|
outputs = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
556
567
|
|
|
557
568
|
wp.launch(
|
|
@@ -588,7 +599,7 @@ def test_spatial_top_bottom(test, device, dtype, register_kernels=False):
|
|
|
588
599
|
|
|
589
600
|
|
|
590
601
|
def test_transform_constructors(test, device, dtype, register_kernels=False):
|
|
591
|
-
np.random.
|
|
602
|
+
rng = np.random.default_rng(123)
|
|
592
603
|
|
|
593
604
|
tol = {
|
|
594
605
|
np.float16: 5.0e-3,
|
|
@@ -622,8 +633,8 @@ def test_transform_constructors(test, device, dtype, register_kernels=False):
|
|
|
622
633
|
if register_kernels:
|
|
623
634
|
return
|
|
624
635
|
|
|
625
|
-
p =
|
|
626
|
-
q =
|
|
636
|
+
p = rng.standard_normal(size=3).astype(dtype)
|
|
637
|
+
q = rng.standard_normal(size=4).astype(dtype)
|
|
627
638
|
q /= np.linalg.norm(q)
|
|
628
639
|
|
|
629
640
|
input = wp.array(np.concatenate((p, q)), requires_grad=True, device=device)
|
|
@@ -647,7 +658,7 @@ def test_transform_constructors(test, device, dtype, register_kernels=False):
|
|
|
647
658
|
|
|
648
659
|
|
|
649
660
|
def test_transform_indexing(test, device, dtype, register_kernels=False):
|
|
650
|
-
np.random.
|
|
661
|
+
rng = np.random.default_rng(123)
|
|
651
662
|
|
|
652
663
|
tol = {
|
|
653
664
|
np.float16: 5.0e-3,
|
|
@@ -676,7 +687,7 @@ def test_transform_indexing(test, device, dtype, register_kernels=False):
|
|
|
676
687
|
if register_kernels:
|
|
677
688
|
return
|
|
678
689
|
|
|
679
|
-
input = wp.array(
|
|
690
|
+
input = wp.array(rng.standard_normal(size=(1, 7)).astype(dtype), dtype=transform, requires_grad=True, device=device)
|
|
680
691
|
outcmps = wp.zeros(7, dtype=wptype, requires_grad=True, device=device)
|
|
681
692
|
|
|
682
693
|
wp.launch(kernel, dim=1, inputs=[input], outputs=[outcmps], device=device)
|
|
@@ -696,7 +707,7 @@ def test_transform_indexing(test, device, dtype, register_kernels=False):
|
|
|
696
707
|
|
|
697
708
|
|
|
698
709
|
def test_transform_scalar_multiplication(test, device, dtype, register_kernels=False):
|
|
699
|
-
np.random.
|
|
710
|
+
rng = np.random.default_rng(123)
|
|
700
711
|
|
|
701
712
|
tol = {
|
|
702
713
|
np.float16: 5.0e-3,
|
|
@@ -727,8 +738,8 @@ def test_transform_scalar_multiplication(test, device, dtype, register_kernels=F
|
|
|
727
738
|
if register_kernels:
|
|
728
739
|
return
|
|
729
740
|
|
|
730
|
-
s = wp.array(
|
|
731
|
-
q = wp.array(
|
|
741
|
+
s = wp.array(rng.standard_normal(size=1).astype(dtype), requires_grad=True, device=device)
|
|
742
|
+
q = wp.array(rng.standard_normal(size=(1, 7)).astype(dtype), dtype=transform, requires_grad=True, device=device)
|
|
732
743
|
|
|
733
744
|
outcmps_l = wp.zeros(7, dtype=wptype, requires_grad=True, device=device)
|
|
734
745
|
outcmps_r = wp.zeros(7, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -764,7 +775,7 @@ def test_transform_scalar_multiplication(test, device, dtype, register_kernels=F
|
|
|
764
775
|
|
|
765
776
|
|
|
766
777
|
def test_transform_add_sub(test, device, dtype, register_kernels=False):
|
|
767
|
-
np.random.
|
|
778
|
+
rng = np.random.default_rng(123)
|
|
768
779
|
|
|
769
780
|
tol = {
|
|
770
781
|
np.float16: 5.0e-3,
|
|
@@ -793,8 +804,8 @@ def test_transform_add_sub(test, device, dtype, register_kernels=False):
|
|
|
793
804
|
if register_kernels:
|
|
794
805
|
return
|
|
795
806
|
|
|
796
|
-
q = wp.array(
|
|
797
|
-
v = wp.array(
|
|
807
|
+
q = wp.array(rng.standard_normal(size=7).astype(dtype), dtype=transform, requires_grad=True, device=device)
|
|
808
|
+
v = wp.array(rng.standard_normal(size=7).astype(dtype), dtype=transform, requires_grad=True, device=device)
|
|
798
809
|
|
|
799
810
|
outputs_add = wp.zeros(7, dtype=wptype, requires_grad=True, device=device)
|
|
800
811
|
outputs_sub = wp.zeros(7, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -841,7 +852,7 @@ def test_transform_add_sub(test, device, dtype, register_kernels=False):
|
|
|
841
852
|
|
|
842
853
|
|
|
843
854
|
def test_transform_get_trans_rot(test, device, dtype, register_kernels=False):
|
|
844
|
-
np.random.
|
|
855
|
+
rng = np.random.default_rng(123)
|
|
845
856
|
|
|
846
857
|
tol = {
|
|
847
858
|
np.float16: 1.0e-2,
|
|
@@ -874,7 +885,7 @@ def test_transform_get_trans_rot(test, device, dtype, register_kernels=False):
|
|
|
874
885
|
if register_kernels:
|
|
875
886
|
return
|
|
876
887
|
|
|
877
|
-
s = wp.array(
|
|
888
|
+
s = wp.array(rng.standard_normal(size=7).astype(dtype), dtype=transform, requires_grad=True, device=device)
|
|
878
889
|
outputs = wp.zeros(7, dtype=wptype, requires_grad=True, device=device)
|
|
879
890
|
|
|
880
891
|
wp.launch(
|
|
@@ -911,7 +922,7 @@ def test_transform_get_trans_rot(test, device, dtype, register_kernels=False):
|
|
|
911
922
|
|
|
912
923
|
|
|
913
924
|
def test_transform_multiply(test, device, dtype, register_kernels=False):
|
|
914
|
-
np.random.
|
|
925
|
+
rng = np.random.default_rng(123)
|
|
915
926
|
|
|
916
927
|
tol = {
|
|
917
928
|
np.float16: 1.0e-2,
|
|
@@ -955,8 +966,8 @@ def test_transform_multiply(test, device, dtype, register_kernels=False):
|
|
|
955
966
|
if register_kernels:
|
|
956
967
|
return
|
|
957
968
|
|
|
958
|
-
q =
|
|
959
|
-
s =
|
|
969
|
+
q = rng.standard_normal(size=7)
|
|
970
|
+
s = rng.standard_normal(size=7)
|
|
960
971
|
q[3:] /= np.linalg.norm(q[3:])
|
|
961
972
|
s[3:] /= np.linalg.norm(s[3:])
|
|
962
973
|
|
|
@@ -1020,7 +1031,7 @@ def test_transform_multiply(test, device, dtype, register_kernels=False):
|
|
|
1020
1031
|
|
|
1021
1032
|
|
|
1022
1033
|
def test_transform_inverse(test, device, dtype, register_kernels=False):
|
|
1023
|
-
np.random.
|
|
1034
|
+
rng = np.random.default_rng(123)
|
|
1024
1035
|
|
|
1025
1036
|
tol = {
|
|
1026
1037
|
np.float16: 1.0e-2,
|
|
@@ -1059,8 +1070,8 @@ def test_transform_inverse(test, device, dtype, register_kernels=False):
|
|
|
1059
1070
|
if register_kernels:
|
|
1060
1071
|
return
|
|
1061
1072
|
|
|
1062
|
-
q =
|
|
1063
|
-
s =
|
|
1073
|
+
q = rng.standard_normal(size=7)
|
|
1074
|
+
s = rng.standard_normal(size=7)
|
|
1064
1075
|
q[3:] /= np.linalg.norm(q[3:])
|
|
1065
1076
|
s[3:] /= np.linalg.norm(s[3:])
|
|
1066
1077
|
|
|
@@ -1113,7 +1124,7 @@ def test_transform_inverse(test, device, dtype, register_kernels=False):
|
|
|
1113
1124
|
|
|
1114
1125
|
|
|
1115
1126
|
def test_transform_point_vector(test, device, dtype, register_kernels=False):
|
|
1116
|
-
np.random.
|
|
1127
|
+
rng = np.random.default_rng(123)
|
|
1117
1128
|
|
|
1118
1129
|
tol = {
|
|
1119
1130
|
np.float16: 1.0e-2,
|
|
@@ -1151,11 +1162,11 @@ def test_transform_point_vector(test, device, dtype, register_kernels=False):
|
|
|
1151
1162
|
if register_kernels:
|
|
1152
1163
|
return
|
|
1153
1164
|
|
|
1154
|
-
q =
|
|
1165
|
+
q = rng.standard_normal(size=7)
|
|
1155
1166
|
q[3:] /= np.linalg.norm(q[3:])
|
|
1156
1167
|
|
|
1157
1168
|
t = wp.array(q.astype(dtype), dtype=transform, requires_grad=True, device=device)
|
|
1158
|
-
v = wp.array(
|
|
1169
|
+
v = wp.array(rng.standard_normal(size=3), dtype=vec3, requires_grad=True, device=device)
|
|
1159
1170
|
outputs_pt = wp.zeros(3, dtype=wptype, requires_grad=True, device=device)
|
|
1160
1171
|
outputs_pt_manual = wp.zeros(3, dtype=wptype, requires_grad=True, device=device)
|
|
1161
1172
|
outputs_vec = wp.zeros(3, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -1221,7 +1232,7 @@ def test_transform_point_vector(test, device, dtype, register_kernels=False):
|
|
|
1221
1232
|
|
|
1222
1233
|
|
|
1223
1234
|
def test_spatial_matrix_constructors(test, device, dtype, register_kernels=False):
|
|
1224
|
-
np.random.
|
|
1235
|
+
rng = np.random.default_rng(123)
|
|
1225
1236
|
|
|
1226
1237
|
tol = {
|
|
1227
1238
|
np.float16: 5.0e-3,
|
|
@@ -1294,7 +1305,7 @@ def test_spatial_matrix_constructors(test, device, dtype, register_kernels=False
|
|
|
1294
1305
|
if register_kernels:
|
|
1295
1306
|
return
|
|
1296
1307
|
|
|
1297
|
-
input = wp.array(
|
|
1308
|
+
input = wp.array(rng.standard_normal(size=6 * 6).astype(dtype), requires_grad=True, device=device)
|
|
1298
1309
|
output = wp.zeros(2 * 6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1299
1310
|
|
|
1300
1311
|
wp.launch(kernel, dim=1, inputs=[input], outputs=[output], device=device)
|
|
@@ -1317,7 +1328,7 @@ def test_spatial_matrix_constructors(test, device, dtype, register_kernels=False
|
|
|
1317
1328
|
|
|
1318
1329
|
|
|
1319
1330
|
def test_spatial_matrix_indexing(test, device, dtype, register_kernels=False):
|
|
1320
|
-
np.random.
|
|
1331
|
+
rng = np.random.default_rng(123)
|
|
1321
1332
|
|
|
1322
1333
|
tol = {
|
|
1323
1334
|
np.float16: 5.0e-3,
|
|
@@ -1347,7 +1358,9 @@ def test_spatial_matrix_indexing(test, device, dtype, register_kernels=False):
|
|
|
1347
1358
|
if register_kernels:
|
|
1348
1359
|
return
|
|
1349
1360
|
|
|
1350
|
-
input = wp.array(
|
|
1361
|
+
input = wp.array(
|
|
1362
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1363
|
+
)
|
|
1351
1364
|
outcmps = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1352
1365
|
|
|
1353
1366
|
wp.launch(kernel, dim=1, inputs=[input], outputs=[outcmps], device=device)
|
|
@@ -1370,7 +1383,7 @@ def test_spatial_matrix_indexing(test, device, dtype, register_kernels=False):
|
|
|
1370
1383
|
|
|
1371
1384
|
|
|
1372
1385
|
def test_spatial_matrix_scalar_multiplication(test, device, dtype, register_kernels=False):
|
|
1373
|
-
np.random.
|
|
1386
|
+
rng = np.random.default_rng(123)
|
|
1374
1387
|
|
|
1375
1388
|
tol = {
|
|
1376
1389
|
np.float16: 5.0e-3,
|
|
@@ -1404,8 +1417,10 @@ def test_spatial_matrix_scalar_multiplication(test, device, dtype, register_kern
|
|
|
1404
1417
|
if register_kernels:
|
|
1405
1418
|
return
|
|
1406
1419
|
|
|
1407
|
-
s = wp.array(
|
|
1408
|
-
q = wp.array(
|
|
1420
|
+
s = wp.array(rng.standard_normal(size=1).astype(dtype), requires_grad=True, device=device)
|
|
1421
|
+
q = wp.array(
|
|
1422
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1423
|
+
)
|
|
1409
1424
|
|
|
1410
1425
|
outcmps_l = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1411
1426
|
outcmps_r = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -1444,7 +1459,7 @@ def test_spatial_matrix_scalar_multiplication(test, device, dtype, register_kern
|
|
|
1444
1459
|
|
|
1445
1460
|
|
|
1446
1461
|
def test_spatial_matrix_add_sub(test, device, dtype, register_kernels=False):
|
|
1447
|
-
np.random.
|
|
1462
|
+
rng = np.random.default_rng(123)
|
|
1448
1463
|
|
|
1449
1464
|
tol = {
|
|
1450
1465
|
np.float16: 5.0e-3,
|
|
@@ -1476,8 +1491,12 @@ def test_spatial_matrix_add_sub(test, device, dtype, register_kernels=False):
|
|
|
1476
1491
|
if register_kernels:
|
|
1477
1492
|
return
|
|
1478
1493
|
|
|
1479
|
-
q = wp.array(
|
|
1480
|
-
|
|
1494
|
+
q = wp.array(
|
|
1495
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1496
|
+
)
|
|
1497
|
+
v = wp.array(
|
|
1498
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1499
|
+
)
|
|
1481
1500
|
|
|
1482
1501
|
outputs_add = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1483
1502
|
outputs_sub = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
@@ -1528,7 +1547,7 @@ def test_spatial_matrix_add_sub(test, device, dtype, register_kernels=False):
|
|
|
1528
1547
|
|
|
1529
1548
|
|
|
1530
1549
|
def test_spatial_matvec_multiplication(test, device, dtype, register_kernels=False):
|
|
1531
|
-
np.random.
|
|
1550
|
+
rng = np.random.default_rng(123)
|
|
1532
1551
|
|
|
1533
1552
|
tol = {
|
|
1534
1553
|
np.float16: 2.0e-2,
|
|
@@ -1560,8 +1579,12 @@ def test_spatial_matvec_multiplication(test, device, dtype, register_kernels=Fal
|
|
|
1560
1579
|
if register_kernels:
|
|
1561
1580
|
return
|
|
1562
1581
|
|
|
1563
|
-
v = wp.array(
|
|
1564
|
-
|
|
1582
|
+
v = wp.array(
|
|
1583
|
+
rng.standard_normal(size=(1, 6)).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device
|
|
1584
|
+
)
|
|
1585
|
+
m = wp.array(
|
|
1586
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1587
|
+
)
|
|
1565
1588
|
outcomponents = wp.zeros(6, dtype=wptype, requires_grad=True, device=device)
|
|
1566
1589
|
|
|
1567
1590
|
wp.launch(kernel, dim=1, inputs=[v, m], outputs=[outcomponents], device=device)
|
|
@@ -1585,7 +1608,7 @@ def test_spatial_matvec_multiplication(test, device, dtype, register_kernels=Fal
|
|
|
1585
1608
|
|
|
1586
1609
|
|
|
1587
1610
|
def test_spatial_matmat_multiplication(test, device, dtype, register_kernels=False):
|
|
1588
|
-
np.random.
|
|
1611
|
+
rng = np.random.default_rng(123)
|
|
1589
1612
|
|
|
1590
1613
|
tol = {
|
|
1591
1614
|
np.float16: 2.0e-2,
|
|
@@ -1617,8 +1640,12 @@ def test_spatial_matmat_multiplication(test, device, dtype, register_kernels=Fal
|
|
|
1617
1640
|
if register_kernels:
|
|
1618
1641
|
return
|
|
1619
1642
|
|
|
1620
|
-
v = wp.array(
|
|
1621
|
-
|
|
1643
|
+
v = wp.array(
|
|
1644
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1645
|
+
)
|
|
1646
|
+
m = wp.array(
|
|
1647
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1648
|
+
)
|
|
1622
1649
|
outcomponents = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1623
1650
|
|
|
1624
1651
|
wp.launch(kernel, dim=1, inputs=[v, m], outputs=[outcomponents], device=device)
|
|
@@ -1648,7 +1675,7 @@ def test_spatial_matmat_multiplication(test, device, dtype, register_kernels=Fal
|
|
|
1648
1675
|
|
|
1649
1676
|
|
|
1650
1677
|
def test_spatial_mat_transpose(test, device, dtype, register_kernels=False):
|
|
1651
|
-
np.random.
|
|
1678
|
+
rng = np.random.default_rng(123)
|
|
1652
1679
|
|
|
1653
1680
|
tol = {
|
|
1654
1681
|
np.float16: 1.0e-2,
|
|
@@ -1679,7 +1706,9 @@ def test_spatial_mat_transpose(test, device, dtype, register_kernels=False):
|
|
|
1679
1706
|
if register_kernels:
|
|
1680
1707
|
return
|
|
1681
1708
|
|
|
1682
|
-
m = wp.array(
|
|
1709
|
+
m = wp.array(
|
|
1710
|
+
rng.standard_normal(size=(1, 6, 6)).astype(dtype), dtype=spatial_matrix, requires_grad=True, device=device
|
|
1711
|
+
)
|
|
1683
1712
|
outcomponents = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1684
1713
|
|
|
1685
1714
|
wp.launch(kernel, dim=1, inputs=[m], outputs=[outcomponents], device=device)
|
|
@@ -1703,7 +1732,7 @@ def test_spatial_mat_transpose(test, device, dtype, register_kernels=False):
|
|
|
1703
1732
|
|
|
1704
1733
|
|
|
1705
1734
|
def test_spatial_outer_product(test, device, dtype, register_kernels=False):
|
|
1706
|
-
np.random.
|
|
1735
|
+
rng = np.random.default_rng(123)
|
|
1707
1736
|
|
|
1708
1737
|
tol = {
|
|
1709
1738
|
np.float16: 5.0e-3,
|
|
@@ -1735,8 +1764,12 @@ def test_spatial_outer_product(test, device, dtype, register_kernels=False):
|
|
|
1735
1764
|
if register_kernels:
|
|
1736
1765
|
return
|
|
1737
1766
|
|
|
1738
|
-
s = wp.array(
|
|
1739
|
-
|
|
1767
|
+
s = wp.array(
|
|
1768
|
+
rng.standard_normal(size=(1, 6)).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device
|
|
1769
|
+
)
|
|
1770
|
+
v = wp.array(
|
|
1771
|
+
rng.standard_normal(size=(1, 6)).astype(dtype), dtype=spatial_vector, requires_grad=True, device=device
|
|
1772
|
+
)
|
|
1740
1773
|
outcomponents = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1741
1774
|
|
|
1742
1775
|
wp.launch(kernel, dim=1, inputs=[s, v], outputs=[outcomponents], device=device)
|
|
@@ -1779,7 +1812,7 @@ def test_spatial_outer_product(test, device, dtype, register_kernels=False):
|
|
|
1779
1812
|
|
|
1780
1813
|
|
|
1781
1814
|
def test_spatial_adjoint(test, device, dtype, register_kernels=False):
|
|
1782
|
-
np.random.
|
|
1815
|
+
rng = np.random.default_rng(123)
|
|
1783
1816
|
|
|
1784
1817
|
tol = {
|
|
1785
1818
|
np.float16: 5.0e-3,
|
|
@@ -1811,8 +1844,8 @@ def test_spatial_adjoint(test, device, dtype, register_kernels=False):
|
|
|
1811
1844
|
if register_kernels:
|
|
1812
1845
|
return
|
|
1813
1846
|
|
|
1814
|
-
R = wp.array(
|
|
1815
|
-
S = wp.array(
|
|
1847
|
+
R = wp.array(rng.standard_normal(size=(1, 3, 3)).astype(dtype), dtype=mat3, requires_grad=True, device=device)
|
|
1848
|
+
S = wp.array(rng.standard_normal(size=(1, 3, 3)).astype(dtype), dtype=mat3, requires_grad=True, device=device)
|
|
1816
1849
|
outcomponents = wp.zeros(6 * 6, dtype=wptype, requires_grad=True, device=device)
|
|
1817
1850
|
|
|
1818
1851
|
wp.launch(kernel, dim=1, inputs=[R, S], outputs=[outcomponents], device=device)
|
|
@@ -1895,6 +1928,8 @@ def test_transform_identity(test, device, dtype, register_kernels=False):
|
|
|
1895
1928
|
|
|
1896
1929
|
|
|
1897
1930
|
def test_transform_anon_type_instance(test, device, dtype, register_kernels=False):
|
|
1931
|
+
rng = np.random.default_rng(123)
|
|
1932
|
+
|
|
1898
1933
|
wptype = wp.types.np_dtype_to_warp_type[np.dtype(dtype)]
|
|
1899
1934
|
|
|
1900
1935
|
def transform_create_test(input: wp.array(dtype=wptype), output: wp.array(dtype=wptype)):
|
|
@@ -1910,7 +1945,7 @@ def test_transform_anon_type_instance(test, device, dtype, register_kernels=Fals
|
|
|
1910
1945
|
if register_kernels:
|
|
1911
1946
|
return
|
|
1912
1947
|
|
|
1913
|
-
input = wp.array(
|
|
1948
|
+
input = wp.array(rng.standard_normal(size=7).astype(dtype), requires_grad=True, device=device)
|
|
1914
1949
|
output = wp.zeros(7, dtype=wptype, requires_grad=True, device=device)
|
|
1915
1950
|
wp.launch(transform_create_kernel, dim=1, inputs=[input], outputs=[output], device=device)
|
|
1916
1951
|
assert_np_equal(output.numpy(), 2 * input.numpy())
|
|
@@ -1928,188 +1963,186 @@ def test_transform_anon_type_instance(test, device, dtype, register_kernels=Fals
|
|
|
1928
1963
|
tape.zero()
|
|
1929
1964
|
|
|
1930
1965
|
|
|
1931
|
-
|
|
1932
|
-
devices = get_test_devices()
|
|
1966
|
+
devices = get_test_devices()
|
|
1933
1967
|
|
|
1934
|
-
class TestSpatial(parent):
|
|
1935
|
-
pass
|
|
1936
1968
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
TestSpatial,
|
|
1940
|
-
f"test_spatial_vector_constructors_{dtype.__name__}",
|
|
1941
|
-
test_spatial_vector_constructors,
|
|
1942
|
-
devices=devices,
|
|
1943
|
-
dtype=dtype,
|
|
1944
|
-
)
|
|
1945
|
-
add_function_test_register_kernel(
|
|
1946
|
-
TestSpatial,
|
|
1947
|
-
f"test_spatial_vector_indexing_{dtype.__name__}",
|
|
1948
|
-
test_spatial_vector_indexing,
|
|
1949
|
-
devices=devices,
|
|
1950
|
-
dtype=dtype,
|
|
1951
|
-
)
|
|
1952
|
-
add_function_test_register_kernel(
|
|
1953
|
-
TestSpatial,
|
|
1954
|
-
f"test_spatial_vector_scalar_multiplication_{dtype.__name__}",
|
|
1955
|
-
test_spatial_vector_scalar_multiplication,
|
|
1956
|
-
devices=devices,
|
|
1957
|
-
dtype=dtype,
|
|
1958
|
-
)
|
|
1959
|
-
add_function_test_register_kernel(
|
|
1960
|
-
TestSpatial,
|
|
1961
|
-
f"test_spatial_vector_add_sub_{dtype.__name__}",
|
|
1962
|
-
test_spatial_vector_add_sub,
|
|
1963
|
-
devices=devices,
|
|
1964
|
-
dtype=dtype,
|
|
1965
|
-
)
|
|
1966
|
-
add_function_test_register_kernel(
|
|
1967
|
-
TestSpatial, f"test_spatial_dot_{dtype.__name__}", test_spatial_dot, devices=devices, dtype=dtype
|
|
1968
|
-
)
|
|
1969
|
-
add_function_test_register_kernel(
|
|
1970
|
-
TestSpatial, f"test_spatial_cross_{dtype.__name__}", test_spatial_cross, devices=devices, dtype=dtype
|
|
1971
|
-
)
|
|
1972
|
-
add_function_test_register_kernel(
|
|
1973
|
-
TestSpatial,
|
|
1974
|
-
f"test_spatial_top_bottom_{dtype.__name__}",
|
|
1975
|
-
test_spatial_top_bottom,
|
|
1976
|
-
devices=devices,
|
|
1977
|
-
dtype=dtype,
|
|
1978
|
-
)
|
|
1969
|
+
class TestSpatial(unittest.TestCase):
|
|
1970
|
+
pass
|
|
1979
1971
|
|
|
1980
|
-
add_function_test_register_kernel(
|
|
1981
|
-
TestSpatial,
|
|
1982
|
-
f"test_transform_constructors_{dtype.__name__}",
|
|
1983
|
-
test_transform_constructors,
|
|
1984
|
-
devices=devices,
|
|
1985
|
-
dtype=dtype,
|
|
1986
|
-
)
|
|
1987
|
-
add_function_test_register_kernel(
|
|
1988
|
-
TestSpatial,
|
|
1989
|
-
f"test_transform_anon_type_instance_{dtype.__name__}",
|
|
1990
|
-
test_transform_anon_type_instance,
|
|
1991
|
-
devices=devices,
|
|
1992
|
-
dtype=dtype,
|
|
1993
|
-
)
|
|
1994
|
-
add_function_test_register_kernel(
|
|
1995
|
-
TestSpatial,
|
|
1996
|
-
f"test_transform_identity_{dtype.__name__}",
|
|
1997
|
-
test_transform_identity,
|
|
1998
|
-
devices=devices,
|
|
1999
|
-
dtype=dtype,
|
|
2000
|
-
)
|
|
2001
|
-
add_function_test_register_kernel(
|
|
2002
|
-
TestSpatial,
|
|
2003
|
-
f"test_transform_indexing_{dtype.__name__}",
|
|
2004
|
-
test_transform_indexing,
|
|
2005
|
-
devices=devices,
|
|
2006
|
-
dtype=dtype,
|
|
2007
|
-
)
|
|
2008
|
-
add_function_test_register_kernel(
|
|
2009
|
-
TestSpatial,
|
|
2010
|
-
f"test_transform_get_trans_rot_{dtype.__name__}",
|
|
2011
|
-
test_transform_get_trans_rot,
|
|
2012
|
-
devices=devices,
|
|
2013
|
-
dtype=dtype,
|
|
2014
|
-
)
|
|
2015
|
-
add_function_test_register_kernel(
|
|
2016
|
-
TestSpatial,
|
|
2017
|
-
f"test_transform_multiply_{dtype.__name__}",
|
|
2018
|
-
test_transform_multiply,
|
|
2019
|
-
devices=devices,
|
|
2020
|
-
dtype=dtype,
|
|
2021
|
-
)
|
|
2022
|
-
add_function_test_register_kernel(
|
|
2023
|
-
TestSpatial,
|
|
2024
|
-
f"test_transform_inverse_{dtype.__name__}",
|
|
2025
|
-
test_transform_inverse,
|
|
2026
|
-
devices=devices,
|
|
2027
|
-
dtype=dtype,
|
|
2028
|
-
)
|
|
2029
|
-
add_function_test_register_kernel(
|
|
2030
|
-
TestSpatial,
|
|
2031
|
-
f"test_transform_point_vector_{dtype.__name__}",
|
|
2032
|
-
test_transform_point_vector,
|
|
2033
|
-
devices=devices,
|
|
2034
|
-
dtype=dtype,
|
|
2035
|
-
)
|
|
2036
1972
|
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
1973
|
+
for dtype in np_float_types:
|
|
1974
|
+
add_function_test_register_kernel(
|
|
1975
|
+
TestSpatial,
|
|
1976
|
+
f"test_spatial_vector_constructors_{dtype.__name__}",
|
|
1977
|
+
test_spatial_vector_constructors,
|
|
1978
|
+
devices=devices,
|
|
1979
|
+
dtype=dtype,
|
|
1980
|
+
)
|
|
1981
|
+
add_function_test_register_kernel(
|
|
1982
|
+
TestSpatial,
|
|
1983
|
+
f"test_spatial_vector_indexing_{dtype.__name__}",
|
|
1984
|
+
test_spatial_vector_indexing,
|
|
1985
|
+
devices=devices,
|
|
1986
|
+
dtype=dtype,
|
|
1987
|
+
)
|
|
1988
|
+
add_function_test_register_kernel(
|
|
1989
|
+
TestSpatial,
|
|
1990
|
+
f"test_spatial_vector_scalar_multiplication_{dtype.__name__}",
|
|
1991
|
+
test_spatial_vector_scalar_multiplication,
|
|
1992
|
+
devices=devices,
|
|
1993
|
+
dtype=dtype,
|
|
1994
|
+
)
|
|
1995
|
+
add_function_test_register_kernel(
|
|
1996
|
+
TestSpatial,
|
|
1997
|
+
f"test_spatial_vector_add_sub_{dtype.__name__}",
|
|
1998
|
+
test_spatial_vector_add_sub,
|
|
1999
|
+
devices=devices,
|
|
2000
|
+
dtype=dtype,
|
|
2001
|
+
)
|
|
2002
|
+
add_function_test_register_kernel(
|
|
2003
|
+
TestSpatial, f"test_spatial_dot_{dtype.__name__}", test_spatial_dot, devices=devices, dtype=dtype
|
|
2004
|
+
)
|
|
2005
|
+
add_function_test_register_kernel(
|
|
2006
|
+
TestSpatial, f"test_spatial_cross_{dtype.__name__}", test_spatial_cross, devices=devices, dtype=dtype
|
|
2007
|
+
)
|
|
2008
|
+
add_function_test_register_kernel(
|
|
2009
|
+
TestSpatial,
|
|
2010
|
+
f"test_spatial_top_bottom_{dtype.__name__}",
|
|
2011
|
+
test_spatial_top_bottom,
|
|
2012
|
+
devices=devices,
|
|
2013
|
+
dtype=dtype,
|
|
2014
|
+
)
|
|
2053
2015
|
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2016
|
+
add_function_test_register_kernel(
|
|
2017
|
+
TestSpatial,
|
|
2018
|
+
f"test_transform_constructors_{dtype.__name__}",
|
|
2019
|
+
test_transform_constructors,
|
|
2020
|
+
devices=devices,
|
|
2021
|
+
dtype=dtype,
|
|
2022
|
+
)
|
|
2023
|
+
add_function_test_register_kernel(
|
|
2024
|
+
TestSpatial,
|
|
2025
|
+
f"test_transform_anon_type_instance_{dtype.__name__}",
|
|
2026
|
+
test_transform_anon_type_instance,
|
|
2027
|
+
devices=devices,
|
|
2028
|
+
dtype=dtype,
|
|
2029
|
+
)
|
|
2030
|
+
add_function_test_register_kernel(
|
|
2031
|
+
TestSpatial,
|
|
2032
|
+
f"test_transform_identity_{dtype.__name__}",
|
|
2033
|
+
test_transform_identity,
|
|
2034
|
+
devices=devices,
|
|
2035
|
+
dtype=dtype,
|
|
2036
|
+
)
|
|
2037
|
+
add_function_test_register_kernel(
|
|
2038
|
+
TestSpatial,
|
|
2039
|
+
f"test_transform_indexing_{dtype.__name__}",
|
|
2040
|
+
test_transform_indexing,
|
|
2041
|
+
devices=devices,
|
|
2042
|
+
dtype=dtype,
|
|
2043
|
+
)
|
|
2044
|
+
add_function_test_register_kernel(
|
|
2045
|
+
TestSpatial,
|
|
2046
|
+
f"test_transform_get_trans_rot_{dtype.__name__}",
|
|
2047
|
+
test_transform_get_trans_rot,
|
|
2048
|
+
devices=devices,
|
|
2049
|
+
dtype=dtype,
|
|
2050
|
+
)
|
|
2051
|
+
add_function_test_register_kernel(
|
|
2052
|
+
TestSpatial,
|
|
2053
|
+
f"test_transform_multiply_{dtype.__name__}",
|
|
2054
|
+
test_transform_multiply,
|
|
2055
|
+
devices=devices,
|
|
2056
|
+
dtype=dtype,
|
|
2057
|
+
)
|
|
2058
|
+
add_function_test_register_kernel(
|
|
2059
|
+
TestSpatial,
|
|
2060
|
+
f"test_transform_inverse_{dtype.__name__}",
|
|
2061
|
+
test_transform_inverse,
|
|
2062
|
+
devices=devices,
|
|
2063
|
+
dtype=dtype,
|
|
2064
|
+
)
|
|
2065
|
+
add_function_test_register_kernel(
|
|
2066
|
+
TestSpatial,
|
|
2067
|
+
f"test_transform_point_vector_{dtype.__name__}",
|
|
2068
|
+
test_transform_point_vector,
|
|
2069
|
+
devices=devices,
|
|
2070
|
+
dtype=dtype,
|
|
2071
|
+
)
|
|
2072
|
+
|
|
2073
|
+
# are these two valid? They don't seem to be doing things you'd want to do,
|
|
2074
|
+
# maybe they should be removed
|
|
2075
|
+
add_function_test_register_kernel(
|
|
2076
|
+
TestSpatial,
|
|
2077
|
+
f"test_transform_scalar_multiplication_{dtype.__name__}",
|
|
2078
|
+
test_transform_scalar_multiplication,
|
|
2079
|
+
devices=devices,
|
|
2080
|
+
dtype=dtype,
|
|
2081
|
+
)
|
|
2082
|
+
add_function_test_register_kernel(
|
|
2083
|
+
TestSpatial,
|
|
2084
|
+
f"test_transform_add_sub_{dtype.__name__}",
|
|
2085
|
+
test_transform_add_sub,
|
|
2086
|
+
devices=devices,
|
|
2087
|
+
dtype=dtype,
|
|
2088
|
+
)
|
|
2106
2089
|
|
|
2107
|
-
|
|
2090
|
+
add_function_test_register_kernel(
|
|
2091
|
+
TestSpatial,
|
|
2092
|
+
f"test_spatial_matrix_constructors_{dtype.__name__}",
|
|
2093
|
+
test_spatial_matrix_constructors,
|
|
2094
|
+
devices=devices,
|
|
2095
|
+
dtype=dtype,
|
|
2096
|
+
)
|
|
2097
|
+
add_function_test_register_kernel(
|
|
2098
|
+
TestSpatial,
|
|
2099
|
+
f"test_spatial_matrix_indexing_{dtype.__name__}",
|
|
2100
|
+
test_spatial_matrix_indexing,
|
|
2101
|
+
devices=devices,
|
|
2102
|
+
dtype=dtype,
|
|
2103
|
+
)
|
|
2104
|
+
add_function_test_register_kernel(
|
|
2105
|
+
TestSpatial,
|
|
2106
|
+
f"test_spatial_matrix_scalar_multiplication_{dtype.__name__}",
|
|
2107
|
+
test_spatial_matrix_scalar_multiplication,
|
|
2108
|
+
devices=devices,
|
|
2109
|
+
dtype=dtype,
|
|
2110
|
+
)
|
|
2111
|
+
add_function_test_register_kernel(
|
|
2112
|
+
TestSpatial,
|
|
2113
|
+
f"test_spatial_matrix_add_sub_{dtype.__name__}",
|
|
2114
|
+
test_spatial_matrix_add_sub,
|
|
2115
|
+
devices=devices,
|
|
2116
|
+
dtype=dtype,
|
|
2117
|
+
)
|
|
2118
|
+
add_function_test_register_kernel(
|
|
2119
|
+
TestSpatial,
|
|
2120
|
+
f"test_spatial_matvec_multiplication_{dtype.__name__}",
|
|
2121
|
+
test_spatial_matvec_multiplication,
|
|
2122
|
+
devices=devices,
|
|
2123
|
+
dtype=dtype,
|
|
2124
|
+
)
|
|
2125
|
+
add_function_test_register_kernel(
|
|
2126
|
+
TestSpatial,
|
|
2127
|
+
f"test_spatial_matmat_multiplication_{dtype.__name__}",
|
|
2128
|
+
test_spatial_matmat_multiplication,
|
|
2129
|
+
devices=devices,
|
|
2130
|
+
dtype=dtype,
|
|
2131
|
+
)
|
|
2132
|
+
add_function_test_register_kernel(
|
|
2133
|
+
TestSpatial,
|
|
2134
|
+
f"test_spatial_outer_product_{dtype.__name__}",
|
|
2135
|
+
test_spatial_outer_product,
|
|
2136
|
+
devices=devices,
|
|
2137
|
+
dtype=dtype,
|
|
2138
|
+
)
|
|
2139
|
+
add_function_test_register_kernel(
|
|
2140
|
+
TestSpatial, f"test_spatial_adjoint_{dtype.__name__}", test_spatial_adjoint, devices=devices, dtype=dtype
|
|
2141
|
+
)
|
|
2108
2142
|
|
|
2109
|
-
|
|
2143
|
+
# \TODO: test spatial_mass and spatial_jacobian
|
|
2110
2144
|
|
|
2111
2145
|
|
|
2112
2146
|
if __name__ == "__main__":
|
|
2113
2147
|
wp.build.clear_kernel_cache()
|
|
2114
|
-
c = register(unittest.TestCase)
|
|
2115
2148
|
unittest.main(verbosity=2)
|