warp-lang 1.0.0b5__py3-none-manylinux2014_x86_64.whl → 1.0.0b6__py3-none-manylinux2014_x86_64.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.
- docs/conf.py +3 -4
- examples/env/env_ant.py +1 -1
- examples/env/env_cartpole.py +1 -1
- examples/env/env_humanoid.py +1 -1
- examples/example_dem.py +28 -26
- examples/example_diffray.py +37 -30
- examples/example_fluid.py +7 -3
- examples/example_jacobian_ik.py +1 -1
- examples/example_mesh_intersect.py +10 -7
- examples/example_nvdb.py +3 -3
- examples/example_render_opengl.py +19 -10
- examples/example_sim_cartpole.py +9 -5
- examples/example_sim_cloth.py +29 -25
- examples/example_sim_fk_grad.py +2 -2
- examples/example_sim_fk_grad_torch.py +3 -3
- examples/example_sim_grad_bounce.py +11 -8
- examples/example_sim_grad_cloth.py +12 -9
- examples/example_sim_granular.py +2 -2
- examples/example_sim_granular_collision_sdf.py +13 -13
- examples/example_sim_neo_hookean.py +3 -3
- examples/example_sim_particle_chain.py +2 -2
- examples/example_sim_quadruped.py +8 -5
- examples/example_sim_rigid_chain.py +8 -5
- examples/example_sim_rigid_contact.py +13 -10
- examples/example_sim_rigid_fem.py +2 -2
- examples/example_sim_rigid_gyroscopic.py +2 -2
- examples/example_sim_rigid_kinematics.py +1 -1
- examples/example_sim_trajopt.py +3 -2
- examples/fem/example_apic_fluid.py +5 -7
- examples/fem/example_diffusion_mgpu.py +18 -16
- warp/__init__.py +3 -2
- warp/bin/warp.so +0 -0
- warp/build_dll.py +29 -9
- warp/builtins.py +206 -7
- warp/codegen.py +58 -38
- warp/config.py +3 -1
- warp/context.py +234 -128
- warp/fem/__init__.py +2 -2
- warp/fem/cache.py +2 -1
- warp/fem/field/nodal_field.py +18 -17
- warp/fem/geometry/hexmesh.py +11 -6
- warp/fem/geometry/quadmesh_2d.py +16 -12
- warp/fem/geometry/tetmesh.py +19 -8
- warp/fem/geometry/trimesh_2d.py +18 -7
- warp/fem/integrate.py +341 -196
- warp/fem/quadrature/__init__.py +1 -1
- warp/fem/quadrature/pic_quadrature.py +138 -53
- warp/fem/quadrature/quadrature.py +81 -9
- warp/fem/space/__init__.py +1 -1
- warp/fem/space/basis_space.py +169 -51
- warp/fem/space/grid_2d_function_space.py +2 -2
- warp/fem/space/grid_3d_function_space.py +2 -2
- warp/fem/space/hexmesh_function_space.py +2 -2
- warp/fem/space/partition.py +9 -6
- warp/fem/space/quadmesh_2d_function_space.py +2 -2
- warp/fem/space/shape/cube_shape_function.py +27 -15
- warp/fem/space/shape/square_shape_function.py +29 -18
- warp/fem/space/tetmesh_function_space.py +2 -2
- warp/fem/space/topology.py +10 -0
- warp/fem/space/trimesh_2d_function_space.py +2 -2
- warp/fem/utils.py +10 -5
- warp/native/array.h +49 -8
- warp/native/builtin.h +31 -14
- warp/native/cuda_util.cpp +8 -3
- warp/native/cuda_util.h +1 -0
- warp/native/exports.h +1177 -1108
- warp/native/intersect.h +4 -4
- warp/native/intersect_adj.h +8 -8
- warp/native/mat.h +65 -6
- warp/native/mesh.h +126 -5
- warp/native/quat.h +28 -4
- warp/native/vec.h +76 -14
- warp/native/warp.cu +1 -6
- warp/render/render_opengl.py +261 -109
- warp/sim/import_mjcf.py +13 -7
- warp/sim/import_urdf.py +14 -14
- warp/sim/inertia.py +17 -18
- warp/sim/model.py +67 -67
- warp/sim/render.py +1 -1
- warp/sparse.py +6 -6
- warp/stubs.py +19 -81
- warp/tape.py +1 -1
- warp/tests/__main__.py +3 -6
- 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/{test_kinematics.py → disabled_kinematics.py} +10 -12
- warp/tests/run_coverage_serial.py +31 -0
- warp/tests/test_adam.py +102 -106
- warp/tests/test_arithmetic.py +39 -40
- warp/tests/test_array.py +46 -48
- warp/tests/test_array_reduce.py +25 -19
- warp/tests/test_atomic.py +62 -26
- warp/tests/test_bool.py +16 -11
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +9 -12
- warp/tests/test_closest_point_edge_edge.py +53 -57
- warp/tests/test_codegen.py +164 -134
- warp/tests/test_compile_consts.py +13 -19
- warp/tests/test_conditional.py +30 -32
- warp/tests/test_copy.py +9 -12
- warp/tests/test_ctypes.py +90 -98
- warp/tests/test_dense.py +20 -14
- warp/tests/test_devices.py +34 -35
- warp/tests/test_dlpack.py +74 -75
- warp/tests/test_examples.py +215 -97
- warp/tests/test_fabricarray.py +15 -21
- warp/tests/test_fast_math.py +14 -11
- warp/tests/test_fem.py +280 -97
- warp/tests/test_fp16.py +19 -15
- warp/tests/test_func.py +177 -194
- warp/tests/test_generics.py +71 -77
- warp/tests/test_grad.py +83 -32
- warp/tests/test_grad_customs.py +7 -9
- warp/tests/test_hash_grid.py +6 -10
- warp/tests/test_import.py +9 -23
- warp/tests/test_indexedarray.py +19 -21
- warp/tests/test_intersect.py +15 -9
- warp/tests/test_large.py +17 -19
- warp/tests/test_launch.py +14 -17
- warp/tests/test_lerp.py +63 -63
- warp/tests/test_lvalue.py +84 -35
- warp/tests/test_marching_cubes.py +9 -13
- warp/tests/test_mat.py +388 -3004
- warp/tests/test_mat_lite.py +9 -12
- warp/tests/test_mat_scalar_ops.py +2889 -0
- warp/tests/test_math.py +10 -11
- warp/tests/test_matmul.py +104 -100
- warp/tests/test_matmul_lite.py +72 -98
- warp/tests/test_mesh.py +35 -32
- warp/tests/test_mesh_query_aabb.py +18 -25
- warp/tests/test_mesh_query_point.py +39 -23
- warp/tests/test_mesh_query_ray.py +9 -21
- warp/tests/test_mlp.py +8 -9
- warp/tests/test_model.py +89 -93
- warp/tests/test_modules_lite.py +15 -25
- warp/tests/test_multigpu.py +87 -114
- warp/tests/test_noise.py +10 -12
- warp/tests/test_operators.py +14 -21
- warp/tests/test_options.py +10 -11
- warp/tests/test_pinned.py +16 -18
- warp/tests/test_print.py +16 -20
- warp/tests/test_quat.py +121 -88
- warp/tests/test_rand.py +12 -13
- warp/tests/test_reload.py +27 -32
- warp/tests/test_rounding.py +7 -10
- warp/tests/test_runlength_encode.py +105 -106
- warp/tests/test_smoothstep.py +8 -9
- warp/tests/test_snippet.py +13 -22
- warp/tests/test_sparse.py +30 -29
- warp/tests/test_spatial.py +179 -174
- warp/tests/test_streams.py +100 -107
- warp/tests/test_struct.py +98 -67
- warp/tests/test_tape.py +11 -17
- warp/tests/test_torch.py +89 -86
- warp/tests/test_transient_module.py +9 -12
- warp/tests/test_types.py +328 -50
- warp/tests/test_utils.py +217 -218
- warp/tests/test_vec.py +133 -2133
- warp/tests/test_vec_lite.py +8 -11
- warp/tests/test_vec_scalar_ops.py +2099 -0
- warp/tests/test_volume.py +391 -382
- warp/tests/test_volume_write.py +122 -135
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +291 -0
- warp/tests/{test_base.py → unittest_utils.py} +138 -25
- warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
- warp/tests/{test_debug.py → walkthough_debug.py} +2 -15
- warp/thirdparty/unittest_parallel.py +257 -54
- warp/types.py +119 -98
- warp/utils.py +14 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/METADATA +2 -1
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/RECORD +182 -178
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
- warp/tests/test_all.py +0 -239
- warp/tests/test_conditional_unequal_types_kernels.py +0 -14
- warp/tests/test_coverage.py +0 -38
- warp/tests/test_unresolved_func.py +0 -7
- warp/tests/test_unresolved_symbol.py +0 -7
- /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.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
warp/tests/test_volume.py
CHANGED
|
@@ -10,7 +10,7 @@ import unittest
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
|
|
12
12
|
import warp as wp
|
|
13
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
14
14
|
|
|
15
15
|
wp.init()
|
|
16
16
|
|
|
@@ -330,398 +330,407 @@ def test_volume_store_i(volume: wp.uint64, points: wp.array(dtype=wp.vec3), valu
|
|
|
330
330
|
values[tid] = wp.volume_lookup_i(volume, i, j, k)
|
|
331
331
|
|
|
332
332
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
333
|
+
devices = get_test_devices()
|
|
334
|
+
rng = np.random.default_rng(101215)
|
|
335
|
+
|
|
336
|
+
# Note about the test grids:
|
|
337
|
+
# test_grid and test_int32_grid
|
|
338
|
+
# active region: [-10,10]^3
|
|
339
|
+
# values: v[i,j,k] = i * j * k
|
|
340
|
+
# voxel size: 0.25
|
|
341
|
+
#
|
|
342
|
+
# test_vec_grid
|
|
343
|
+
# active region: [-10,10]^3
|
|
344
|
+
# values: v[i,j,k] = (i + 2*j + 3*k, 4*i + 5*j + 6*k, 7*i + 8*j + 9*k)
|
|
345
|
+
# voxel size: 0.25
|
|
346
|
+
#
|
|
347
|
+
# torus
|
|
348
|
+
# index to world transformation:
|
|
349
|
+
# [0.1, 0, 0, 0]
|
|
350
|
+
# [0, 0, 0.1, 0]
|
|
351
|
+
# [0, 0.1, 0, 0]
|
|
352
|
+
# [1, 2, 3, 1]
|
|
353
|
+
# (-90 degrees rotation along X)
|
|
354
|
+
# voxel size: 0.1
|
|
355
|
+
volume_paths = {
|
|
356
|
+
"float": os.path.abspath(os.path.join(os.path.dirname(__file__), "assets/test_grid.nvdb")),
|
|
357
|
+
"int32": os.path.abspath(os.path.join(os.path.dirname(__file__), "assets/test_int32_grid.nvdb")),
|
|
358
|
+
"vec3f": os.path.abspath(os.path.join(os.path.dirname(__file__), "assets/test_vec_grid.nvdb")),
|
|
359
|
+
"torus": os.path.abspath(os.path.join(os.path.dirname(__file__), "assets/torus.nvdb")),
|
|
360
|
+
"float_write": os.path.abspath(os.path.join(os.path.dirname(__file__), "assets/test_grid.nvdb")),
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
test_volume_tiles = (
|
|
364
|
+
np.array([[i, j, k] for i in range(-2, 2) for j in range(-2, 2) for k in range(-2, 2)], dtype=np.int32) * 8
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
volumes = {}
|
|
368
|
+
for value_type, path in volume_paths.items():
|
|
369
|
+
volumes[value_type] = {}
|
|
370
|
+
volume_data = open(path, "rb").read()
|
|
371
|
+
for device in devices:
|
|
372
|
+
try:
|
|
373
|
+
volume = wp.Volume.load_from_nvdb(volume_data, device)
|
|
374
|
+
except RuntimeError as e:
|
|
375
|
+
raise RuntimeError(f'Failed to load volume from "{path}" to {device} memory:\n{e}')
|
|
376
|
+
|
|
377
|
+
volumes[value_type][device.alias] = volume
|
|
378
|
+
|
|
379
|
+
axis = np.linspace(-1, 1, 3)
|
|
380
|
+
point_grid = np.array([[x, y, z] for x in axis for y in axis for z in axis], dtype=np.float32)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def test_volume_sample_linear_f_gradient(test, device):
|
|
384
|
+
points = rng.uniform(-10.0, 10.0, size=(100, 3))
|
|
385
|
+
values = wp.array(np.zeros(1), dtype=wp.float32, device=device, requires_grad=True)
|
|
386
|
+
for test_case in points:
|
|
387
|
+
uvws = wp.array(test_case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
388
|
+
xyzs = wp.array(test_case * 0.25, dtype=wp.vec3, device=device, requires_grad=True)
|
|
389
|
+
|
|
390
|
+
tape = wp.Tape()
|
|
391
|
+
with tape:
|
|
392
|
+
wp.launch(
|
|
393
|
+
test_volume_sample_local_f_linear_values,
|
|
394
|
+
dim=1,
|
|
395
|
+
inputs=[volumes["float"][device.alias].id, uvws, values],
|
|
396
|
+
device=device,
|
|
397
|
+
)
|
|
398
|
+
tape.backward(values)
|
|
399
|
+
|
|
400
|
+
x, y, z = test_case
|
|
401
|
+
grad_expected = np.array([y * z, x * z, x * y])
|
|
402
|
+
grad_computed = tape.gradients[uvws].numpy()[0]
|
|
403
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
404
|
+
|
|
405
|
+
tape = wp.Tape()
|
|
406
|
+
with tape:
|
|
407
|
+
wp.launch(
|
|
408
|
+
test_volume_sample_world_f_linear_values,
|
|
409
|
+
dim=1,
|
|
410
|
+
inputs=[volumes["float"][device.alias].id, xyzs, values],
|
|
411
|
+
device=device,
|
|
412
|
+
)
|
|
413
|
+
tape.backward(values)
|
|
367
414
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
volumes[value_type] = {}
|
|
373
|
-
volume_data = open(path, "rb").read()
|
|
374
|
-
for device in devices:
|
|
375
|
-
try:
|
|
376
|
-
volume = wp.Volume.load_from_nvdb(volume_data, device)
|
|
377
|
-
except RuntimeError as e:
|
|
378
|
-
raise RuntimeError(f'Failed to load volume from "{path}" to {device} memory:\n{e}')
|
|
379
|
-
|
|
380
|
-
volumes[value_type][device.alias] = volume
|
|
381
|
-
|
|
382
|
-
axis = np.linspace(-1, 1, 3)
|
|
383
|
-
point_grid = np.array([[x, y, z] for x in axis for y in axis for z in axis], dtype=np.float32)
|
|
384
|
-
|
|
385
|
-
class TestVolumes(parent):
|
|
386
|
-
def test_volume_sample_linear_f_gradient(self):
|
|
387
|
-
for device in devices:
|
|
388
|
-
points = rng.uniform(-10.0, 10.0, size=(100, 3))
|
|
389
|
-
values = wp.array(np.zeros(1), dtype=wp.float32, device=device, requires_grad=True)
|
|
390
|
-
for case in points:
|
|
391
|
-
uvws = wp.array(case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
392
|
-
xyzs = wp.array(case * 0.25, dtype=wp.vec3, device=device, requires_grad=True)
|
|
393
|
-
|
|
394
|
-
tape = wp.Tape()
|
|
395
|
-
with tape:
|
|
396
|
-
wp.launch(
|
|
397
|
-
test_volume_sample_local_f_linear_values,
|
|
398
|
-
dim=1,
|
|
399
|
-
inputs=[volumes["float"][device.alias].id, uvws, values],
|
|
400
|
-
device=device,
|
|
401
|
-
)
|
|
402
|
-
tape.backward(values)
|
|
403
|
-
|
|
404
|
-
x, y, z = case
|
|
405
|
-
grad_expected = np.array([y * z, x * z, x * y])
|
|
406
|
-
grad_computed = tape.gradients[uvws].numpy()[0]
|
|
407
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
408
|
-
|
|
409
|
-
tape = wp.Tape()
|
|
410
|
-
with tape:
|
|
411
|
-
wp.launch(
|
|
412
|
-
test_volume_sample_world_f_linear_values,
|
|
413
|
-
dim=1,
|
|
414
|
-
inputs=[volumes["float"][device.alias].id, xyzs, values],
|
|
415
|
-
device=device,
|
|
416
|
-
)
|
|
417
|
-
tape.backward(values)
|
|
418
|
-
|
|
419
|
-
x, y, z = case
|
|
420
|
-
grad_expected = np.array([y * z, x * z, x * y]) / 0.25
|
|
421
|
-
grad_computed = tape.gradients[xyzs].numpy()[0]
|
|
422
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
423
|
-
|
|
424
|
-
def test_volume_sample_grad_linear_f_gradient(self):
|
|
425
|
-
for device in devices:
|
|
426
|
-
points = rng.uniform(-10.0, 10.0, size=(100, 3))
|
|
427
|
-
values = wp.array(np.zeros(1), dtype=wp.float32, device=device, requires_grad=True)
|
|
428
|
-
for case in points:
|
|
429
|
-
uvws = wp.array(case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
430
|
-
xyzs = wp.array(case * 0.25, dtype=wp.vec3, device=device, requires_grad=True)
|
|
431
|
-
|
|
432
|
-
for case_num in range(4):
|
|
433
|
-
tape = wp.Tape()
|
|
434
|
-
with tape:
|
|
435
|
-
wp.launch(
|
|
436
|
-
test_volume_sample_grad_local_f_linear_values,
|
|
437
|
-
dim=1,
|
|
438
|
-
inputs=[volumes["float"][device.alias].id, uvws, values, case_num],
|
|
439
|
-
device=device,
|
|
440
|
-
)
|
|
441
|
-
tape.backward(values)
|
|
442
|
-
|
|
443
|
-
x, y, z = case
|
|
444
|
-
grad_computed = tape.gradients[uvws].numpy()[0]
|
|
445
|
-
if case_num == 0:
|
|
446
|
-
grad_expected = np.array([y * z, x * z, x * y])
|
|
447
|
-
elif case_num == 1:
|
|
448
|
-
grad_expected = np.array([0.0, z, y])
|
|
449
|
-
elif case_num == 2:
|
|
450
|
-
grad_expected = np.array([z, 0.0, x])
|
|
451
|
-
elif case_num == 3:
|
|
452
|
-
grad_expected = np.array([y, x, 0.0])
|
|
453
|
-
|
|
454
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
455
|
-
tape.zero()
|
|
456
|
-
|
|
457
|
-
for case_num in range(4):
|
|
458
|
-
tape = wp.Tape()
|
|
459
|
-
with tape:
|
|
460
|
-
wp.launch(
|
|
461
|
-
test_volume_sample_grad_world_f_linear_values,
|
|
462
|
-
dim=1,
|
|
463
|
-
inputs=[volumes["float"][device.alias].id, xyzs, values, case_num],
|
|
464
|
-
device=device,
|
|
465
|
-
)
|
|
466
|
-
tape.backward(values)
|
|
467
|
-
|
|
468
|
-
x, y, z = case
|
|
469
|
-
grad_computed = tape.gradients[xyzs].numpy()[0]
|
|
470
|
-
if case_num == 0:
|
|
471
|
-
grad_expected = np.array([y * z, x * z, x * y]) / 0.25
|
|
472
|
-
elif case_num == 1:
|
|
473
|
-
grad_expected = np.array([0.0, z, y]) / 0.25
|
|
474
|
-
elif case_num == 2:
|
|
475
|
-
grad_expected = np.array([z, 0.0, x]) / 0.25
|
|
476
|
-
elif case_num == 3:
|
|
477
|
-
grad_expected = np.array([y, x, 0.0]) / 0.25
|
|
478
|
-
|
|
479
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
480
|
-
tape.zero()
|
|
481
|
-
|
|
482
|
-
def test_volume_sample_linear_v_gradient(self):
|
|
483
|
-
for device in devices:
|
|
484
|
-
points = rng.uniform(-10.0, 10.0, size=(100, 3))
|
|
485
|
-
values = wp.zeros(1, dtype=wp.float32, device=device, requires_grad=True)
|
|
486
|
-
for case in points:
|
|
487
|
-
uvws = wp.array(case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
488
|
-
xyzs = wp.array(case * 0.25, dtype=wp.vec3, device=device, requires_grad=True)
|
|
489
|
-
|
|
490
|
-
tape = wp.Tape()
|
|
491
|
-
with tape:
|
|
492
|
-
wp.launch(
|
|
493
|
-
test_volume_sample_local_v_linear_values,
|
|
494
|
-
dim=1,
|
|
495
|
-
inputs=[volumes["vec3f"][device.alias].id, uvws, values],
|
|
496
|
-
device=device,
|
|
497
|
-
)
|
|
498
|
-
tape.backward(values)
|
|
499
|
-
|
|
500
|
-
grad_expected = np.array([6.0, 15.0, 24.0])
|
|
501
|
-
grad_computed = tape.gradients[uvws].numpy()[0]
|
|
502
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
503
|
-
|
|
504
|
-
tape = wp.Tape()
|
|
505
|
-
with tape:
|
|
506
|
-
wp.launch(
|
|
507
|
-
test_volume_sample_world_v_linear_values,
|
|
508
|
-
dim=1,
|
|
509
|
-
inputs=[volumes["vec3f"][device.alias].id, xyzs, values],
|
|
510
|
-
device=device,
|
|
511
|
-
)
|
|
512
|
-
tape.backward(values)
|
|
513
|
-
|
|
514
|
-
grad_expected = np.array([6.0, 15.0, 24.0]) / 0.25
|
|
515
|
-
grad_computed = tape.gradients[xyzs].numpy()[0]
|
|
516
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
517
|
-
|
|
518
|
-
def test_volume_transform_gradient(self):
|
|
519
|
-
for device in devices:
|
|
520
|
-
values = wp.zeros(1, dtype=wp.float32, device=device, requires_grad=True)
|
|
521
|
-
grad_values = wp.zeros(1, dtype=wp.vec3, device=device)
|
|
522
|
-
points = rng.uniform(-10.0, 10.0, size=(10, 3))
|
|
523
|
-
for case in points:
|
|
524
|
-
points = wp.array(case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
525
|
-
tape = wp.Tape()
|
|
526
|
-
with tape:
|
|
527
|
-
wp.launch(
|
|
528
|
-
test_volume_index_to_world,
|
|
529
|
-
dim=1,
|
|
530
|
-
inputs=[volumes["torus"][device.alias].id, points, values, grad_values],
|
|
531
|
-
device=device,
|
|
532
|
-
)
|
|
533
|
-
tape.backward(values)
|
|
534
|
-
|
|
535
|
-
grad_computed = tape.gradients[points].numpy()
|
|
536
|
-
grad_expected = grad_values.numpy()
|
|
537
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
538
|
-
|
|
539
|
-
grad_computed = tape.gradients[points].numpy()
|
|
540
|
-
grad_expected = grad_values.numpy()
|
|
541
|
-
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
542
|
-
|
|
543
|
-
def test_volume_store(self):
|
|
544
|
-
values_ref = np.array([x + 100 * y + 10000 * z for x, y, z in point_grid])
|
|
545
|
-
for device in devices:
|
|
546
|
-
points = wp.array(point_grid, dtype=wp.vec3, device=device)
|
|
547
|
-
values = wp.empty(len(point_grid), dtype=wp.float32, device=device)
|
|
548
|
-
wp.launch(
|
|
549
|
-
test_volume_store_f,
|
|
550
|
-
dim=len(point_grid),
|
|
551
|
-
inputs=[volumes["float_write"][device.alias].id, points, values],
|
|
552
|
-
device=device,
|
|
553
|
-
)
|
|
415
|
+
x, y, z = test_case
|
|
416
|
+
grad_expected = np.array([y * z, x * z, x * y]) / 0.25
|
|
417
|
+
grad_computed = tape.gradients[xyzs].numpy()[0]
|
|
418
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
554
419
|
|
|
555
|
-
values_res = values.numpy()
|
|
556
|
-
np.testing.assert_equal(values_res, values_ref)
|
|
557
420
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
continue
|
|
421
|
+
def test_volume_sample_grad_linear_f_gradient(test, device):
|
|
422
|
+
points = rng.uniform(-10.0, 10.0, size=(100, 3))
|
|
423
|
+
values = wp.array(np.zeros(1), dtype=wp.float32, device=device, requires_grad=True)
|
|
424
|
+
for test_case in points:
|
|
425
|
+
uvws = wp.array(test_case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
426
|
+
xyzs = wp.array(test_case * 0.25, dtype=wp.vec3, device=device, requires_grad=True)
|
|
565
427
|
|
|
566
|
-
|
|
567
|
-
|
|
428
|
+
for case_num in range(4):
|
|
429
|
+
tape = wp.Tape()
|
|
430
|
+
with tape:
|
|
431
|
+
wp.launch(
|
|
432
|
+
test_volume_sample_grad_local_f_linear_values,
|
|
433
|
+
dim=1,
|
|
434
|
+
inputs=[volumes["float"][device.alias].id, uvws, values, case_num],
|
|
435
|
+
device=device,
|
|
568
436
|
)
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
np.
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
437
|
+
tape.backward(values)
|
|
438
|
+
|
|
439
|
+
x, y, z = test_case
|
|
440
|
+
grad_computed = tape.gradients[uvws].numpy()[0]
|
|
441
|
+
if case_num == 0:
|
|
442
|
+
grad_expected = np.array([y * z, x * z, x * y])
|
|
443
|
+
elif case_num == 1:
|
|
444
|
+
grad_expected = np.array([0.0, z, y])
|
|
445
|
+
elif case_num == 2:
|
|
446
|
+
grad_expected = np.array([z, 0.0, x])
|
|
447
|
+
elif case_num == 3:
|
|
448
|
+
grad_expected = np.array([y, x, 0.0])
|
|
449
|
+
|
|
450
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
451
|
+
tape.zero()
|
|
452
|
+
|
|
453
|
+
for case_num in range(4):
|
|
454
|
+
tape = wp.Tape()
|
|
455
|
+
with tape:
|
|
456
|
+
wp.launch(
|
|
457
|
+
test_volume_sample_grad_world_f_linear_values,
|
|
458
|
+
dim=1,
|
|
459
|
+
inputs=[volumes["float"][device.alias].id, xyzs, values, case_num],
|
|
460
|
+
device=device,
|
|
586
461
|
)
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
np.
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
np.array([
|
|
462
|
+
tape.backward(values)
|
|
463
|
+
|
|
464
|
+
x, y, z = test_case
|
|
465
|
+
grad_computed = tape.gradients[xyzs].numpy()[0]
|
|
466
|
+
if case_num == 0:
|
|
467
|
+
grad_expected = np.array([y * z, x * z, x * y]) / 0.25
|
|
468
|
+
elif case_num == 1:
|
|
469
|
+
grad_expected = np.array([0.0, z, y]) / 0.25
|
|
470
|
+
elif case_num == 2:
|
|
471
|
+
grad_expected = np.array([z, 0.0, x]) / 0.25
|
|
472
|
+
elif case_num == 3:
|
|
473
|
+
grad_expected = np.array([y, x, 0.0]) / 0.25
|
|
474
|
+
|
|
475
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
476
|
+
tape.zero()
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def test_volume_sample_linear_v_gradient(test, device):
|
|
480
|
+
points = rng.uniform(-10.0, 10.0, size=(100, 3))
|
|
481
|
+
values = wp.zeros(1, dtype=wp.float32, device=device, requires_grad=True)
|
|
482
|
+
for test_case in points:
|
|
483
|
+
uvws = wp.array(test_case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
484
|
+
xyzs = wp.array(test_case * 0.25, dtype=wp.vec3, device=device, requires_grad=True)
|
|
485
|
+
|
|
486
|
+
tape = wp.Tape()
|
|
487
|
+
with tape:
|
|
488
|
+
wp.launch(
|
|
489
|
+
test_volume_sample_local_v_linear_values,
|
|
490
|
+
dim=1,
|
|
491
|
+
inputs=[volumes["vec3f"][device.alias].id, uvws, values],
|
|
492
|
+
device=device,
|
|
493
|
+
)
|
|
494
|
+
tape.backward(values)
|
|
495
|
+
|
|
496
|
+
grad_expected = np.array([6.0, 15.0, 24.0])
|
|
497
|
+
grad_computed = tape.gradients[uvws].numpy()[0]
|
|
498
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
499
|
+
|
|
500
|
+
tape = wp.Tape()
|
|
501
|
+
with tape:
|
|
502
|
+
wp.launch(
|
|
503
|
+
test_volume_sample_world_v_linear_values,
|
|
504
|
+
dim=1,
|
|
505
|
+
inputs=[volumes["vec3f"][device.alias].id, xyzs, values],
|
|
506
|
+
device=device,
|
|
507
|
+
)
|
|
508
|
+
tape.backward(values)
|
|
509
|
+
|
|
510
|
+
grad_expected = np.array([6.0, 15.0, 24.0]) / 0.25
|
|
511
|
+
grad_computed = tape.gradients[xyzs].numpy()[0]
|
|
512
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
def test_volume_transform_gradient(test, device):
|
|
516
|
+
values = wp.zeros(1, dtype=wp.float32, device=device, requires_grad=True)
|
|
517
|
+
grad_values = wp.zeros(1, dtype=wp.vec3, device=device)
|
|
518
|
+
test_points = rng.uniform(-10.0, 10.0, size=(10, 3))
|
|
519
|
+
for test_case in test_points:
|
|
520
|
+
points = wp.array(test_case, dtype=wp.vec3, device=device, requires_grad=True)
|
|
521
|
+
tape = wp.Tape()
|
|
522
|
+
with tape:
|
|
523
|
+
wp.launch(
|
|
524
|
+
test_volume_index_to_world,
|
|
525
|
+
dim=1,
|
|
526
|
+
inputs=[volumes["torus"][device.alias].id, points, values, grad_values],
|
|
527
|
+
device=device,
|
|
599
528
|
)
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
529
|
+
tape.backward(values)
|
|
530
|
+
|
|
531
|
+
grad_computed = tape.gradients[points].numpy()
|
|
532
|
+
grad_expected = grad_values.numpy()
|
|
533
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
534
|
+
|
|
535
|
+
grad_computed = tape.gradients[points].numpy()
|
|
536
|
+
grad_expected = grad_values.numpy()
|
|
537
|
+
np.testing.assert_allclose(grad_computed, grad_expected, rtol=1e-4)
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def test_volume_store(test, device):
|
|
541
|
+
values_ref = np.array([x + 100 * y + 10000 * z for x, y, z in point_grid])
|
|
542
|
+
points = wp.array(point_grid, dtype=wp.vec3, device=device)
|
|
543
|
+
values = wp.empty(len(point_grid), dtype=wp.float32, device=device)
|
|
544
|
+
wp.launch(
|
|
545
|
+
test_volume_store_f,
|
|
546
|
+
dim=len(point_grid),
|
|
547
|
+
inputs=[volumes["float_write"][device.alias].id, points, values],
|
|
548
|
+
device=device,
|
|
549
|
+
)
|
|
603
550
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
551
|
+
values_res = values.numpy()
|
|
552
|
+
np.testing.assert_equal(values_res, values_ref)
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
def test_volume_allocation_f(test, device):
|
|
556
|
+
bg_value = -123.0
|
|
557
|
+
points_np = np.append(point_grid, [[8096, 8096, 8096]], axis=0)
|
|
558
|
+
values_ref = np.append(np.array([x + 100 * y + 10000 * z for x, y, z in point_grid]), bg_value)
|
|
559
|
+
|
|
560
|
+
volume = wp.Volume.allocate(min=[-11, -11, -11], max=[11, 11, 11], voxel_size=0.1, bg_value=bg_value, device=device)
|
|
561
|
+
points = wp.array(points_np, dtype=wp.vec3, device=device)
|
|
562
|
+
values = wp.empty(len(points_np), dtype=wp.float32, device=device)
|
|
563
|
+
wp.launch(test_volume_store_f, dim=len(points_np), inputs=[volume.id, points, values], device=device)
|
|
564
|
+
|
|
565
|
+
values_res = values.numpy()
|
|
566
|
+
np.testing.assert_equal(values_res, values_ref)
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def test_volume_allocation_v(test, device):
|
|
570
|
+
bg_value = (-1, 2.0, -3)
|
|
571
|
+
points_np = np.append(point_grid, [[8096, 8096, 8096]], axis=0)
|
|
572
|
+
values_ref = np.append(point_grid, [bg_value], axis=0)
|
|
573
|
+
|
|
574
|
+
volume = wp.Volume.allocate(min=[-11, -11, -11], max=[11, 11, 11], voxel_size=0.1, bg_value=bg_value, device=device)
|
|
575
|
+
points = wp.array(points_np, dtype=wp.vec3, device=device)
|
|
576
|
+
values = wp.empty(len(points_np), dtype=wp.vec3, device=device)
|
|
577
|
+
wp.launch(test_volume_store_v, dim=len(points_np), inputs=[volume.id, points, values], device=device)
|
|
578
|
+
|
|
579
|
+
values_res = values.numpy()
|
|
580
|
+
np.testing.assert_equal(values_res, values_ref)
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def test_volume_allocation_i(test, device):
|
|
584
|
+
bg_value = -123
|
|
585
|
+
points_np = np.append(point_grid, [[8096, 8096, 8096]], axis=0)
|
|
586
|
+
values_ref = np.append(np.array([x + 100 * y + 10000 * z for x, y, z in point_grid], dtype=np.int32), bg_value)
|
|
587
|
+
|
|
588
|
+
volume = wp.Volume.allocate(min=[-11, -11, -11], max=[11, 11, 11], voxel_size=0.1, bg_value=bg_value, device=device)
|
|
589
|
+
points = wp.array(points_np, dtype=wp.vec3, device=device)
|
|
590
|
+
values = wp.empty(len(points_np), dtype=wp.int32, device=device)
|
|
591
|
+
wp.launch(test_volume_store_i, dim=len(points_np), inputs=[volume.id, points, values], device=device)
|
|
592
|
+
|
|
593
|
+
values_res = values.numpy()
|
|
594
|
+
np.testing.assert_equal(values_res, values_ref)
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def test_volume_introspection(test, device):
|
|
598
|
+
for volume_names in ("float", "vec3f"):
|
|
599
|
+
with test.subTest(volume_names=volume_names):
|
|
600
|
+
volume = volumes[volume_names][device.alias]
|
|
601
|
+
tiles_actual = volume.get_tiles().numpy()
|
|
602
|
+
tiles_sorted = tiles_actual[np.lexsort(tiles_actual.T[::-1])]
|
|
603
|
+
voxel_size = np.array(volume.get_voxel_size())
|
|
604
|
+
|
|
605
|
+
np.testing.assert_equal(test_volume_tiles, tiles_sorted)
|
|
606
|
+
np.testing.assert_equal([0.25] * 3, voxel_size)
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def test_volume_from_numpy(test, device):
|
|
610
|
+
# Volume.allocate_from_tiles() is only available with CUDA
|
|
611
|
+
mins = np.array([-3.0, -3.0, -3.0])
|
|
612
|
+
voxel_size = 0.2
|
|
613
|
+
maxs = np.array([3.0, 3.0, 3.0])
|
|
614
|
+
nums = np.ceil((maxs - mins) / (voxel_size)).astype(dtype=int)
|
|
615
|
+
center = np.array([0.0, 0.0, 0.0])
|
|
616
|
+
rad = 2.5
|
|
617
|
+
sphere_sdf_np = np.zeros(tuple(nums))
|
|
618
|
+
for x in range(nums[0]):
|
|
619
|
+
for y in range(nums[1]):
|
|
620
|
+
for z in range(nums[2]):
|
|
621
|
+
pos = mins + voxel_size * np.array([x, y, z])
|
|
622
|
+
dis = np.linalg.norm(pos - center)
|
|
623
|
+
sphere_sdf_np[x, y, z] = dis - rad
|
|
624
|
+
sphere_vdb = wp.Volume.load_from_numpy(sphere_sdf_np, mins, voxel_size, rad + 3.0 * voxel_size, device=device)
|
|
625
|
+
|
|
626
|
+
test.assertNotEqual(sphere_vdb.id, 0)
|
|
627
|
+
|
|
628
|
+
sphere_vdb_array = sphere_vdb.array()
|
|
629
|
+
test.assertEqual(sphere_vdb_array.dtype, wp.uint8)
|
|
630
|
+
test.assertFalse(sphere_vdb_array.owner)
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
class TestVolume(unittest.TestCase):
|
|
634
|
+
pass
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
add_function_test(
|
|
638
|
+
TestVolume, "test_volume_sample_linear_f_gradient", test_volume_sample_linear_f_gradient, devices=devices
|
|
639
|
+
)
|
|
640
|
+
add_function_test(
|
|
641
|
+
TestVolume, "test_volume_sample_grad_linear_f_gradient", test_volume_sample_grad_linear_f_gradient, devices=devices
|
|
642
|
+
)
|
|
643
|
+
add_function_test(
|
|
644
|
+
TestVolume, "test_volume_sample_linear_v_gradient", test_volume_sample_linear_v_gradient, devices=devices
|
|
645
|
+
)
|
|
646
|
+
add_function_test(TestVolume, "test_volume_transform_gradient", test_volume_transform_gradient, devices=devices)
|
|
647
|
+
add_function_test(TestVolume, "test_volume_store", test_volume_store, devices=devices)
|
|
648
|
+
add_function_test(
|
|
649
|
+
TestVolume, "test_volume_allocation_f", test_volume_allocation_f, devices=get_unique_cuda_test_devices()
|
|
650
|
+
)
|
|
651
|
+
add_function_test(
|
|
652
|
+
TestVolume, "test_volume_allocation_v", test_volume_allocation_v, devices=get_unique_cuda_test_devices()
|
|
653
|
+
)
|
|
654
|
+
add_function_test(
|
|
655
|
+
TestVolume, "test_volume_allocation_i", test_volume_allocation_i, devices=get_unique_cuda_test_devices()
|
|
656
|
+
)
|
|
657
|
+
add_function_test(TestVolume, "test_volume_introspection", test_volume_introspection, devices=devices)
|
|
658
|
+
add_function_test(TestVolume, "test_volume_from_numpy", test_volume_from_numpy, devices=get_unique_cuda_test_devices())
|
|
659
|
+
|
|
660
|
+
points = {}
|
|
661
|
+
points_jittered = {}
|
|
662
|
+
for device in devices:
|
|
663
|
+
points_jittered_np = point_grid + rng.uniform(-0.5, 0.5, size=point_grid.shape)
|
|
664
|
+
points[device.alias] = wp.array(point_grid, dtype=wp.vec3, device=device)
|
|
665
|
+
points_jittered[device.alias] = wp.array(points_jittered_np, dtype=wp.vec3, device=device)
|
|
666
|
+
|
|
667
|
+
add_kernel_test(
|
|
668
|
+
TestVolume,
|
|
669
|
+
test_volume_lookup_f,
|
|
670
|
+
dim=len(point_grid),
|
|
671
|
+
inputs=[volumes["float"][device.alias].id, points[device.alias]],
|
|
672
|
+
devices=[device],
|
|
673
|
+
)
|
|
674
|
+
add_kernel_test(
|
|
675
|
+
TestVolume,
|
|
676
|
+
test_volume_sample_closest_f,
|
|
677
|
+
dim=len(point_grid),
|
|
678
|
+
inputs=[volumes["float"][device.alias].id, points_jittered[device.alias]],
|
|
679
|
+
devices=[device.alias],
|
|
680
|
+
)
|
|
681
|
+
add_kernel_test(
|
|
682
|
+
TestVolume,
|
|
683
|
+
test_volume_sample_linear_f,
|
|
684
|
+
dim=len(point_grid),
|
|
685
|
+
inputs=[volumes["float"][device.alias].id, points_jittered[device.alias]],
|
|
686
|
+
devices=[device.alias],
|
|
687
|
+
)
|
|
688
|
+
add_kernel_test(
|
|
689
|
+
TestVolume,
|
|
690
|
+
test_volume_sample_grad_linear_f,
|
|
691
|
+
dim=len(point_grid),
|
|
692
|
+
inputs=[volumes["float"][device.alias].id, points_jittered[device.alias]],
|
|
693
|
+
devices=[device.alias],
|
|
694
|
+
)
|
|
648
695
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
)
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
)
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
test_volume_lookup_v,
|
|
686
|
-
dim=len(point_grid),
|
|
687
|
-
inputs=[volumes["vec3f"][device.alias].id, points[device.alias]],
|
|
688
|
-
devices=[device.alias],
|
|
689
|
-
)
|
|
690
|
-
add_kernel_test(
|
|
691
|
-
TestVolumes,
|
|
692
|
-
test_volume_sample_closest_v,
|
|
693
|
-
dim=len(point_grid),
|
|
694
|
-
inputs=[volumes["vec3f"][device.alias].id, points_jittered[device.alias]],
|
|
695
|
-
devices=[device.alias],
|
|
696
|
-
)
|
|
697
|
-
add_kernel_test(
|
|
698
|
-
TestVolumes,
|
|
699
|
-
test_volume_sample_linear_v,
|
|
700
|
-
dim=len(point_grid),
|
|
701
|
-
inputs=[volumes["vec3f"][device.alias].id, points_jittered[device.alias]],
|
|
702
|
-
devices=[device.alias],
|
|
703
|
-
)
|
|
704
|
-
|
|
705
|
-
add_kernel_test(
|
|
706
|
-
TestVolumes,
|
|
707
|
-
test_volume_lookup_i,
|
|
708
|
-
dim=len(point_grid),
|
|
709
|
-
inputs=[volumes["int32"][device.alias].id, points[device.alias]],
|
|
710
|
-
devices=[device.alias],
|
|
711
|
-
)
|
|
712
|
-
add_kernel_test(
|
|
713
|
-
TestVolumes,
|
|
714
|
-
test_volume_sample_i,
|
|
715
|
-
dim=len(point_grid),
|
|
716
|
-
inputs=[volumes["int32"][device.alias].id, points_jittered[device.alias]],
|
|
717
|
-
devices=[device.alias],
|
|
718
|
-
)
|
|
719
|
-
|
|
720
|
-
return TestVolumes
|
|
696
|
+
add_kernel_test(
|
|
697
|
+
TestVolume,
|
|
698
|
+
test_volume_lookup_v,
|
|
699
|
+
dim=len(point_grid),
|
|
700
|
+
inputs=[volumes["vec3f"][device.alias].id, points[device.alias]],
|
|
701
|
+
devices=[device.alias],
|
|
702
|
+
)
|
|
703
|
+
add_kernel_test(
|
|
704
|
+
TestVolume,
|
|
705
|
+
test_volume_sample_closest_v,
|
|
706
|
+
dim=len(point_grid),
|
|
707
|
+
inputs=[volumes["vec3f"][device.alias].id, points_jittered[device.alias]],
|
|
708
|
+
devices=[device.alias],
|
|
709
|
+
)
|
|
710
|
+
add_kernel_test(
|
|
711
|
+
TestVolume,
|
|
712
|
+
test_volume_sample_linear_v,
|
|
713
|
+
dim=len(point_grid),
|
|
714
|
+
inputs=[volumes["vec3f"][device.alias].id, points_jittered[device.alias]],
|
|
715
|
+
devices=[device.alias],
|
|
716
|
+
)
|
|
717
|
+
|
|
718
|
+
add_kernel_test(
|
|
719
|
+
TestVolume,
|
|
720
|
+
test_volume_lookup_i,
|
|
721
|
+
dim=len(point_grid),
|
|
722
|
+
inputs=[volumes["int32"][device.alias].id, points[device.alias]],
|
|
723
|
+
devices=[device.alias],
|
|
724
|
+
)
|
|
725
|
+
add_kernel_test(
|
|
726
|
+
TestVolume,
|
|
727
|
+
test_volume_sample_i,
|
|
728
|
+
dim=len(point_grid),
|
|
729
|
+
inputs=[volumes["int32"][device.alias].id, points_jittered[device.alias]],
|
|
730
|
+
devices=[device.alias],
|
|
731
|
+
)
|
|
721
732
|
|
|
722
733
|
|
|
723
734
|
if __name__ == "__main__":
|
|
724
735
|
wp.build.clear_kernel_cache()
|
|
725
|
-
wp.force_load()
|
|
726
|
-
_ = register(unittest.TestCase)
|
|
727
736
|
unittest.main(verbosity=2)
|