warp-lang 1.7.2rc1__py3-none-macosx_10_13_universal2.whl → 1.8.1__py3-none-macosx_10_13_universal2.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 +3 -1
- warp/__init__.pyi +3489 -1
- warp/autograd.py +45 -122
- warp/bin/libwarp.dylib +0 -0
- warp/build.py +241 -252
- warp/build_dll.py +130 -26
- warp/builtins.py +1907 -384
- warp/codegen.py +272 -104
- warp/config.py +12 -1
- warp/constants.py +1 -1
- warp/context.py +770 -238
- warp/dlpack.py +1 -1
- warp/examples/benchmarks/benchmark_cloth.py +2 -2
- warp/examples/benchmarks/benchmark_tile_sort.py +155 -0
- warp/examples/core/example_sample_mesh.py +1 -1
- warp/examples/core/example_spin_lock.py +93 -0
- warp/examples/core/example_work_queue.py +118 -0
- warp/examples/fem/example_adaptive_grid.py +5 -5
- warp/examples/fem/example_apic_fluid.py +1 -1
- warp/examples/fem/example_burgers.py +1 -1
- warp/examples/fem/example_convection_diffusion.py +9 -6
- warp/examples/fem/example_darcy_ls_optimization.py +489 -0
- warp/examples/fem/example_deformed_geometry.py +1 -1
- warp/examples/fem/example_diffusion.py +2 -2
- warp/examples/fem/example_diffusion_3d.py +1 -1
- warp/examples/fem/example_distortion_energy.py +1 -1
- warp/examples/fem/example_elastic_shape_optimization.py +387 -0
- warp/examples/fem/example_magnetostatics.py +5 -3
- warp/examples/fem/example_mixed_elasticity.py +5 -3
- warp/examples/fem/example_navier_stokes.py +11 -9
- warp/examples/fem/example_nonconforming_contact.py +5 -3
- warp/examples/fem/example_streamlines.py +8 -3
- warp/examples/fem/utils.py +9 -8
- warp/examples/interop/example_jax_callable.py +34 -4
- warp/examples/interop/example_jax_ffi_callback.py +2 -2
- warp/examples/interop/example_jax_kernel.py +27 -1
- warp/examples/optim/example_drone.py +1 -1
- warp/examples/sim/example_cloth.py +1 -1
- warp/examples/sim/example_cloth_self_contact.py +48 -54
- warp/examples/tile/example_tile_block_cholesky.py +502 -0
- warp/examples/tile/example_tile_cholesky.py +2 -1
- warp/examples/tile/example_tile_convolution.py +1 -1
- warp/examples/tile/example_tile_filtering.py +1 -1
- warp/examples/tile/example_tile_matmul.py +1 -1
- warp/examples/tile/example_tile_mlp.py +2 -0
- warp/fabric.py +7 -7
- warp/fem/__init__.py +5 -0
- warp/fem/adaptivity.py +1 -1
- warp/fem/cache.py +152 -63
- warp/fem/dirichlet.py +2 -2
- warp/fem/domain.py +136 -6
- warp/fem/field/field.py +141 -99
- warp/fem/field/nodal_field.py +85 -39
- warp/fem/field/virtual.py +99 -52
- warp/fem/geometry/adaptive_nanogrid.py +91 -86
- warp/fem/geometry/closest_point.py +13 -0
- warp/fem/geometry/deformed_geometry.py +102 -40
- warp/fem/geometry/element.py +56 -2
- warp/fem/geometry/geometry.py +323 -22
- warp/fem/geometry/grid_2d.py +157 -62
- warp/fem/geometry/grid_3d.py +116 -20
- warp/fem/geometry/hexmesh.py +86 -20
- warp/fem/geometry/nanogrid.py +166 -86
- warp/fem/geometry/partition.py +59 -25
- warp/fem/geometry/quadmesh.py +86 -135
- warp/fem/geometry/tetmesh.py +47 -119
- warp/fem/geometry/trimesh.py +77 -270
- warp/fem/integrate.py +181 -95
- warp/fem/linalg.py +25 -58
- warp/fem/operator.py +124 -27
- warp/fem/quadrature/pic_quadrature.py +36 -14
- warp/fem/quadrature/quadrature.py +40 -16
- warp/fem/space/__init__.py +1 -1
- warp/fem/space/basis_function_space.py +66 -46
- warp/fem/space/basis_space.py +17 -4
- warp/fem/space/dof_mapper.py +1 -1
- warp/fem/space/function_space.py +2 -2
- warp/fem/space/grid_2d_function_space.py +4 -1
- warp/fem/space/hexmesh_function_space.py +4 -2
- warp/fem/space/nanogrid_function_space.py +3 -1
- warp/fem/space/partition.py +11 -2
- warp/fem/space/quadmesh_function_space.py +4 -1
- warp/fem/space/restriction.py +5 -2
- warp/fem/space/shape/__init__.py +10 -8
- warp/fem/space/tetmesh_function_space.py +4 -1
- warp/fem/space/topology.py +52 -21
- warp/fem/space/trimesh_function_space.py +4 -1
- warp/fem/utils.py +53 -8
- warp/jax.py +1 -2
- warp/jax_experimental/ffi.py +210 -67
- warp/jax_experimental/xla_ffi.py +37 -24
- warp/math.py +171 -1
- warp/native/array.h +103 -4
- warp/native/builtin.h +182 -35
- warp/native/coloring.cpp +6 -2
- warp/native/cuda_util.cpp +1 -1
- warp/native/exports.h +118 -63
- warp/native/intersect.h +5 -5
- warp/native/mat.h +8 -13
- warp/native/mathdx.cpp +11 -5
- warp/native/matnn.h +1 -123
- warp/native/mesh.h +1 -1
- warp/native/quat.h +34 -6
- warp/native/rand.h +7 -7
- warp/native/sparse.cpp +121 -258
- warp/native/sparse.cu +181 -274
- warp/native/spatial.h +305 -17
- warp/native/svd.h +23 -8
- warp/native/tile.h +603 -73
- warp/native/tile_radix_sort.h +1112 -0
- warp/native/tile_reduce.h +239 -13
- warp/native/tile_scan.h +240 -0
- warp/native/tuple.h +189 -0
- warp/native/vec.h +10 -20
- warp/native/warp.cpp +36 -4
- warp/native/warp.cu +588 -52
- warp/native/warp.h +47 -74
- warp/optim/linear.py +5 -1
- warp/paddle.py +7 -8
- warp/py.typed +0 -0
- warp/render/render_opengl.py +110 -80
- warp/render/render_usd.py +124 -62
- warp/sim/__init__.py +9 -0
- warp/sim/collide.py +253 -80
- warp/sim/graph_coloring.py +8 -1
- warp/sim/import_mjcf.py +4 -3
- warp/sim/import_usd.py +11 -7
- warp/sim/integrator.py +5 -2
- warp/sim/integrator_euler.py +1 -1
- warp/sim/integrator_featherstone.py +1 -1
- warp/sim/integrator_vbd.py +761 -322
- warp/sim/integrator_xpbd.py +1 -1
- warp/sim/model.py +265 -260
- warp/sim/utils.py +10 -7
- warp/sparse.py +303 -166
- warp/tape.py +54 -51
- warp/tests/cuda/test_conditional_captures.py +1046 -0
- warp/tests/cuda/test_streams.py +1 -1
- warp/tests/geometry/test_volume.py +2 -2
- warp/tests/interop/test_dlpack.py +9 -9
- warp/tests/interop/test_jax.py +0 -1
- warp/tests/run_coverage_serial.py +1 -1
- warp/tests/sim/disabled_kinematics.py +2 -2
- warp/tests/sim/{test_vbd.py → test_cloth.py} +378 -112
- warp/tests/sim/test_collision.py +159 -51
- warp/tests/sim/test_coloring.py +91 -2
- warp/tests/test_array.py +254 -2
- warp/tests/test_array_reduce.py +2 -2
- warp/tests/test_assert.py +53 -0
- warp/tests/test_atomic_cas.py +312 -0
- warp/tests/test_codegen.py +142 -19
- warp/tests/test_conditional.py +47 -1
- warp/tests/test_ctypes.py +0 -20
- warp/tests/test_devices.py +8 -0
- warp/tests/test_fabricarray.py +4 -2
- warp/tests/test_fem.py +58 -25
- warp/tests/test_func.py +42 -1
- warp/tests/test_grad.py +1 -1
- warp/tests/test_lerp.py +1 -3
- warp/tests/test_map.py +481 -0
- warp/tests/test_mat.py +23 -24
- warp/tests/test_quat.py +28 -15
- warp/tests/test_rounding.py +10 -38
- warp/tests/test_runlength_encode.py +7 -7
- warp/tests/test_smoothstep.py +1 -1
- warp/tests/test_sparse.py +83 -2
- warp/tests/test_spatial.py +507 -1
- warp/tests/test_static.py +48 -0
- warp/tests/test_struct.py +2 -2
- warp/tests/test_tape.py +38 -0
- warp/tests/test_tuple.py +265 -0
- warp/tests/test_types.py +2 -2
- warp/tests/test_utils.py +24 -18
- warp/tests/test_vec.py +38 -408
- warp/tests/test_vec_constructors.py +325 -0
- warp/tests/tile/test_tile.py +438 -131
- warp/tests/tile/test_tile_mathdx.py +518 -14
- warp/tests/tile/test_tile_matmul.py +179 -0
- warp/tests/tile/test_tile_reduce.py +307 -5
- warp/tests/tile/test_tile_shared_memory.py +136 -7
- warp/tests/tile/test_tile_sort.py +121 -0
- warp/tests/unittest_suites.py +14 -6
- warp/types.py +462 -308
- warp/utils.py +647 -86
- {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.1.dist-info}/METADATA +20 -6
- {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.1.dist-info}/RECORD +189 -175
- warp/stubs.py +0 -3381
- warp/tests/sim/test_xpbd.py +0 -399
- warp/tests/test_mlp.py +0 -282
- {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.1.dist-info}/WHEEL +0 -0
- {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.1.dist-info}/licenses/LICENSE.md +0 -0
- {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.1.dist-info}/top_level.txt +0 -0
warp/autograd.py
CHANGED
|
@@ -13,34 +13,36 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
16
18
|
import inspect
|
|
17
19
|
import itertools
|
|
18
|
-
from typing import Any, Callable,
|
|
20
|
+
from typing import Any, Callable, Sequence
|
|
19
21
|
|
|
20
22
|
import numpy as np
|
|
21
23
|
|
|
22
24
|
import warp as wp
|
|
23
25
|
|
|
24
26
|
__all__ = [
|
|
25
|
-
"jacobian",
|
|
26
|
-
"jacobian_fd",
|
|
27
27
|
"gradcheck",
|
|
28
28
|
"gradcheck_tape",
|
|
29
|
+
"jacobian",
|
|
30
|
+
"jacobian_fd",
|
|
29
31
|
"jacobian_plot",
|
|
30
32
|
]
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
def gradcheck(
|
|
34
|
-
function:
|
|
35
|
-
dim:
|
|
36
|
-
inputs: Sequence = None,
|
|
37
|
-
outputs: Sequence = None,
|
|
36
|
+
function: wp.Kernel | Callable,
|
|
37
|
+
dim: tuple[int] | None = None,
|
|
38
|
+
inputs: Sequence | None = None,
|
|
39
|
+
outputs: Sequence | None = None,
|
|
38
40
|
*,
|
|
39
41
|
eps: float = 1e-4,
|
|
40
42
|
atol: float = 1e-3,
|
|
41
43
|
rtol: float = 1e-2,
|
|
42
44
|
raise_exception: bool = True,
|
|
43
|
-
input_output_mask:
|
|
45
|
+
input_output_mask: list[tuple[str | int, str | int]] | None = None,
|
|
44
46
|
device: wp.context.Devicelike = None,
|
|
45
47
|
max_blocks: int = 0,
|
|
46
48
|
block_dim: int = 256,
|
|
@@ -242,9 +244,9 @@ def gradcheck_tape(
|
|
|
242
244
|
atol=1e-3,
|
|
243
245
|
rtol=1e-2,
|
|
244
246
|
raise_exception=True,
|
|
245
|
-
input_output_masks:
|
|
246
|
-
blacklist_kernels:
|
|
247
|
-
whitelist_kernels:
|
|
247
|
+
input_output_masks: dict[str, list[tuple[str | int, str | int]]] | None = None,
|
|
248
|
+
blacklist_kernels: list[str] | None = None,
|
|
249
|
+
whitelist_kernels: list[str] | None = None,
|
|
248
250
|
max_inputs_per_var=-1,
|
|
249
251
|
max_outputs_per_var=-1,
|
|
250
252
|
plot_relative_error=False,
|
|
@@ -364,13 +366,13 @@ class FunctionMetadata:
|
|
|
364
366
|
|
|
365
367
|
def __init__(
|
|
366
368
|
self,
|
|
367
|
-
key: str = None,
|
|
368
|
-
input_labels:
|
|
369
|
-
output_labels:
|
|
370
|
-
input_strides:
|
|
371
|
-
output_strides:
|
|
372
|
-
input_dtypes: list = None,
|
|
373
|
-
output_dtypes: list = None,
|
|
369
|
+
key: str | None = None,
|
|
370
|
+
input_labels: list[str] | None = None,
|
|
371
|
+
output_labels: list[str] | None = None,
|
|
372
|
+
input_strides: list[tuple] | None = None,
|
|
373
|
+
output_strides: list[tuple] | None = None,
|
|
374
|
+
input_dtypes: list | None = None,
|
|
375
|
+
output_dtypes: list | None = None,
|
|
374
376
|
):
|
|
375
377
|
self.key = key
|
|
376
378
|
self.input_labels = input_labels
|
|
@@ -413,7 +415,7 @@ class FunctionMetadata:
|
|
|
413
415
|
self.output_strides.append(None)
|
|
414
416
|
self.output_dtypes.append(None)
|
|
415
417
|
|
|
416
|
-
def update_from_function(self, function: Callable, inputs: Sequence, outputs: Sequence = None):
|
|
418
|
+
def update_from_function(self, function: Callable, inputs: Sequence, outputs: Sequence | None = None):
|
|
417
419
|
self.key = function.__name__
|
|
418
420
|
self.input_labels = list(inspect.signature(function).parameters.keys())
|
|
419
421
|
if outputs is None:
|
|
@@ -442,16 +444,15 @@ class FunctionMetadata:
|
|
|
442
444
|
|
|
443
445
|
|
|
444
446
|
def jacobian_plot(
|
|
445
|
-
jacobians:
|
|
446
|
-
kernel:
|
|
447
|
-
inputs: Sequence = None,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
title: str = None,
|
|
447
|
+
jacobians: dict[tuple[int, int], wp.array],
|
|
448
|
+
kernel: FunctionMetadata | wp.Kernel,
|
|
449
|
+
inputs: Sequence | None = None,
|
|
450
|
+
show_plot: bool = True,
|
|
451
|
+
show_colorbar: bool = True,
|
|
452
|
+
scale_colors_per_submatrix: bool = False,
|
|
453
|
+
title: str | None = None,
|
|
453
454
|
colormap: str = "coolwarm",
|
|
454
|
-
log_scale=False,
|
|
455
|
+
log_scale: bool = False,
|
|
455
456
|
):
|
|
456
457
|
"""
|
|
457
458
|
Visualizes the Jacobians computed by :func:`jacobian` or :func:`jacobian_fd` in a combined image plot.
|
|
@@ -461,7 +462,6 @@ def jacobian_plot(
|
|
|
461
462
|
jacobians: A dictionary of Jacobians, where the keys are tuples of input and output indices, and the values are the Jacobian matrices.
|
|
462
463
|
kernel: The Warp kernel function, decorated with the ``@wp.kernel`` decorator, or a :class:`FunctionMetadata` instance with the kernel/function attributes.
|
|
463
464
|
inputs: List of input variables.
|
|
464
|
-
outputs: List of output variables. Deprecated and will be removed in a future Warp version.
|
|
465
465
|
show_plot: If True, displays the plot via ``plt.show()``.
|
|
466
466
|
show_colorbar: If True, displays a colorbar next to the plot (or a colorbar next to every submatrix if ).
|
|
467
467
|
scale_colors_per_submatrix: If True, considers the minimum and maximum of each Jacobian submatrix separately for color scaling. Otherwise, uses the global minimum and maximum of all Jacobians.
|
|
@@ -484,12 +484,6 @@ def jacobian_plot(
|
|
|
484
484
|
metadata = kernel
|
|
485
485
|
else:
|
|
486
486
|
raise ValueError("Invalid kernel argument: must be a Warp kernel or a FunctionMetadata object")
|
|
487
|
-
if outputs is not None:
|
|
488
|
-
wp.utils.warn(
|
|
489
|
-
"The `outputs` argument to `jacobian_plot` is no longer needed and will be removed in a future Warp version.",
|
|
490
|
-
DeprecationWarning,
|
|
491
|
-
stacklevel=3,
|
|
492
|
-
)
|
|
493
487
|
|
|
494
488
|
jacobians = sorted(jacobians.items(), key=lambda x: (x[0][1], x[0][0]))
|
|
495
489
|
jacobians = dict(jacobians)
|
|
@@ -635,59 +629,6 @@ def jacobian_plot(
|
|
|
635
629
|
return fig
|
|
636
630
|
|
|
637
631
|
|
|
638
|
-
def plot_kernel_jacobians(
|
|
639
|
-
jacobians: Dict[Tuple[int, int], wp.array],
|
|
640
|
-
kernel: wp.Kernel,
|
|
641
|
-
inputs: Sequence,
|
|
642
|
-
outputs: Sequence,
|
|
643
|
-
show_plot=True,
|
|
644
|
-
show_colorbar=True,
|
|
645
|
-
scale_colors_per_submatrix=False,
|
|
646
|
-
title: str = None,
|
|
647
|
-
colormap: str = "coolwarm",
|
|
648
|
-
log_scale=False,
|
|
649
|
-
):
|
|
650
|
-
"""
|
|
651
|
-
Visualizes the Jacobians computed by :func:`jacobian` or :func:`jacobian_fd` in a combined image plot.
|
|
652
|
-
Requires the ``matplotlib`` package to be installed.
|
|
653
|
-
|
|
654
|
-
Note:
|
|
655
|
-
This function is deprecated and will be removed in a future Warp version. Please call :func:`jacobian_plot` instead.
|
|
656
|
-
|
|
657
|
-
Args:
|
|
658
|
-
jacobians: A dictionary of Jacobians, where the keys are tuples of input and output indices, and the values are the Jacobian matrices.
|
|
659
|
-
kernel: The Warp kernel function, decorated with the ``@wp.kernel`` decorator.
|
|
660
|
-
inputs: List of input variables.
|
|
661
|
-
outputs: List of output variables.
|
|
662
|
-
show_plot: If True, displays the plot via ``plt.show()``.
|
|
663
|
-
show_colorbar: If True, displays a colorbar next to the plot (or a colorbar next to every submatrix if ).
|
|
664
|
-
scale_colors_per_submatrix: If True, considers the minimum and maximum of each Jacobian submatrix separately for color scaling. Otherwise, uses the global minimum and maximum of all Jacobians.
|
|
665
|
-
title: The title of the plot (optional).
|
|
666
|
-
colormap: The colormap to use for the plot.
|
|
667
|
-
log_scale: If True, uses a logarithmic scale for the matrix values shown in the image plot.
|
|
668
|
-
|
|
669
|
-
Returns:
|
|
670
|
-
The created Matplotlib figure.
|
|
671
|
-
"""
|
|
672
|
-
wp.utils.warn(
|
|
673
|
-
"The function `plot_kernel_jacobians` is deprecated and will be removed in a future Warp version. Please call `jacobian_plot` instead.",
|
|
674
|
-
DeprecationWarning,
|
|
675
|
-
stacklevel=3,
|
|
676
|
-
)
|
|
677
|
-
return jacobian_plot(
|
|
678
|
-
jacobians,
|
|
679
|
-
kernel,
|
|
680
|
-
inputs,
|
|
681
|
-
outputs,
|
|
682
|
-
show_plot=show_plot,
|
|
683
|
-
show_colorbar=show_colorbar,
|
|
684
|
-
scale_colors_per_submatrix=scale_colors_per_submatrix,
|
|
685
|
-
title=title,
|
|
686
|
-
colormap=colormap,
|
|
687
|
-
log_scale=log_scale,
|
|
688
|
-
)
|
|
689
|
-
|
|
690
|
-
|
|
691
632
|
def scalarize_array_1d(arr):
|
|
692
633
|
# convert array to 1D array with scalar dtype
|
|
693
634
|
if arr.dtype in wp.types.scalar_types:
|
|
@@ -724,19 +665,18 @@ def scalarize_array_2d(arr):
|
|
|
724
665
|
|
|
725
666
|
|
|
726
667
|
def jacobian(
|
|
727
|
-
function:
|
|
728
|
-
dim:
|
|
729
|
-
inputs: Sequence = None,
|
|
730
|
-
outputs: Sequence = None,
|
|
731
|
-
input_output_mask:
|
|
668
|
+
function: wp.Kernel | Callable,
|
|
669
|
+
dim: tuple[int] | None = None,
|
|
670
|
+
inputs: Sequence | None = None,
|
|
671
|
+
outputs: Sequence | None = None,
|
|
672
|
+
input_output_mask: list[tuple[str | int, str | int]] | None = None,
|
|
732
673
|
device: wp.context.Devicelike = None,
|
|
733
674
|
max_blocks=0,
|
|
734
675
|
block_dim=256,
|
|
735
676
|
max_outputs_per_var=-1,
|
|
736
677
|
plot_jacobians=False,
|
|
737
|
-
metadata: FunctionMetadata = None,
|
|
738
|
-
|
|
739
|
-
) -> Dict[Tuple[int, int], wp.array]:
|
|
678
|
+
metadata: FunctionMetadata | None = None,
|
|
679
|
+
) -> dict[tuple[int, int], wp.array]:
|
|
740
680
|
"""
|
|
741
681
|
Computes the Jacobians of a function or Warp kernel for the provided selection of differentiable inputs to differentiable outputs.
|
|
742
682
|
|
|
@@ -764,20 +704,12 @@ def jacobian(
|
|
|
764
704
|
max_outputs_per_var: Maximum number of output dimensions over which to evaluate the Jacobians for the input-output pairs. Evaluates all output dimensions if value <= 0.
|
|
765
705
|
plot_jacobians: If True, visualizes the computed Jacobians in a plot (requires ``matplotlib``).
|
|
766
706
|
metadata: The metadata of the kernel function, containing the input and output labels, strides, and dtypes. If None or empty, the metadata is inferred from the kernel or function.
|
|
767
|
-
kernel: Deprecated argument. Use the ``function`` argument instead.
|
|
768
707
|
|
|
769
708
|
Returns:
|
|
770
709
|
A dictionary of Jacobians, where the keys are tuples of input and output indices, and the values are the Jacobian matrices.
|
|
771
710
|
"""
|
|
772
711
|
if input_output_mask is None:
|
|
773
712
|
input_output_mask = []
|
|
774
|
-
if kernel is not None:
|
|
775
|
-
wp.utils.warn(
|
|
776
|
-
"The argument `kernel` to the function `wp.autograd.jacobian` is deprecated in favor of the `function` argument and will be removed in a future Warp version.",
|
|
777
|
-
DeprecationWarning,
|
|
778
|
-
stacklevel=3,
|
|
779
|
-
)
|
|
780
|
-
function = kernel
|
|
781
713
|
|
|
782
714
|
if metadata is None:
|
|
783
715
|
metadata = FunctionMetadata()
|
|
@@ -868,20 +800,19 @@ def jacobian(
|
|
|
868
800
|
|
|
869
801
|
|
|
870
802
|
def jacobian_fd(
|
|
871
|
-
function:
|
|
872
|
-
dim:
|
|
873
|
-
inputs: Sequence = None,
|
|
874
|
-
outputs: Sequence = None,
|
|
875
|
-
input_output_mask:
|
|
803
|
+
function: wp.Kernel | Callable,
|
|
804
|
+
dim: tuple[int] | None | None = None,
|
|
805
|
+
inputs: Sequence | None = None,
|
|
806
|
+
outputs: Sequence | None = None,
|
|
807
|
+
input_output_mask: list[tuple[str | int, str | int]] | None = None,
|
|
876
808
|
device: wp.context.Devicelike = None,
|
|
877
809
|
max_blocks=0,
|
|
878
810
|
block_dim=256,
|
|
879
811
|
max_inputs_per_var=-1,
|
|
880
812
|
eps: float = 1e-4,
|
|
881
813
|
plot_jacobians=False,
|
|
882
|
-
metadata: FunctionMetadata = None,
|
|
883
|
-
|
|
884
|
-
) -> Dict[Tuple[int, int], wp.array]:
|
|
814
|
+
metadata: FunctionMetadata | None = None,
|
|
815
|
+
) -> dict[tuple[int, int], wp.array]:
|
|
885
816
|
"""
|
|
886
817
|
Computes the finite-difference Jacobian of a function or Warp kernel for the provided selection of differentiable inputs to differentiable outputs.
|
|
887
818
|
The method uses a central difference scheme to approximate the Jacobian.
|
|
@@ -911,20 +842,12 @@ def jacobian_fd(
|
|
|
911
842
|
eps: The finite-difference step size.
|
|
912
843
|
plot_jacobians: If True, visualizes the computed Jacobians in a plot (requires ``matplotlib``).
|
|
913
844
|
metadata: The metadata of the kernel function, containing the input and output labels, strides, and dtypes. If None or empty, the metadata is inferred from the kernel or function.
|
|
914
|
-
kernel: Deprecated argument. Use the ``function`` argument instead.
|
|
915
845
|
|
|
916
846
|
Returns:
|
|
917
847
|
A dictionary of Jacobians, where the keys are tuples of input and output indices, and the values are the Jacobian matrices.
|
|
918
848
|
"""
|
|
919
849
|
if input_output_mask is None:
|
|
920
850
|
input_output_mask = []
|
|
921
|
-
if kernel is not None:
|
|
922
|
-
wp.utils.warn(
|
|
923
|
-
"The argument `kernel` to the function `wp.autograd.jacobian` is deprecated in favor of the `function` argument and will be removed in a future Warp version.",
|
|
924
|
-
DeprecationWarning,
|
|
925
|
-
stacklevel=3,
|
|
926
|
-
)
|
|
927
|
-
function = kernel
|
|
928
851
|
|
|
929
852
|
if metadata is None:
|
|
930
853
|
metadata = FunctionMetadata()
|
|
@@ -1003,8 +926,8 @@ def jacobian_fd(
|
|
|
1003
926
|
outputs_until_right = [conditional_clone(output) for output in outputs_copy[:output_i]]
|
|
1004
927
|
outputs_after_left = [conditional_clone(output) for output in outputs_copy[output_i + 1 :]]
|
|
1005
928
|
outputs_after_right = [conditional_clone(output) for output in outputs_copy[output_i + 1 :]]
|
|
1006
|
-
left_outputs = outputs_until_left
|
|
1007
|
-
right_outputs = outputs_until_right
|
|
929
|
+
left_outputs = [*outputs_until_left, left, *outputs_after_left]
|
|
930
|
+
right_outputs = [*outputs_until_right, right, *outputs_after_right]
|
|
1008
931
|
|
|
1009
932
|
input_num = flat_input.shape[0]
|
|
1010
933
|
flat_input_copy = wp.clone(flat_input)
|
warp/bin/libwarp.dylib
CHANGED
|
Binary file
|