warp-lang 1.7.2rc1__py3-none-macosx_10_13_universal2.whl → 1.8.0__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.

Files changed (180) hide show
  1. warp/__init__.py +3 -1
  2. warp/__init__.pyi +3489 -1
  3. warp/autograd.py +45 -122
  4. warp/bin/libwarp.dylib +0 -0
  5. warp/build.py +241 -252
  6. warp/build_dll.py +125 -26
  7. warp/builtins.py +1907 -384
  8. warp/codegen.py +257 -101
  9. warp/config.py +12 -1
  10. warp/constants.py +1 -1
  11. warp/context.py +657 -223
  12. warp/dlpack.py +1 -1
  13. warp/examples/benchmarks/benchmark_cloth.py +2 -2
  14. warp/examples/benchmarks/benchmark_tile_sort.py +155 -0
  15. warp/examples/core/example_sample_mesh.py +1 -1
  16. warp/examples/core/example_spin_lock.py +93 -0
  17. warp/examples/core/example_work_queue.py +118 -0
  18. warp/examples/fem/example_adaptive_grid.py +5 -5
  19. warp/examples/fem/example_apic_fluid.py +1 -1
  20. warp/examples/fem/example_burgers.py +1 -1
  21. warp/examples/fem/example_convection_diffusion.py +9 -6
  22. warp/examples/fem/example_darcy_ls_optimization.py +489 -0
  23. warp/examples/fem/example_deformed_geometry.py +1 -1
  24. warp/examples/fem/example_diffusion.py +2 -2
  25. warp/examples/fem/example_diffusion_3d.py +1 -1
  26. warp/examples/fem/example_distortion_energy.py +1 -1
  27. warp/examples/fem/example_elastic_shape_optimization.py +387 -0
  28. warp/examples/fem/example_magnetostatics.py +5 -3
  29. warp/examples/fem/example_mixed_elasticity.py +5 -3
  30. warp/examples/fem/example_navier_stokes.py +11 -9
  31. warp/examples/fem/example_nonconforming_contact.py +5 -3
  32. warp/examples/fem/example_streamlines.py +8 -3
  33. warp/examples/fem/utils.py +9 -8
  34. warp/examples/interop/example_jax_ffi_callback.py +2 -2
  35. warp/examples/optim/example_drone.py +1 -1
  36. warp/examples/sim/example_cloth.py +1 -1
  37. warp/examples/sim/example_cloth_self_contact.py +48 -54
  38. warp/examples/tile/example_tile_block_cholesky.py +502 -0
  39. warp/examples/tile/example_tile_cholesky.py +2 -1
  40. warp/examples/tile/example_tile_convolution.py +1 -1
  41. warp/examples/tile/example_tile_filtering.py +1 -1
  42. warp/examples/tile/example_tile_matmul.py +1 -1
  43. warp/examples/tile/example_tile_mlp.py +2 -0
  44. warp/fabric.py +7 -7
  45. warp/fem/__init__.py +5 -0
  46. warp/fem/adaptivity.py +1 -1
  47. warp/fem/cache.py +152 -63
  48. warp/fem/dirichlet.py +2 -2
  49. warp/fem/domain.py +136 -6
  50. warp/fem/field/field.py +141 -99
  51. warp/fem/field/nodal_field.py +85 -39
  52. warp/fem/field/virtual.py +97 -52
  53. warp/fem/geometry/adaptive_nanogrid.py +91 -86
  54. warp/fem/geometry/closest_point.py +13 -0
  55. warp/fem/geometry/deformed_geometry.py +102 -40
  56. warp/fem/geometry/element.py +56 -2
  57. warp/fem/geometry/geometry.py +323 -22
  58. warp/fem/geometry/grid_2d.py +157 -62
  59. warp/fem/geometry/grid_3d.py +116 -20
  60. warp/fem/geometry/hexmesh.py +86 -20
  61. warp/fem/geometry/nanogrid.py +166 -86
  62. warp/fem/geometry/partition.py +59 -25
  63. warp/fem/geometry/quadmesh.py +86 -135
  64. warp/fem/geometry/tetmesh.py +47 -119
  65. warp/fem/geometry/trimesh.py +77 -270
  66. warp/fem/integrate.py +107 -52
  67. warp/fem/linalg.py +25 -58
  68. warp/fem/operator.py +124 -27
  69. warp/fem/quadrature/pic_quadrature.py +36 -14
  70. warp/fem/quadrature/quadrature.py +40 -16
  71. warp/fem/space/__init__.py +1 -1
  72. warp/fem/space/basis_function_space.py +66 -46
  73. warp/fem/space/basis_space.py +17 -4
  74. warp/fem/space/dof_mapper.py +1 -1
  75. warp/fem/space/function_space.py +2 -2
  76. warp/fem/space/grid_2d_function_space.py +4 -1
  77. warp/fem/space/hexmesh_function_space.py +4 -2
  78. warp/fem/space/nanogrid_function_space.py +3 -1
  79. warp/fem/space/partition.py +11 -2
  80. warp/fem/space/quadmesh_function_space.py +4 -1
  81. warp/fem/space/restriction.py +5 -2
  82. warp/fem/space/shape/__init__.py +10 -8
  83. warp/fem/space/tetmesh_function_space.py +4 -1
  84. warp/fem/space/topology.py +52 -21
  85. warp/fem/space/trimesh_function_space.py +4 -1
  86. warp/fem/utils.py +53 -8
  87. warp/jax.py +1 -2
  88. warp/jax_experimental/ffi.py +12 -17
  89. warp/jax_experimental/xla_ffi.py +37 -24
  90. warp/math.py +171 -1
  91. warp/native/array.h +99 -0
  92. warp/native/builtin.h +174 -31
  93. warp/native/coloring.cpp +1 -1
  94. warp/native/exports.h +118 -63
  95. warp/native/intersect.h +3 -3
  96. warp/native/mat.h +5 -10
  97. warp/native/mathdx.cpp +11 -5
  98. warp/native/matnn.h +1 -123
  99. warp/native/quat.h +28 -4
  100. warp/native/sparse.cpp +121 -258
  101. warp/native/sparse.cu +181 -274
  102. warp/native/spatial.h +305 -17
  103. warp/native/tile.h +583 -72
  104. warp/native/tile_radix_sort.h +1108 -0
  105. warp/native/tile_reduce.h +237 -2
  106. warp/native/tile_scan.h +240 -0
  107. warp/native/tuple.h +189 -0
  108. warp/native/vec.h +6 -16
  109. warp/native/warp.cpp +36 -4
  110. warp/native/warp.cu +574 -51
  111. warp/native/warp.h +47 -74
  112. warp/optim/linear.py +5 -1
  113. warp/paddle.py +7 -8
  114. warp/py.typed +0 -0
  115. warp/render/render_opengl.py +58 -29
  116. warp/render/render_usd.py +124 -61
  117. warp/sim/__init__.py +9 -0
  118. warp/sim/collide.py +252 -78
  119. warp/sim/graph_coloring.py +8 -1
  120. warp/sim/import_mjcf.py +4 -3
  121. warp/sim/import_usd.py +11 -7
  122. warp/sim/integrator.py +5 -2
  123. warp/sim/integrator_euler.py +1 -1
  124. warp/sim/integrator_featherstone.py +1 -1
  125. warp/sim/integrator_vbd.py +751 -320
  126. warp/sim/integrator_xpbd.py +1 -1
  127. warp/sim/model.py +265 -260
  128. warp/sim/utils.py +10 -7
  129. warp/sparse.py +303 -166
  130. warp/tape.py +52 -51
  131. warp/tests/cuda/test_conditional_captures.py +1046 -0
  132. warp/tests/cuda/test_streams.py +1 -1
  133. warp/tests/geometry/test_volume.py +2 -2
  134. warp/tests/interop/test_dlpack.py +9 -9
  135. warp/tests/interop/test_jax.py +0 -1
  136. warp/tests/run_coverage_serial.py +1 -1
  137. warp/tests/sim/disabled_kinematics.py +2 -2
  138. warp/tests/sim/{test_vbd.py → test_cloth.py} +296 -113
  139. warp/tests/sim/test_collision.py +159 -51
  140. warp/tests/sim/test_coloring.py +15 -1
  141. warp/tests/test_array.py +254 -2
  142. warp/tests/test_array_reduce.py +2 -2
  143. warp/tests/test_atomic_cas.py +299 -0
  144. warp/tests/test_codegen.py +142 -19
  145. warp/tests/test_conditional.py +47 -1
  146. warp/tests/test_ctypes.py +0 -20
  147. warp/tests/test_devices.py +8 -0
  148. warp/tests/test_fabricarray.py +4 -2
  149. warp/tests/test_fem.py +58 -25
  150. warp/tests/test_func.py +42 -1
  151. warp/tests/test_grad.py +1 -1
  152. warp/tests/test_lerp.py +1 -3
  153. warp/tests/test_map.py +481 -0
  154. warp/tests/test_mat.py +1 -24
  155. warp/tests/test_quat.py +6 -15
  156. warp/tests/test_rounding.py +10 -38
  157. warp/tests/test_runlength_encode.py +7 -7
  158. warp/tests/test_smoothstep.py +1 -1
  159. warp/tests/test_sparse.py +51 -2
  160. warp/tests/test_spatial.py +507 -1
  161. warp/tests/test_struct.py +2 -2
  162. warp/tests/test_tuple.py +265 -0
  163. warp/tests/test_types.py +2 -2
  164. warp/tests/test_utils.py +24 -18
  165. warp/tests/tile/test_tile.py +420 -1
  166. warp/tests/tile/test_tile_mathdx.py +518 -14
  167. warp/tests/tile/test_tile_reduce.py +213 -0
  168. warp/tests/tile/test_tile_shared_memory.py +130 -1
  169. warp/tests/tile/test_tile_sort.py +117 -0
  170. warp/tests/unittest_suites.py +4 -6
  171. warp/types.py +462 -308
  172. warp/utils.py +647 -86
  173. {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.0.dist-info}/METADATA +20 -6
  174. {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.0.dist-info}/RECORD +177 -165
  175. warp/stubs.py +0 -3381
  176. warp/tests/sim/test_xpbd.py +0 -399
  177. warp/tests/test_mlp.py +0 -282
  178. {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.0.dist-info}/WHEEL +0 -0
  179. {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.0.dist-info}/licenses/LICENSE.md +0 -0
  180. {warp_lang-1.7.2rc1.dist-info → warp_lang-1.8.0.dist-info}/top_level.txt +0 -0
warp/stubs.py DELETED
@@ -1,3381 +0,0 @@
1
- # SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
- # SPDX-License-Identifier: Apache-2.0
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- # Autogenerated file, do not edit, this file provides stubs for builtins autocomplete in VSCode, PyCharm, etc
17
-
18
- from typing import Any
19
- from typing import Tuple
20
- from typing import Callable
21
- from typing import TypeVar
22
- from typing import Generic
23
- from typing import overload as over
24
-
25
- Length = TypeVar("Length", bound=int)
26
- Rows = TypeVar("Rows", bound=int)
27
- Cols = TypeVar("Cols", bound=int)
28
- DType = TypeVar("DType")
29
- Vector = Generic[Length, Scalar]
30
- Matrix = Generic[Rows, Cols, Scalar]
31
- Quaternion = Generic[Float]
32
- Transformation = Generic[Float]
33
- Array = Generic[DType]
34
- FabricArray = Generic[DType]
35
- IndexedFabricArray = Generic[DType]
36
-
37
-
38
- from warp.types import array, array1d, array2d, array3d, array4d, constant, from_ptr
39
- from warp.types import indexedarray, indexedarray1d, indexedarray2d, indexedarray3d, indexedarray4d
40
- from warp.fabric import fabricarray, fabricarrayarray, indexedfabricarray, indexedfabricarrayarray
41
-
42
- from warp.types import bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64, float16, float32, float64
43
- from warp.types import vec2, vec2b, vec2ub, vec2s, vec2us, vec2i, vec2ui, vec2l, vec2ul, vec2h, vec2f, vec2d
44
- from warp.types import vec3, vec3b, vec3ub, vec3s, vec3us, vec3i, vec3ui, vec3l, vec3ul, vec3h, vec3f, vec3d
45
- from warp.types import vec4, vec4b, vec4ub, vec4s, vec4us, vec4i, vec4ui, vec4l, vec4ul, vec4h, vec4f, vec4d
46
- from warp.types import mat22, mat22h, mat22f, mat22d
47
- from warp.types import mat33, mat33h, mat33f, mat33d
48
- from warp.types import mat44, mat44h, mat44f, mat44d
49
- from warp.types import quat, quath, quatf, quatd
50
- from warp.types import transform, transformh, transformf, transformd
51
- from warp.types import spatial_vector, spatial_vectorh, spatial_vectorf, spatial_vectord
52
- from warp.types import spatial_matrix, spatial_matrixh, spatial_matrixf, spatial_matrixd
53
-
54
- from warp.types import Int, Float, Scalar
55
-
56
- from warp.types import Bvh, Mesh, HashGrid, Volume, MarchingCubes
57
- from warp.types import BvhQuery, HashGridQuery, MeshQueryAABB, MeshQueryPoint, MeshQueryRay
58
-
59
- from warp.types import matmul, adj_matmul, batched_matmul, adj_batched_matmul
60
-
61
- from warp.types import vector as vec
62
- from warp.types import matrix as mat
63
-
64
- from warp.types import dtype_from_numpy, dtype_to_numpy
65
-
66
- from warp.types import from_ipc_handle
67
-
68
- from warp.context import init, func, func_grad, func_replay, func_native, kernel, struct, overload
69
- from warp.context import is_cpu_available, is_cuda_available, is_device_available
70
- from warp.context import get_devices, get_preferred_device
71
- from warp.context import get_cuda_devices, get_cuda_device_count, get_cuda_device, map_cuda_device, unmap_cuda_device
72
- from warp.context import get_device, set_device, synchronize_device
73
- from warp.context import (
74
- zeros,
75
- zeros_like,
76
- ones,
77
- ones_like,
78
- full,
79
- full_like,
80
- clone,
81
- empty,
82
- empty_like,
83
- copy,
84
- from_numpy,
85
- launch,
86
- launch_tiled,
87
- synchronize,
88
- force_load,
89
- load_module,
90
- event_from_ipc_handle,
91
- )
92
- from warp.context import set_module_options, get_module_options, get_module
93
- from warp.context import capture_begin, capture_end, capture_launch
94
- from warp.context import Kernel, Function, Launch
95
- from warp.context import Stream, get_stream, set_stream, wait_stream, synchronize_stream
96
- from warp.context import Event, record_event, wait_event, synchronize_event, get_event_elapsed_time
97
- from warp.context import RegisteredGLBuffer
98
- from warp.context import is_mempool_supported, is_mempool_enabled, set_mempool_enabled
99
- from warp.context import (
100
- set_mempool_release_threshold,
101
- get_mempool_release_threshold,
102
- get_mempool_used_mem_current,
103
- get_mempool_used_mem_high,
104
- )
105
- from warp.context import is_mempool_access_supported, is_mempool_access_enabled, set_mempool_access_enabled
106
- from warp.context import is_peer_access_supported, is_peer_access_enabled, set_peer_access_enabled
107
-
108
- from warp.tape import Tape
109
- from warp.utils import ScopedTimer, ScopedDevice, ScopedStream
110
- from warp.utils import ScopedMempool, ScopedMempoolAccess, ScopedPeerAccess
111
- from warp.utils import ScopedCapture
112
- from warp.utils import transform_expand, quat_between_vectors
113
- from warp.utils import TimingResult, timing_begin, timing_end, timing_print
114
- from warp.utils import (
115
- TIMING_KERNEL,
116
- TIMING_KERNEL_BUILTIN,
117
- TIMING_MEMCPY,
118
- TIMING_MEMSET,
119
- TIMING_GRAPH,
120
- TIMING_ALL,
121
- )
122
-
123
- from warp.torch import from_torch, to_torch
124
- from warp.torch import dtype_from_torch, dtype_to_torch
125
- from warp.torch import device_from_torch, device_to_torch
126
- from warp.torch import stream_from_torch, stream_to_torch
127
-
128
- from warp.jax import from_jax, to_jax
129
- from warp.jax import dtype_from_jax, dtype_to_jax
130
- from warp.jax import device_from_jax, device_to_jax
131
-
132
- from warp.dlpack import from_dlpack, to_dlpack
133
-
134
- from warp.paddle import from_paddle, to_paddle
135
- from warp.paddle import dtype_from_paddle, dtype_to_paddle
136
- from warp.paddle import device_from_paddle, device_to_paddle
137
- from warp.paddle import stream_from_paddle
138
-
139
- from warp.build import clear_kernel_cache
140
- from warp.build import clear_lto_cache
141
-
142
- from warp.constants import *
143
-
144
- from . import builtins
145
- from warp.builtins import static
146
-
147
- from warp.math import *
148
-
149
- import warp.config as config
150
-
151
- __version__ = config.version
152
-
153
-
154
- @over
155
- def min(a: Scalar, b: Scalar) -> Scalar:
156
- """Return the minimum of two scalars."""
157
- ...
158
-
159
-
160
- @over
161
- def min(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
162
- """Return the element-wise minimum of two vectors."""
163
- ...
164
-
165
-
166
- @over
167
- def min(a: Vector[Any, Scalar]) -> Scalar:
168
- """Return the minimum element of a vector ``a``."""
169
- ...
170
-
171
-
172
- @over
173
- def max(a: Scalar, b: Scalar) -> Scalar:
174
- """Return the maximum of two scalars."""
175
- ...
176
-
177
-
178
- @over
179
- def max(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
180
- """Return the element-wise maximum of two vectors."""
181
- ...
182
-
183
-
184
- @over
185
- def max(a: Vector[Any, Scalar]) -> Scalar:
186
- """Return the maximum element of a vector ``a``."""
187
- ...
188
-
189
-
190
- @over
191
- def clamp(x: Scalar, low: Scalar, high: Scalar) -> Scalar:
192
- """Clamp the value of ``x`` to the range [low, high]."""
193
- ...
194
-
195
-
196
- @over
197
- def abs(x: Scalar) -> Scalar:
198
- """Return the absolute value of ``x``."""
199
- ...
200
-
201
-
202
- @over
203
- def abs(x: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
204
- """Return the absolute values of the elements of ``x``."""
205
- ...
206
-
207
-
208
- @over
209
- def sign(x: Scalar) -> Scalar:
210
- """Return -1 if ``x`` < 0, return 1 otherwise."""
211
- ...
212
-
213
-
214
- @over
215
- def sign(x: Vector[Any, Scalar]) -> Scalar:
216
- """Return -1 for the negative elements of ``x``, and 1 otherwise."""
217
- ...
218
-
219
-
220
- @over
221
- def step(x: Scalar) -> Scalar:
222
- """Return 1.0 if ``x`` < 0.0, return 0.0 otherwise."""
223
- ...
224
-
225
-
226
- @over
227
- def nonzero(x: Scalar) -> Scalar:
228
- """Return 1.0 if ``x`` is not equal to zero, return 0.0 otherwise."""
229
- ...
230
-
231
-
232
- @over
233
- def sin(x: Float) -> Float:
234
- """Return the sine of ``x`` in radians."""
235
- ...
236
-
237
-
238
- @over
239
- def cos(x: Float) -> Float:
240
- """Return the cosine of ``x`` in radians."""
241
- ...
242
-
243
-
244
- @over
245
- def acos(x: Float) -> Float:
246
- """Return arccos of ``x`` in radians. Inputs are automatically clamped to [-1.0, 1.0]."""
247
- ...
248
-
249
-
250
- @over
251
- def asin(x: Float) -> Float:
252
- """Return arcsin of ``x`` in radians. Inputs are automatically clamped to [-1.0, 1.0]."""
253
- ...
254
-
255
-
256
- @over
257
- def sqrt(x: Float) -> Float:
258
- """Return the square root of ``x``, where ``x`` is positive."""
259
- ...
260
-
261
-
262
- @over
263
- def cbrt(x: Float) -> Float:
264
- """Return the cube root of ``x``."""
265
- ...
266
-
267
-
268
- @over
269
- def tan(x: Float) -> Float:
270
- """Return the tangent of ``x`` in radians."""
271
- ...
272
-
273
-
274
- @over
275
- def atan(x: Float) -> Float:
276
- """Return the arctangent of ``x`` in radians."""
277
- ...
278
-
279
-
280
- @over
281
- def atan2(y: Float, x: Float) -> Float:
282
- """Return the 2-argument arctangent, atan2, of the point ``(x, y)`` in radians."""
283
- ...
284
-
285
-
286
- @over
287
- def sinh(x: Float) -> Float:
288
- """Return the sinh of ``x``."""
289
- ...
290
-
291
-
292
- @over
293
- def cosh(x: Float) -> Float:
294
- """Return the cosh of ``x``."""
295
- ...
296
-
297
-
298
- @over
299
- def tanh(x: Float) -> Float:
300
- """Return the tanh of ``x``."""
301
- ...
302
-
303
-
304
- @over
305
- def degrees(x: Float) -> Float:
306
- """Convert ``x`` from radians into degrees."""
307
- ...
308
-
309
-
310
- @over
311
- def radians(x: Float) -> Float:
312
- """Convert ``x`` from degrees into radians."""
313
- ...
314
-
315
-
316
- @over
317
- def log(x: Float) -> Float:
318
- """Return the natural logarithm (base-e) of ``x``, where ``x`` is positive."""
319
- ...
320
-
321
-
322
- @over
323
- def log2(x: Float) -> Float:
324
- """Return the binary logarithm (base-2) of ``x``, where ``x`` is positive."""
325
- ...
326
-
327
-
328
- @over
329
- def log10(x: Float) -> Float:
330
- """Return the common logarithm (base-10) of ``x``, where ``x`` is positive."""
331
- ...
332
-
333
-
334
- @over
335
- def exp(x: Float) -> Float:
336
- """Return the value of the exponential function :math:`e^x`."""
337
- ...
338
-
339
-
340
- @over
341
- def pow(x: Float, y: Float) -> Float:
342
- """Return the result of ``x`` raised to power of ``y``."""
343
- ...
344
-
345
-
346
- @over
347
- def round(x: Float) -> Float:
348
- """Return the nearest integer value to ``x``, rounding halfway cases away from zero.
349
-
350
- This is the most intuitive form of rounding in the colloquial sense, but can be slower than other options like :func:`warp.rint()`.
351
- Differs from :func:`numpy.round()`, which behaves the same way as :func:`numpy.rint()`.
352
- """
353
- ...
354
-
355
-
356
- @over
357
- def rint(x: Float) -> Float:
358
- """Return the nearest integer value to ``x``, rounding halfway cases to nearest even integer.
359
-
360
- It is generally faster than :func:`warp.round()`. Equivalent to :func:`numpy.rint()`.
361
- """
362
- ...
363
-
364
-
365
- @over
366
- def trunc(x: Float) -> Float:
367
- """Return the nearest integer that is closer to zero than ``x``.
368
-
369
- In other words, it discards the fractional part of ``x``.
370
- It is similar to casting ``float(int(a))``, but preserves the negative sign when ``x`` is in the range [-0.0, -1.0).
371
- Equivalent to :func:`numpy.trunc()` and :func:`numpy.fix()`.
372
- """
373
- ...
374
-
375
-
376
- @over
377
- def floor(x: Float) -> Float:
378
- """Return the largest integer that is less than or equal to ``x``."""
379
- ...
380
-
381
-
382
- @over
383
- def ceil(x: Float) -> Float:
384
- """Return the smallest integer that is greater than or equal to ``x``."""
385
- ...
386
-
387
-
388
- @over
389
- def frac(x: Float) -> Float:
390
- """Retrieve the fractional part of ``x``.
391
-
392
- In other words, it discards the integer part of ``x`` and is equivalent to ``x - trunc(x)``.
393
- """
394
- ...
395
-
396
-
397
- @over
398
- def isfinite(a: Scalar) -> bool:
399
- """Return ``True`` if ``a`` is a finite number, otherwise return ``False``."""
400
- ...
401
-
402
-
403
- @over
404
- def isfinite(a: Vector[Any, Scalar]) -> bool:
405
- """Return ``True`` if all elements of the vector ``a`` are finite, otherwise return ``False``."""
406
- ...
407
-
408
-
409
- @over
410
- def isfinite(a: Quaternion[Scalar]) -> bool:
411
- """Return ``True`` if all elements of the quaternion ``a`` are finite, otherwise return ``False``."""
412
- ...
413
-
414
-
415
- @over
416
- def isfinite(a: Matrix[Any, Any, Scalar]) -> bool:
417
- """Return ``True`` if all elements of the matrix ``a`` are finite, otherwise return ``False``."""
418
- ...
419
-
420
-
421
- @over
422
- def isnan(a: Scalar) -> bool:
423
- """Return ``True`` if ``a`` is NaN, otherwise return ``False``."""
424
- ...
425
-
426
-
427
- @over
428
- def isnan(a: Vector[Any, Scalar]) -> bool:
429
- """Return ``True`` if any element of the vector ``a`` is NaN, otherwise return ``False``."""
430
- ...
431
-
432
-
433
- @over
434
- def isnan(a: Quaternion[Scalar]) -> bool:
435
- """Return ``True`` if any element of the quaternion ``a`` is NaN, otherwise return ``False``."""
436
- ...
437
-
438
-
439
- @over
440
- def isnan(a: Matrix[Any, Any, Scalar]) -> bool:
441
- """Return ``True`` if any element of the matrix ``a`` is NaN, otherwise return ``False``."""
442
- ...
443
-
444
-
445
- @over
446
- def isinf(a: Scalar) -> bool:
447
- """Return ``True`` if ``a`` is positive or negative infinity, otherwise return ``False``."""
448
- ...
449
-
450
-
451
- @over
452
- def isinf(a: Vector[Any, Scalar]) -> bool:
453
- """Return ``True`` if any element of the vector ``a`` is positive or negative infinity, otherwise return ``False``."""
454
- ...
455
-
456
-
457
- @over
458
- def isinf(a: Quaternion[Scalar]) -> bool:
459
- """Return ``True`` if any element of the quaternion ``a`` is positive or negative infinity, otherwise return ``False``."""
460
- ...
461
-
462
-
463
- @over
464
- def isinf(a: Matrix[Any, Any, Scalar]) -> bool:
465
- """Return ``True`` if any element of the matrix ``a`` is positive or negative infinity, otherwise return ``False``."""
466
- ...
467
-
468
-
469
- @over
470
- def dot(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Scalar:
471
- """Compute the dot product between two vectors."""
472
- ...
473
-
474
-
475
- @over
476
- def dot(a: Quaternion[Float], b: Quaternion[Float]) -> Float:
477
- """Compute the dot product between two quaternions."""
478
- ...
479
-
480
-
481
- @over
482
- def ddot(a: Matrix[Any, Any, Scalar], b: Matrix[Any, Any, Scalar]) -> Scalar:
483
- """Compute the double dot product between two matrices."""
484
- ...
485
-
486
-
487
- @over
488
- def argmin(a: Vector[Any, Scalar]) -> uint32:
489
- """Return the index of the minimum element of a vector ``a``."""
490
- ...
491
-
492
-
493
- @over
494
- def argmax(a: Vector[Any, Scalar]) -> uint32:
495
- """Return the index of the maximum element of a vector ``a``."""
496
- ...
497
-
498
-
499
- @over
500
- def outer(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Matrix[Any, Any, Scalar]:
501
- """Compute the outer product ``a*b^T`` for two vectors."""
502
- ...
503
-
504
-
505
- @over
506
- def cross(a: Vector[3, Scalar], b: Vector[3, Scalar]) -> Vector[3, Scalar]:
507
- """Compute the cross product of two 3D vectors."""
508
- ...
509
-
510
-
511
- @over
512
- def skew(vec: Vector[3, Scalar]) -> Matrix[3, 3, Scalar]:
513
- """Compute the skew-symmetric 3x3 matrix for a 3D vector ``vec``."""
514
- ...
515
-
516
-
517
- @over
518
- def length(a: Vector[Any, Float]) -> Float:
519
- """Compute the length of a floating-point vector ``a``."""
520
- ...
521
-
522
-
523
- @over
524
- def length(a: Quaternion[Float]) -> Float:
525
- """Compute the length of a quaternion ``a``."""
526
- ...
527
-
528
-
529
- @over
530
- def length_sq(a: Vector[Any, Scalar]) -> Scalar:
531
- """Compute the squared length of a vector ``a``."""
532
- ...
533
-
534
-
535
- @over
536
- def length_sq(a: Quaternion[Scalar]) -> Scalar:
537
- """Compute the squared length of a quaternion ``a``."""
538
- ...
539
-
540
-
541
- @over
542
- def normalize(a: Vector[Any, Float]) -> Vector[Any, Float]:
543
- """Compute the normalized value of ``a``. If ``length(a)`` is 0 then the zero vector is returned."""
544
- ...
545
-
546
-
547
- @over
548
- def normalize(a: Quaternion[Float]) -> Quaternion[Float]:
549
- """Compute the normalized value of ``a``. If ``length(a)`` is 0, then the zero quaternion is returned."""
550
- ...
551
-
552
-
553
- @over
554
- def transpose(a: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
555
- """Return the transpose of the matrix ``a``."""
556
- ...
557
-
558
-
559
- @over
560
- def inverse(a: Matrix[2, 2, Float]) -> Matrix[Any, Any, Float]:
561
- """Return the inverse of a 2x2 matrix ``a``."""
562
- ...
563
-
564
-
565
- @over
566
- def inverse(a: Matrix[3, 3, Float]) -> Matrix[Any, Any, Float]:
567
- """Return the inverse of a 3x3 matrix ``a``."""
568
- ...
569
-
570
-
571
- @over
572
- def inverse(a: Matrix[4, 4, Float]) -> Matrix[Any, Any, Float]:
573
- """Return the inverse of a 4x4 matrix ``a``."""
574
- ...
575
-
576
-
577
- @over
578
- def determinant(a: Matrix[2, 2, Float]) -> Float:
579
- """Return the determinant of a 2x2 matrix ``a``."""
580
- ...
581
-
582
-
583
- @over
584
- def determinant(a: Matrix[3, 3, Float]) -> Float:
585
- """Return the determinant of a 3x3 matrix ``a``."""
586
- ...
587
-
588
-
589
- @over
590
- def determinant(a: Matrix[4, 4, Float]) -> Float:
591
- """Return the determinant of a 4x4 matrix ``a``."""
592
- ...
593
-
594
-
595
- @over
596
- def trace(a: Matrix[Any, Any, Scalar]) -> Scalar:
597
- """Return the trace of the matrix ``a``."""
598
- ...
599
-
600
-
601
- @over
602
- def diag(vec: Vector[Any, Scalar]) -> Matrix[Any, Any, Scalar]:
603
- """Returns a matrix with the components of the vector ``vec`` on the diagonal."""
604
- ...
605
-
606
-
607
- @over
608
- def get_diag(mat: Matrix[Any, Any, Scalar]) -> Vector[Any, Scalar]:
609
- """Returns a vector containing the diagonal elements of the square matrix ``mat``."""
610
- ...
611
-
612
-
613
- @over
614
- def cw_mul(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
615
- """Component-wise multiplication of two vectors."""
616
- ...
617
-
618
-
619
- @over
620
- def cw_mul(a: Matrix[Any, Any, Scalar], b: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
621
- """Component-wise multiplication of two matrices."""
622
- ...
623
-
624
-
625
- @over
626
- def cw_div(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
627
- """Component-wise division of two vectors."""
628
- ...
629
-
630
-
631
- @over
632
- def cw_div(a: Matrix[Any, Any, Scalar], b: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
633
- """Component-wise division of two matrices."""
634
- ...
635
-
636
-
637
- @over
638
- def vector(*args: Scalar, length: int32, dtype: Scalar) -> Vector[Any, Scalar]:
639
- """Construct a vector of given length and dtype."""
640
- ...
641
-
642
-
643
- @over
644
- def matrix(pos: Vector[3, Float], rot: Quaternion[Float], scale: Vector[3, Float], dtype: Float) -> Matrix[4, 4, Float]:
645
- """Construct a 4x4 transformation matrix that applies the transformations as
646
- Translation(pos)*Rotation(rot)*Scaling(scale) when applied to column vectors, i.e.: y = (TRS)*x
647
- """
648
- ...
649
-
650
-
651
- @over
652
- def matrix(*args: Scalar, shape: Tuple[int, int], dtype: Scalar) -> Matrix[Any, Any, Scalar]:
653
- """Construct a matrix. If the positional ``arg_types`` are not given, then matrix will be zero-initialized."""
654
- ...
655
-
656
-
657
- @over
658
- def matrix_from_cols(*args: Vector[Any, Scalar]) -> Matrix[Any, Any, Scalar]:
659
- """Construct a matrix from column vectors."""
660
- ...
661
-
662
-
663
- @over
664
- def matrix_from_rows(*args: Vector[Any, Scalar]) -> Matrix[Any, Any, Scalar]:
665
- """Construct a matrix from row vectors."""
666
- ...
667
-
668
-
669
- @over
670
- def identity(n: int32, dtype: Scalar) -> Matrix[Any, Any, Scalar]:
671
- """Create an identity matrix with shape=(n,n) with the type given by ``dtype``."""
672
- ...
673
-
674
-
675
- @over
676
- def svd3(A: Matrix[3, 3, Float], U: Matrix[3, 3, Float], sigma: Vector[3, Float], V: Matrix[3, 3, Scalar]):
677
- """Compute the SVD of a 3x3 matrix ``A``. The singular values are returned in ``sigma``,
678
- while the left and right basis vectors are returned in ``U`` and ``V``.
679
- """
680
- ...
681
-
682
-
683
- @over
684
- def svd2(A: Matrix[2, 2, Float], U: Matrix[2, 2, Float], sigma: Vector[2, Float], V: Matrix[2, 2, Scalar]):
685
- """Compute the SVD of a 2x2 matrix ``A``. The singular values are returned in ``sigma``,
686
- while the left and right basis vectors are returned in ``U`` and ``V``.
687
- """
688
- ...
689
-
690
-
691
- @over
692
- def qr3(A: Matrix[3, 3, Float], Q: Matrix[3, 3, Float], R: Matrix[3, 3, Float]):
693
- """Compute the QR decomposition of a 3x3 matrix ``A``. The orthogonal matrix is returned in ``Q``,
694
- while the upper triangular matrix is returned in ``R``.
695
- """
696
- ...
697
-
698
-
699
- @over
700
- def eig3(A: Matrix[3, 3, Float], Q: Matrix[3, 3, Float], d: Vector[3, Float]):
701
- """Compute the eigendecomposition of a 3x3 matrix ``A``. The eigenvectors are returned as the columns of ``Q``,
702
- while the corresponding eigenvalues are returned in ``d``.
703
- """
704
- ...
705
-
706
-
707
- @over
708
- def quaternion(dtype: Float) -> Quaternion[Float]:
709
- """Construct a zero-initialized quaternion. Quaternions are laid out as
710
- [ix, iy, iz, r], where ix, iy, iz are the imaginary part, and r the real part.
711
- """
712
- ...
713
-
714
-
715
- @over
716
- def quaternion(x: Float, y: Float, z: Float, w: Float, dtype: Scalar) -> Quaternion[Float]:
717
- """Create a quaternion using the supplied components (type inferred from component type)."""
718
- ...
719
-
720
-
721
- @over
722
- def quaternion(ijk: Vector[3, Float], real: Float, dtype: Float) -> Quaternion[Float]:
723
- """Create a quaternion using the supplied vector/scalar (type inferred from scalar type)."""
724
- ...
725
-
726
-
727
- @over
728
- def quaternion(quat: Quaternion[Float], dtype: Float) -> Quaternion[Float]:
729
- """Construct a quaternion of type dtype from another quaternion of a different dtype."""
730
- ...
731
-
732
-
733
- @over
734
- def quat_identity(dtype: Float) -> quatf:
735
- """Construct an identity quaternion with zero imaginary part and real part of 1.0"""
736
- ...
737
-
738
-
739
- @over
740
- def quat_from_axis_angle(axis: Vector[3, Float], angle: Float) -> Quaternion[Float]:
741
- """Construct a quaternion representing a rotation of angle radians around the given axis."""
742
- ...
743
-
744
-
745
- @over
746
- def quat_to_axis_angle(quat: Quaternion[Float], axis: Vector[3, Float], angle: Float):
747
- """Extract the rotation axis and angle radians a quaternion represents."""
748
- ...
749
-
750
-
751
- @over
752
- def quat_from_matrix(mat: Matrix[3, 3, Float]) -> Quaternion[Float]:
753
- """Construct a quaternion from a 3x3 matrix.
754
-
755
- If the matrix is not a pure rotation, but for example includes scaling or skewing, the result is undefined.
756
- """
757
- ...
758
-
759
-
760
- @over
761
- def quat_from_matrix(mat: Matrix[4, 4, Float]) -> Quaternion[Float]:
762
- """Construct a quaternion from a 4x4 matrix.
763
-
764
- If the top-left 3x3 block of the matrix is not a pure rotation, but for example includes scaling or skewing, the result is undefined.
765
- """
766
- ...
767
-
768
-
769
- @over
770
- def quat_rpy(roll: Float, pitch: Float, yaw: Float) -> Quaternion[Float]:
771
- """Construct a quaternion representing a combined roll (z), pitch (x), yaw rotations (y) in radians."""
772
- ...
773
-
774
-
775
- @over
776
- def quat_inverse(quat: Quaternion[Float]) -> Quaternion[Float]:
777
- """Compute quaternion conjugate."""
778
- ...
779
-
780
-
781
- @over
782
- def quat_rotate(quat: Quaternion[Float], vec: Vector[3, Float]) -> Vector[3, Float]:
783
- """Rotate a vector by a quaternion."""
784
- ...
785
-
786
-
787
- @over
788
- def quat_rotate_inv(quat: Quaternion[Float], vec: Vector[3, Float]) -> Vector[3, Float]:
789
- """Rotate a vector by the inverse of a quaternion."""
790
- ...
791
-
792
-
793
- @over
794
- def quat_slerp(a: Quaternion[Float], b: Quaternion[Float], t: Float) -> Quaternion[Float]:
795
- """Linearly interpolate between two quaternions."""
796
- ...
797
-
798
-
799
- @over
800
- def quat_to_matrix(quat: Quaternion[Float]) -> Matrix[3, 3, Float]:
801
- """Convert a quaternion to a 3x3 rotation matrix."""
802
- ...
803
-
804
-
805
- @over
806
- def transformation(pos: Vector[3, Float], rot: Quaternion[Float], dtype: Float) -> Transformation[Float]:
807
- """Construct a rigid-body transformation with translation part ``pos`` and rotation ``rot``."""
808
- ...
809
-
810
-
811
- @over
812
- def transform_identity(dtype: Float) -> transformf:
813
- """Construct an identity transform with zero translation and identity rotation."""
814
- ...
815
-
816
-
817
- @over
818
- def transform_get_translation(xform: Transformation[Float]) -> Vector[3, Float]:
819
- """Return the translational part of a transform ``xform``."""
820
- ...
821
-
822
-
823
- @over
824
- def transform_get_rotation(xform: Transformation[Float]) -> Quaternion[Float]:
825
- """Return the rotational part of a transform ``xform``."""
826
- ...
827
-
828
-
829
- @over
830
- def transform_multiply(a: Transformation[Float], b: Transformation[Float]) -> Transformation[Float]:
831
- """Multiply two rigid body transformations together."""
832
- ...
833
-
834
-
835
- @over
836
- def transform_point(xform: Transformation[Float], point: Vector[3, Float]) -> Vector[3, Float]:
837
- """Apply the transform to a point ``point`` treating the homogeneous coordinate as w=1 (translation and rotation)."""
838
- ...
839
-
840
-
841
- @over
842
- def transform_point(mat: Matrix[4, 4, Float], point: Vector[3, Float]) -> Vector[3, Float]:
843
- """Apply the transform to a point ``point`` treating the homogeneous coordinate as w=1.
844
-
845
- The transformation is applied treating ``point`` as a column vector, e.g.: ``y = mat*point``.
846
-
847
- This is in contrast to some libraries, notably USD, which applies transforms to row vectors, ``y^T = point^T*mat^T``.
848
- If the transform is coming from a library that uses row-vectors, then users should transpose the transformation
849
- matrix before calling this method.
850
- """
851
- ...
852
-
853
-
854
- @over
855
- def transform_vector(xform: Transformation[Float], vec: Vector[3, Float]) -> Vector[3, Float]:
856
- """Apply the transform to a vector ``vec`` treating the homogeneous coordinate as w=0 (rotation only)."""
857
- ...
858
-
859
-
860
- @over
861
- def transform_vector(mat: Matrix[4, 4, Float], vec: Vector[3, Float]) -> Vector[3, Float]:
862
- """Apply the transform to a vector ``vec`` treating the homogeneous coordinate as w=0.
863
-
864
- The transformation is applied treating ``vec`` as a column vector, e.g.: ``y = mat*vec``.
865
-
866
- This is in contrast to some libraries, notably USD, which applies transforms to row vectors, ``y^T = vec^T*mat^T``.
867
- If the transform is coming from a library that uses row-vectors, then users should transpose the transformation
868
- matrix before calling this method.
869
- """
870
- ...
871
-
872
-
873
- @over
874
- def transform_inverse(xform: Transformation[Float]) -> Transformation[Float]:
875
- """Compute the inverse of the transformation ``xform``."""
876
- ...
877
-
878
-
879
- @over
880
- def spatial_vector(dtype: Float) -> Vector[6, Float]:
881
- """Zero-initialize a 6D screw vector."""
882
- ...
883
-
884
-
885
- @over
886
- def spatial_vector(w: Vector[3, Float], v: Vector[3, Float], dtype: Float) -> Vector[6, Float]:
887
- """Construct a 6D screw vector from two 3D vectors."""
888
- ...
889
-
890
-
891
- @over
892
- def spatial_vector(wx: Float, wy: Float, wz: Float, vx: Float, vy: Float, vz: Float, dtype: Float) -> Vector[6, Float]:
893
- """Construct a 6D screw vector from six values."""
894
- ...
895
-
896
-
897
- @over
898
- def spatial_adjoint(r: Matrix[3, 3, Float], s: Matrix[3, 3, Float]) -> Matrix[6, 6, Float]:
899
- """Construct a 6x6 spatial inertial matrix from two 3x3 diagonal blocks."""
900
- ...
901
-
902
-
903
- @over
904
- def spatial_dot(a: Vector[6, Float], b: Vector[6, Float]) -> Float:
905
- """Compute the dot product of two 6D screw vectors."""
906
- ...
907
-
908
-
909
- @over
910
- def spatial_cross(a: Vector[6, Float], b: Vector[6, Float]) -> Vector[6, Float]:
911
- """Compute the cross product of two 6D screw vectors."""
912
- ...
913
-
914
-
915
- @over
916
- def spatial_cross_dual(a: Vector[6, Float], b: Vector[6, Float]) -> Vector[6, Float]:
917
- """Compute the dual cross product of two 6D screw vectors."""
918
- ...
919
-
920
-
921
- @over
922
- def spatial_top(svec: Vector[6, Float]) -> Vector[3, Float]:
923
- """Return the top (first) part of a 6D screw vector."""
924
- ...
925
-
926
-
927
- @over
928
- def spatial_bottom(svec: Vector[6, Float]) -> Vector[3, Float]:
929
- """Return the bottom (second) part of a 6D screw vector."""
930
- ...
931
-
932
-
933
- @over
934
- def spatial_jacobian(
935
- S: Array[Vector[6, Float]],
936
- joint_parents: Array[int32],
937
- joint_qd_start: Array[int32],
938
- joint_start: int32,
939
- joint_count: int32,
940
- J_start: int32,
941
- J_out: Array[Float],
942
- ):
943
- """ """
944
- ...
945
-
946
-
947
- @over
948
- def spatial_mass(
949
- I_s: Array[Matrix[6, 6, Float]], joint_start: int32, joint_count: int32, M_start: int32, M: Array[Float]
950
- ):
951
- """ """
952
- ...
953
-
954
-
955
- @over
956
- def tile_zeros(shape: Tuple[int, ...], dtype: Any, storage: str) -> Tile:
957
- """Allocate a tile of zero-initialized items.
958
-
959
- :param shape: Shape of the output tile
960
- :param dtype: Data type of output tile's elements (default float)
961
- :param storage: The storage location for the tile: ``"register"`` for registers
962
- (default) or ``"shared"`` for shared memory.
963
- :returns: A zero-initialized tile with shape and data type as specified
964
- """
965
- ...
966
-
967
-
968
- @over
969
- def tile_ones(shape: Tuple[int, ...], dtype: Any, storage: str) -> Tile:
970
- """Allocate a tile of one-initialized items.
971
-
972
- :param shape: Shape of the output tile
973
- :param dtype: Data type of output tile's elements
974
- :param storage: The storage location for the tile: ``"register"`` for registers
975
- (default) or ``"shared"`` for shared memory.
976
- :returns: A one-initialized tile with shape and data type as specified
977
- """
978
- ...
979
-
980
-
981
- @over
982
- def tile_arange(*args: Scalar, dtype: Any, storage: str) -> Tile:
983
- """Generate a tile of linearly spaced elements.
984
-
985
- :param args: Variable-length positional arguments, interpreted as:
986
-
987
- - ``(stop,)``: Generates values from ``0`` to ``stop - 1``
988
- - ``(start, stop)``: Generates values from ``start`` to ``stop - 1``
989
- - ``(start, stop, step)``: Generates values from ``start`` to ``stop - 1`` with a step size
990
-
991
- :param dtype: Data type of output tile's elements (optional, default: ``float``)
992
- :param storage: The storage location for the tile: ``"register"`` for registers
993
- (default) or ``"shared"`` for shared memory.
994
- :returns: A tile with ``shape=(n)`` with linearly spaced elements of specified data type
995
- """
996
- ...
997
-
998
-
999
- @over
1000
- def tile_load(a: Array[Any], shape: Tuple[int, ...], offset: Tuple[int, ...], storage: str):
1001
- """Loads a tile from a global memory array.
1002
-
1003
- This method will cooperatively load a tile from global memory using all threads in the block.
1004
-
1005
- :param a: The source array in global memory
1006
- :param shape: Shape of the tile to load, must have the same number of dimensions as ``a``
1007
- :param offset: Offset in the source array to begin reading from (optional)
1008
- :param storage: The storage location for the tile: ``"register"`` for registers
1009
- (default) or ``"shared"`` for shared memory.
1010
- :returns: A tile with shape as specified and data type the same as the source array
1011
- """
1012
- ...
1013
-
1014
-
1015
- @over
1016
- def tile_store(a: Array[Any], t: Tile, offset: Tuple[int, ...]):
1017
- """Store a tile to a global memory array.
1018
-
1019
- This method will cooperatively store a tile to global memory using all threads in the block.
1020
-
1021
- :param a: The destination array in global memory
1022
- :param t: The source tile to store data from, must have the same data type and number of dimensions as the destination array
1023
- :param offset: Offset in the destination array (optional)
1024
- """
1025
- ...
1026
-
1027
-
1028
- @over
1029
- def tile_atomic_add(a: Array[Any], t: Tile, offset: Tuple[int, ...]) -> Tile:
1030
- """Atomically add a 1D tile to the array `a`, each element will be updated atomically.
1031
-
1032
- :param a: Array in global memory, should have the same ``dtype`` as the input tile
1033
- :param t: Source tile to add to the destination array
1034
- :param offset: Offset in the destination array (optional)
1035
- :returns: A tile with the same dimensions and data type as the source tile, holding the original value of the destination elements
1036
- """
1037
- ...
1038
-
1039
-
1040
- @over
1041
- def tile_view(t: Tile, offset: Tuple[int, ...], shape: Tuple[int, ...]) -> Tile:
1042
- """Return a slice of a given tile [offset, offset+shape], if shape is not specified it will be inferred from the unspecified offset dimensions.
1043
-
1044
- :param t: Input tile to extract a subrange from
1045
- :param offset: Offset in the source tile
1046
- :param shape: Shape of the returned slice
1047
- :returns: A tile with dimensions given by the specified shape or the remaining source tile dimensions
1048
- """
1049
- ...
1050
-
1051
-
1052
- @over
1053
- def tile_assign(dst: Tile, src: Tile, offset: Tuple[int, ...]):
1054
- """Assign a tile to a subrange of a destination tile.
1055
-
1056
- :param dst: The destination tile to assign to
1057
- :param src: The source tile to read values from
1058
- :param offset: Offset in the destination tile to write to
1059
- """
1060
- ...
1061
-
1062
-
1063
- @over
1064
- def tile(x: Any) -> Tile:
1065
- """Construct a new tile from per-thread kernel values.
1066
-
1067
- This function converts values computed using scalar kernel code to a tile representation for input into collective operations.
1068
-
1069
- * If the input value is a scalar, then the resulting tile has ``shape=(block_dim,)``
1070
- * If the input value is a vector, then the resulting tile has ``shape=(length(vector), block_dim)``
1071
-
1072
- :param x: A per-thread local value, e.g. scalar, vector, or matrix.
1073
- :returns: A tile with first dimension according to the value type length and a second dimension equal to ``block_dim``
1074
-
1075
- This example shows how to create a linear sequence from thread variables:
1076
-
1077
- .. code-block:: python
1078
-
1079
- @wp.kernel
1080
- def compute():
1081
- i = wp.tid()
1082
- t = wp.tile(i * 2)
1083
- print(t)
1084
-
1085
-
1086
- wp.launch(compute, dim=16, inputs=[], block_dim=16)
1087
-
1088
- Prints:
1089
-
1090
- .. code-block:: text
1091
-
1092
- [0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30] = tile(shape=(16), storage=register)
1093
-
1094
-
1095
- """
1096
- ...
1097
-
1098
-
1099
- @over
1100
- def untile(a: Tile) -> Scalar:
1101
- """Convert a tile back to per-thread values.
1102
-
1103
- This function converts a block-wide tile back to per-thread values.
1104
-
1105
- * If the input tile is 1D, then the resulting value will be a per-thread scalar
1106
- * If the input tile is 2D, then the resulting value will be a per-thread vector of length M
1107
-
1108
- :param a: A tile with dimensions ``shape=(M, block_dim)``
1109
- :returns: A single value per-thread with the same data type as the tile
1110
-
1111
- This example shows how to create a linear sequence from thread variables:
1112
-
1113
- .. code-block:: python
1114
-
1115
- @wp.kernel
1116
- def compute():
1117
- i = wp.tid()
1118
-
1119
- # create block-wide tile
1120
- t = wp.tile(i) * 2
1121
-
1122
- # convert back to per-thread values
1123
- s = wp.untile(t)
1124
-
1125
- print(s)
1126
-
1127
-
1128
- wp.launch(compute, dim=16, inputs=[], block_dim=16)
1129
-
1130
- Prints:
1131
-
1132
- .. code-block:: text
1133
-
1134
- 0
1135
- 2
1136
- 4
1137
- 6
1138
- 8
1139
- ...
1140
-
1141
- """
1142
- ...
1143
-
1144
-
1145
- @over
1146
- def tile_transpose(a: Tile) -> Tile:
1147
- """Transpose a tile.
1148
-
1149
- For shared memory tiles, this operation will alias the input tile.
1150
- Register tiles will first be transferred to shared memory before transposition.
1151
-
1152
- :param a: Tile to transpose with ``shape=(M,N)``
1153
- :returns: Tile with ``shape=(N,M)``
1154
- """
1155
- ...
1156
-
1157
-
1158
- @over
1159
- def tile_broadcast(a: Tile, shape: Tuple[int, ...]) -> Tile:
1160
- """Broadcast a tile.
1161
-
1162
- Broadcasts the input tile ``a`` to the destination shape.
1163
- Broadcasting follows NumPy broadcast rules.
1164
-
1165
- :param a: Tile to broadcast
1166
- :param shape: The shape to broadcast to
1167
- :returns: Tile with broadcast shape
1168
- """
1169
- ...
1170
-
1171
-
1172
- @over
1173
- def tile_sum(a: Tile) -> Tile:
1174
- """Cooperatively compute the sum of the tile elements using all threads in the block.
1175
-
1176
- :param a: The tile to compute the sum of
1177
- :returns: A single-element tile holding the sum
1178
-
1179
- Example:
1180
-
1181
- .. code-block:: python
1182
-
1183
- @wp.kernel
1184
- def compute():
1185
- t = wp.tile_ones(dtype=float, shape=(16, 16))
1186
- s = wp.tile_sum(t)
1187
-
1188
- print(s)
1189
-
1190
-
1191
- wp.launch_tiled(compute, dim=[1], inputs=[], block_dim=64)
1192
-
1193
- Prints:
1194
-
1195
- .. code-block:: text
1196
-
1197
- [256] = tile(shape=(1), storage=register)
1198
-
1199
-
1200
- """
1201
- ...
1202
-
1203
-
1204
- @over
1205
- def tile_min(a: Tile) -> Tile:
1206
- """Cooperatively compute the minimum of the tile elements using all threads in the block.
1207
-
1208
- :param a: The tile to compute the minimum of
1209
- :returns: A single-element tile holding the minimum value
1210
-
1211
- Example:
1212
-
1213
- .. code-block:: python
1214
-
1215
- @wp.kernel
1216
- def compute():
1217
- t = wp.tile_arange(64, 128)
1218
- s = wp.tile_min(t)
1219
-
1220
- print(s)
1221
-
1222
-
1223
- wp.launch_tiled(compute, dim=[1], inputs=[], block_dim=64)
1224
-
1225
- Prints:
1226
-
1227
- .. code-block:: text
1228
-
1229
- [64] = tile(shape=(1), storage=register)
1230
-
1231
-
1232
- """
1233
- ...
1234
-
1235
-
1236
- @over
1237
- def tile_max(a: Tile) -> Tile:
1238
- """Cooperatively compute the maximum of the tile elements using all threads in the block.
1239
-
1240
- :param a: The tile to compute the maximum from
1241
- :returns: A single-element tile holding the maximum value
1242
-
1243
- Example:
1244
-
1245
- .. code-block:: python
1246
-
1247
- @wp.kernel
1248
- def compute():
1249
- t = wp.tile_arange(64, 128)
1250
- s = wp.tile_max(t)
1251
-
1252
- print(s)
1253
-
1254
-
1255
- wp.launch_tiled(compute, dim=[1], inputs=[], block_dim=64)
1256
-
1257
- Prints:
1258
-
1259
- .. code-block:: text
1260
-
1261
- [127] = tile(shape=(1), storage=register)
1262
-
1263
-
1264
- """
1265
- ...
1266
-
1267
-
1268
- @over
1269
- def tile_reduce(op: Callable, a: Tile) -> Tile:
1270
- """Apply a custom reduction operator across the tile.
1271
-
1272
- This function cooperatively performs a reduction using the provided operator across the tile.
1273
-
1274
- :param op: A callable function that accepts two arguments and returns one argument, may be a user function or builtin
1275
- :param a: The input tile, the operator (or one of its overloads) must be able to accept the tile's data type
1276
- :returns: A single-element tile with the same data type as the input tile.
1277
-
1278
- Example:
1279
-
1280
- .. code-block:: python
1281
-
1282
- @wp.kernel
1283
- def factorial():
1284
- t = wp.tile_arange(1, 10, dtype=int)
1285
- s = wp.tile_reduce(wp.mul, t)
1286
-
1287
- print(s)
1288
-
1289
-
1290
- wp.launch_tiled(factorial, dim=[1], inputs=[], block_dim=16)
1291
-
1292
- Prints:
1293
-
1294
- .. code-block:: text
1295
-
1296
- [362880] = tile(shape=(1), storage=register)
1297
-
1298
- """
1299
- ...
1300
-
1301
-
1302
- @over
1303
- def tile_map(op: Callable, a: Tile) -> Tile:
1304
- """Apply a unary function onto the tile.
1305
-
1306
- This function cooperatively applies a unary function to each element of the tile using all threads in the block.
1307
-
1308
- :param op: A callable function that accepts one argument and returns one argument, may be a user function or builtin
1309
- :param a: The input tile, the operator (or one of its overloads) must be able to accept the tile's data type
1310
- :returns: A tile with the same dimensions and data type as the input tile.
1311
-
1312
- Example:
1313
-
1314
- .. code-block:: python
1315
-
1316
- @wp.kernel
1317
- def compute():
1318
- t = wp.tile_arange(0.0, 1.0, 0.1, dtype=float)
1319
- s = wp.tile_map(wp.sin, t)
1320
-
1321
- print(s)
1322
-
1323
-
1324
- wp.launch_tiled(compute, dim=[1], inputs=[], block_dim=16)
1325
-
1326
- Prints:
1327
-
1328
- .. code-block:: text
1329
-
1330
- [0 0.0998334 0.198669 0.29552 0.389418 0.479426 0.564642 0.644218 0.717356 0.783327] = tile(shape=(10), storage=register)
1331
-
1332
- """
1333
- ...
1334
-
1335
-
1336
- @over
1337
- def tile_map(op: Callable, a: Tile, b: Tile) -> Tile:
1338
- """Apply a binary function onto the tile.
1339
-
1340
- This function cooperatively applies a binary function to each element of the tiles using all threads in the block.
1341
- Both input tiles must have the same dimensions and datatype.
1342
-
1343
- :param op: A callable function that accepts two arguments and returns one argument, all of the same type, may be a user function or builtin
1344
- :param a: The first input tile, the operator (or one of its overloads) must be able to accept the tile's dtype
1345
- :param b: The second input tile, the operator (or one of its overloads) must be able to accept the tile's dtype
1346
- :returns: A tile with the same dimensions and datatype as the input tiles.
1347
-
1348
- Example:
1349
-
1350
- .. code-block:: python
1351
-
1352
- @wp.kernel
1353
- def compute():
1354
- a = wp.tile_arange(0.0, 1.0, 0.1, dtype=float)
1355
- b = wp.tile_ones(shape=10, dtype=float)
1356
-
1357
- s = wp.tile_map(wp.add, a, b)
1358
-
1359
- print(s)
1360
-
1361
-
1362
- wp.launch_tiled(compute, dim=[1], inputs=[], block_dim=16)
1363
-
1364
- Prints:
1365
-
1366
- .. code-block:: text
1367
-
1368
- [1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9] = tile(shape=(10), storage=register)
1369
- """
1370
- ...
1371
-
1372
-
1373
- @over
1374
- def mlp(
1375
- weights: Array[float32],
1376
- bias: Array[float32],
1377
- activation: Callable,
1378
- index: int32,
1379
- x: Array[float32],
1380
- out: Array[float32],
1381
- ):
1382
- """Evaluate a multi-layer perceptron (MLP) layer in the form: ``out = act(weights*x + bias)``.
1383
-
1384
- .. deprecated:: 1.6
1385
- Use :doc:`tile primitives </modules/tiles>` instead.
1386
-
1387
- :param weights: A layer's network weights with dimensions ``(m, n)``.
1388
- :param bias: An array with dimensions ``(n)``.
1389
- :param activation: A ``wp.func`` function that takes a single scalar float as input and returns a scalar float as output
1390
- :param index: The batch item to process, typically each thread will process one item in the batch, in which case
1391
- index should be ``wp.tid()``
1392
- :param x: The feature matrix with dimensions ``(n, b)``
1393
- :param out: The network output with dimensions ``(m, b)``
1394
-
1395
- :note: Feature and output matrices are transposed compared to some other frameworks such as PyTorch.
1396
- All matrices are assumed to be stored in flattened row-major memory layout (NumPy default).
1397
- """
1398
- ...
1399
-
1400
-
1401
- @over
1402
- def bvh_query_aabb(id: uint64, low: vec3f, high: vec3f) -> bvh_query_t:
1403
- """Construct an axis-aligned bounding box query against a BVH object.
1404
-
1405
- This query can be used to iterate over all bounds inside a BVH.
1406
-
1407
- :param id: The BVH identifier
1408
- :param low: The lower bound of the bounding box in BVH space
1409
- :param high: The upper bound of the bounding box in BVH space
1410
- """
1411
- ...
1412
-
1413
-
1414
- @over
1415
- def bvh_query_ray(id: uint64, start: vec3f, dir: vec3f) -> bvh_query_t:
1416
- """Construct a ray query against a BVH object.
1417
-
1418
- This query can be used to iterate over all bounds that intersect the ray.
1419
-
1420
- :param id: The BVH identifier
1421
- :param start: The start of the ray in BVH space
1422
- :param dir: The direction of the ray in BVH space
1423
- """
1424
- ...
1425
-
1426
-
1427
- @over
1428
- def bvh_query_next(query: bvh_query_t, index: int32) -> bool:
1429
- """Move to the next bound returned by the query.
1430
- The index of the current bound is stored in ``index``, returns ``False`` if there are no more overlapping bound.
1431
- """
1432
- ...
1433
-
1434
-
1435
- @over
1436
- def mesh_query_point(id: uint64, point: vec3f, max_dist: float32) -> mesh_query_point_t:
1437
- """Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space.
1438
-
1439
- Identifies the sign of the distance using additional ray-casts to determine if the point is inside or outside.
1440
- This method is relatively robust, but does increase computational cost.
1441
- See below for additional sign determination methods.
1442
-
1443
- :param id: The mesh identifier
1444
- :param point: The point in space to query
1445
- :param max_dist: Mesh faces above this distance will not be considered by the query
1446
- """
1447
- ...
1448
-
1449
-
1450
- @over
1451
- def mesh_query_point_no_sign(id: uint64, point: vec3f, max_dist: float32) -> mesh_query_point_t:
1452
- """Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space.
1453
-
1454
- This method does not compute the sign of the point (inside/outside) which makes it faster than other point query methods.
1455
-
1456
- :param id: The mesh identifier
1457
- :param point: The point in space to query
1458
- :param max_dist: Mesh faces above this distance will not be considered by the query
1459
- """
1460
- ...
1461
-
1462
-
1463
- @over
1464
- def mesh_query_furthest_point_no_sign(id: uint64, point: vec3f, min_dist: float32) -> mesh_query_point_t:
1465
- """Computes the furthest point on the mesh with identifier `id` to the given point in space.
1466
-
1467
- This method does not compute the sign of the point (inside/outside).
1468
-
1469
- :param id: The mesh identifier
1470
- :param point: The point in space to query
1471
- :param min_dist: Mesh faces below this distance will not be considered by the query
1472
- """
1473
- ...
1474
-
1475
-
1476
- @over
1477
- def mesh_query_point_sign_normal(id: uint64, point: vec3f, max_dist: float32, epsilon: float32) -> mesh_query_point_t:
1478
- """Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given ``point`` in space.
1479
-
1480
- Identifies the sign of the distance (inside/outside) using the angle-weighted pseudo normal.
1481
- This approach to sign determination is robust for well conditioned meshes that are watertight and non-self intersecting.
1482
- It is also comparatively fast to compute.
1483
-
1484
- :param id: The mesh identifier
1485
- :param point: The point in space to query
1486
- :param max_dist: Mesh faces above this distance will not be considered by the query
1487
- :param epsilon: Epsilon treating distance values as equal, when locating the minimum distance vertex/face/edge, as a
1488
- fraction of the average edge length, also for treating closest point as being on edge/vertex default 1e-3
1489
- """
1490
- ...
1491
-
1492
-
1493
- @over
1494
- def mesh_query_point_sign_winding_number(
1495
- id: uint64, point: vec3f, max_dist: float32, accuracy: float32, threshold: float32
1496
- ) -> mesh_query_point_t:
1497
- """Computes the closest point on the :class:`Mesh` with identifier ``id`` to the given point in space.
1498
-
1499
- Identifies the sign using the winding number of the mesh relative to the query point. This method of sign determination is robust for poorly conditioned meshes
1500
- and provides a smooth approximation to sign even when the mesh is not watertight. This method is the most robust and accurate of the sign determination meshes
1501
- but also the most expensive.
1502
-
1503
- .. note:: The :class:`Mesh` object must be constructed with ``support_winding_number=True`` for this method to return correct results.
1504
-
1505
- :param id: The mesh identifier
1506
- :param point: The point in space to query
1507
- :param max_dist: Mesh faces above this distance will not be considered by the query
1508
- :param accuracy: Accuracy for computing the winding number with fast winding number method utilizing second-order dipole approximation, default 2.0
1509
- :param threshold: The threshold of the winding number to be considered inside, default 0.5
1510
- """
1511
- ...
1512
-
1513
-
1514
- @over
1515
- def mesh_query_ray(id: uint64, start: vec3f, dir: vec3f, max_t: float32) -> mesh_query_ray_t:
1516
- """Computes the closest ray hit on the :class:`Mesh` with identifier ``id``.
1517
-
1518
- :param id: The mesh identifier
1519
- :param start: The start point of the ray
1520
- :param dir: The ray direction (should be normalized)
1521
- :param max_t: The maximum distance along the ray to check for intersections
1522
- """
1523
- ...
1524
-
1525
-
1526
- @over
1527
- def mesh_query_aabb(id: uint64, low: vec3f, high: vec3f) -> mesh_query_aabb_t:
1528
- """Construct an axis-aligned bounding box query against a :class:`Mesh`.
1529
-
1530
- This query can be used to iterate over all triangles inside a volume.
1531
-
1532
- :param id: The mesh identifier
1533
- :param low: The lower bound of the bounding box in mesh space
1534
- :param high: The upper bound of the bounding box in mesh space
1535
- """
1536
- ...
1537
-
1538
-
1539
- @over
1540
- def mesh_query_aabb_next(query: mesh_query_aabb_t, index: int32) -> bool:
1541
- """Move to the next triangle overlapping the query bounding box.
1542
-
1543
- The index of the current face is stored in ``index``, returns ``False`` if there are no more overlapping triangles.
1544
- """
1545
- ...
1546
-
1547
-
1548
- @over
1549
- def mesh_eval_position(id: uint64, face: int32, bary_u: float32, bary_v: float32) -> vec3f:
1550
- """Evaluates the position on the :class:`Mesh` given a face index and barycentric coordinates."""
1551
- ...
1552
-
1553
-
1554
- @over
1555
- def mesh_eval_velocity(id: uint64, face: int32, bary_u: float32, bary_v: float32) -> vec3f:
1556
- """Evaluates the velocity on the :class:`Mesh` given a face index and barycentric coordinates."""
1557
- ...
1558
-
1559
-
1560
- @over
1561
- def hash_grid_query(id: uint64, point: vec3f, max_dist: float32) -> hash_grid_query_t:
1562
- """Construct a point query against a :class:`HashGrid`.
1563
-
1564
- This query can be used to iterate over all neighboring point within a fixed radius from the query point.
1565
- """
1566
- ...
1567
-
1568
-
1569
- @over
1570
- def hash_grid_query_next(query: hash_grid_query_t, index: int32) -> bool:
1571
- """Move to the next point in the hash grid query.
1572
-
1573
- The index of the current neighbor is stored in ``index``, returns ``False`` if there are no more neighbors.
1574
- """
1575
- ...
1576
-
1577
-
1578
- @over
1579
- def hash_grid_point_id(id: uint64, index: int32) -> int:
1580
- """Return the index of a point in the :class:`HashGrid`.
1581
-
1582
- This can be used to reorder threads such that grid traversal occurs in a spatially coherent order.
1583
-
1584
- Returns -1 if the :class:`HashGrid` has not been reserved.
1585
- """
1586
- ...
1587
-
1588
-
1589
- @over
1590
- def intersect_tri_tri(v0: vec3f, v1: vec3f, v2: vec3f, u0: vec3f, u1: vec3f, u2: vec3f) -> int:
1591
- """Tests for intersection between two triangles (v0, v1, v2) and (u0, u1, u2) using Moller's method.
1592
-
1593
- Returns > 0 if triangles intersect.
1594
- """
1595
- ...
1596
-
1597
-
1598
- @over
1599
- def mesh_get(id: uint64) -> Mesh:
1600
- """Retrieves the mesh given its index."""
1601
- ...
1602
-
1603
-
1604
- @over
1605
- def mesh_eval_face_normal(id: uint64, face: int32) -> vec3f:
1606
- """Evaluates the face normal the mesh given a face index."""
1607
- ...
1608
-
1609
-
1610
- @over
1611
- def mesh_get_point(id: uint64, index: int32) -> vec3f:
1612
- """Returns the point of the mesh given a index."""
1613
- ...
1614
-
1615
-
1616
- @over
1617
- def mesh_get_velocity(id: uint64, index: int32) -> vec3f:
1618
- """Returns the velocity of the mesh given a index."""
1619
- ...
1620
-
1621
-
1622
- @over
1623
- def mesh_get_index(id: uint64, index: int32) -> int:
1624
- """Returns the point-index of the mesh given a face-vertex index."""
1625
- ...
1626
-
1627
-
1628
- @over
1629
- def closest_point_edge_edge(p1: vec3f, q1: vec3f, p2: vec3f, q2: vec3f, epsilon: float32) -> vec3f:
1630
- """Finds the closest points between two edges.
1631
-
1632
- Returns barycentric weights to the points on each edge, as well as the closest distance between the edges.
1633
-
1634
- :param p1: First point of first edge
1635
- :param q1: Second point of first edge
1636
- :param p2: First point of second edge
1637
- :param q2: Second point of second edge
1638
- :param epsilon: Zero tolerance for determining if points in an edge are degenerate.
1639
- :param out: vec3 output containing (s,t,d), where `s` in [0,1] is the barycentric weight for the first edge, `t` is the barycentric weight for the second edge, and `d` is the distance between the two edges at these two closest points.
1640
- """
1641
- ...
1642
-
1643
-
1644
- @over
1645
- def reversed(range: range_t) -> range_t:
1646
- """Returns the range in reversed order."""
1647
- ...
1648
-
1649
-
1650
- @over
1651
- def volume_sample(id: uint64, uvw: vec3f, sampling_mode: int32, dtype: Any) -> Any:
1652
- """Sample the volume of type `dtype` given by ``id`` at the volume local-space point ``uvw``.
1653
-
1654
- Interpolation should be :attr:`warp.Volume.CLOSEST` or :attr:`wp.Volume.LINEAR.`
1655
- """
1656
- ...
1657
-
1658
-
1659
- @over
1660
- def volume_sample_grad(id: uint64, uvw: vec3f, sampling_mode: int32, grad: Any, dtype: Any) -> Any:
1661
- """Sample the volume given by ``id`` and its gradient at the volume local-space point ``uvw``.
1662
-
1663
- Interpolation should be :attr:`warp.Volume.CLOSEST` or :attr:`wp.Volume.LINEAR.`
1664
- """
1665
- ...
1666
-
1667
-
1668
- @over
1669
- def volume_lookup(id: uint64, i: int32, j: int32, k: int32, dtype: Any) -> Any:
1670
- """Returns the value of voxel with coordinates ``i``, ``j``, ``k`` for a volume of type type `dtype`.
1671
-
1672
- If the voxel at this index does not exist, this function returns the background value.
1673
- """
1674
- ...
1675
-
1676
-
1677
- @over
1678
- def volume_store(id: uint64, i: int32, j: int32, k: int32, value: Any):
1679
- """Store ``value`` at the voxel with coordinates ``i``, ``j``, ``k``."""
1680
- ...
1681
-
1682
-
1683
- @over
1684
- def volume_sample_f(id: uint64, uvw: vec3f, sampling_mode: int32) -> float:
1685
- """Sample the volume given by ``id`` at the volume local-space point ``uvw``.
1686
-
1687
- Interpolation should be :attr:`warp.Volume.CLOSEST` or :attr:`wp.Volume.LINEAR.`
1688
- """
1689
- ...
1690
-
1691
-
1692
- @over
1693
- def volume_sample_grad_f(id: uint64, uvw: vec3f, sampling_mode: int32, grad: vec3f) -> float:
1694
- """Sample the volume and its gradient given by ``id`` at the volume local-space point ``uvw``.
1695
-
1696
- Interpolation should be :attr:`warp.Volume.CLOSEST` or :attr:`wp.Volume.LINEAR.`
1697
- """
1698
- ...
1699
-
1700
-
1701
- @over
1702
- def volume_lookup_f(id: uint64, i: int32, j: int32, k: int32) -> float:
1703
- """Returns the value of voxel with coordinates ``i``, ``j``, ``k``.
1704
-
1705
- If the voxel at this index does not exist, this function returns the background value
1706
- """
1707
- ...
1708
-
1709
-
1710
- @over
1711
- def volume_store_f(id: uint64, i: int32, j: int32, k: int32, value: float32):
1712
- """Store ``value`` at the voxel with coordinates ``i``, ``j``, ``k``."""
1713
- ...
1714
-
1715
-
1716
- @over
1717
- def volume_sample_v(id: uint64, uvw: vec3f, sampling_mode: int32) -> vec3f:
1718
- """Sample the vector volume given by ``id`` at the volume local-space point ``uvw``.
1719
-
1720
- Interpolation should be :attr:`warp.Volume.CLOSEST` or :attr:`wp.Volume.LINEAR.`
1721
- """
1722
- ...
1723
-
1724
-
1725
- @over
1726
- def volume_lookup_v(id: uint64, i: int32, j: int32, k: int32) -> vec3f:
1727
- """Returns the vector value of voxel with coordinates ``i``, ``j``, ``k``.
1728
-
1729
- If the voxel at this index does not exist, this function returns the background value.
1730
- """
1731
- ...
1732
-
1733
-
1734
- @over
1735
- def volume_store_v(id: uint64, i: int32, j: int32, k: int32, value: vec3f):
1736
- """Store ``value`` at the voxel with coordinates ``i``, ``j``, ``k``."""
1737
- ...
1738
-
1739
-
1740
- @over
1741
- def volume_sample_i(id: uint64, uvw: vec3f) -> int:
1742
- """Sample the :class:`int32` volume given by ``id`` at the volume local-space point ``uvw``."""
1743
- ...
1744
-
1745
-
1746
- @over
1747
- def volume_lookup_i(id: uint64, i: int32, j: int32, k: int32) -> int:
1748
- """Returns the :class:`int32` value of voxel with coordinates ``i``, ``j``, ``k``.
1749
-
1750
- If the voxel at this index does not exist, this function returns the background value.
1751
- """
1752
- ...
1753
-
1754
-
1755
- @over
1756
- def volume_store_i(id: uint64, i: int32, j: int32, k: int32, value: int32):
1757
- """Store ``value`` at the voxel with coordinates ``i``, ``j``, ``k``."""
1758
- ...
1759
-
1760
-
1761
- @over
1762
- def volume_sample_index(id: uint64, uvw: vec3f, sampling_mode: int32, voxel_data: Array[Any], background: Any) -> Any:
1763
- """Sample the volume given by ``id`` at the volume local-space point ``uvw``.
1764
-
1765
- Values for allocated voxels are read from the ``voxel_data`` array, and `background` is used as the value of non-existing voxels.
1766
- Interpolation should be :attr:`warp.Volume.CLOSEST` or :attr:`wp.Volume.LINEAR`.
1767
- This function is available for both index grids and classical volumes.
1768
-
1769
- """
1770
- ...
1771
-
1772
-
1773
- @over
1774
- def volume_sample_grad_index(
1775
- id: uint64, uvw: vec3f, sampling_mode: int32, voxel_data: Array[Any], background: Any, grad: Any
1776
- ) -> Any:
1777
- """Sample the volume given by ``id`` and its gradient at the volume local-space point ``uvw``.
1778
-
1779
- Values for allocated voxels are read from the ``voxel_data`` array, and `background` is used as the value of non-existing voxels.
1780
- Interpolation should be :attr:`warp.Volume.CLOSEST` or :attr:`wp.Volume.LINEAR`.
1781
- This function is available for both index grids and classical volumes.
1782
-
1783
- """
1784
- ...
1785
-
1786
-
1787
- @over
1788
- def volume_lookup_index(id: uint64, i: int32, j: int32, k: int32) -> int32:
1789
- """Returns the index associated to the voxel with coordinates ``i``, ``j``, ``k``.
1790
-
1791
- If the voxel at this index does not exist, this function returns -1.
1792
- This function is available for both index grids and classical volumes.
1793
-
1794
- """
1795
- ...
1796
-
1797
-
1798
- @over
1799
- def volume_index_to_world(id: uint64, uvw: vec3f) -> vec3f:
1800
- """Transform a point ``uvw`` defined in volume index space to world space given the volume's intrinsic affine transformation."""
1801
- ...
1802
-
1803
-
1804
- @over
1805
- def volume_world_to_index(id: uint64, xyz: vec3f) -> vec3f:
1806
- """Transform a point ``xyz`` defined in volume world space to the volume's index space given the volume's intrinsic affine transformation."""
1807
- ...
1808
-
1809
-
1810
- @over
1811
- def volume_index_to_world_dir(id: uint64, uvw: vec3f) -> vec3f:
1812
- """Transform a direction ``uvw`` defined in volume index space to world space given the volume's intrinsic affine transformation."""
1813
- ...
1814
-
1815
-
1816
- @over
1817
- def volume_world_to_index_dir(id: uint64, xyz: vec3f) -> vec3f:
1818
- """Transform a direction ``xyz`` defined in volume world space to the volume's index space given the volume's intrinsic affine transformation."""
1819
- ...
1820
-
1821
-
1822
- @over
1823
- def rand_init(seed: int32) -> uint32:
1824
- """Initialize a new random number generator given a user-defined seed. Returns a 32-bit integer representing the RNG state."""
1825
- ...
1826
-
1827
-
1828
- @over
1829
- def rand_init(seed: int32, offset: int32) -> uint32:
1830
- """Initialize a new random number generator given a user-defined seed and an offset.
1831
-
1832
- This alternative constructor can be useful in parallel programs, where a kernel as a whole should share a seed,
1833
- but each thread should generate uncorrelated values. In this case usage should be ``r = rand_init(seed, tid)``
1834
- """
1835
- ...
1836
-
1837
-
1838
- @over
1839
- def randi(state: uint32) -> int:
1840
- """Return a random integer in the range [-2^31, 2^31)."""
1841
- ...
1842
-
1843
-
1844
- @over
1845
- def randi(state: uint32, low: int32, high: int32) -> int:
1846
- """Return a random integer between [low, high)."""
1847
- ...
1848
-
1849
-
1850
- @over
1851
- def randu(state: uint32) -> uint32:
1852
- """Return a random unsigned integer in the range [0, 2^32)."""
1853
- ...
1854
-
1855
-
1856
- @over
1857
- def randu(state: uint32, low: uint32, high: uint32) -> uint32:
1858
- """Return a random unsigned integer between [low, high)."""
1859
- ...
1860
-
1861
-
1862
- @over
1863
- def randf(state: uint32) -> float:
1864
- """Return a random float between [0.0, 1.0)."""
1865
- ...
1866
-
1867
-
1868
- @over
1869
- def randf(state: uint32, low: float32, high: float32) -> float:
1870
- """Return a random float between [low, high)."""
1871
- ...
1872
-
1873
-
1874
- @over
1875
- def randn(state: uint32) -> float:
1876
- """Sample a normal (Gaussian) distribution of mean 0 and variance 1."""
1877
- ...
1878
-
1879
-
1880
- @over
1881
- def sample_cdf(state: uint32, cdf: Array[float32]) -> int:
1882
- """Inverse-transform sample a cumulative distribution function."""
1883
- ...
1884
-
1885
-
1886
- @over
1887
- def sample_triangle(state: uint32) -> vec2f:
1888
- """Uniformly sample a triangle. Returns sample barycentric coordinates."""
1889
- ...
1890
-
1891
-
1892
- @over
1893
- def sample_unit_ring(state: uint32) -> vec2f:
1894
- """Uniformly sample a ring in the xy plane."""
1895
- ...
1896
-
1897
-
1898
- @over
1899
- def sample_unit_disk(state: uint32) -> vec2f:
1900
- """Uniformly sample a disk in the xy plane."""
1901
- ...
1902
-
1903
-
1904
- @over
1905
- def sample_unit_sphere_surface(state: uint32) -> vec3f:
1906
- """Uniformly sample a unit sphere surface."""
1907
- ...
1908
-
1909
-
1910
- @over
1911
- def sample_unit_sphere(state: uint32) -> vec3f:
1912
- """Uniformly sample a unit sphere."""
1913
- ...
1914
-
1915
-
1916
- @over
1917
- def sample_unit_hemisphere_surface(state: uint32) -> vec3f:
1918
- """Uniformly sample a unit hemisphere surface."""
1919
- ...
1920
-
1921
-
1922
- @over
1923
- def sample_unit_hemisphere(state: uint32) -> vec3f:
1924
- """Uniformly sample a unit hemisphere."""
1925
- ...
1926
-
1927
-
1928
- @over
1929
- def sample_unit_square(state: uint32) -> vec2f:
1930
- """Uniformly sample a unit square."""
1931
- ...
1932
-
1933
-
1934
- @over
1935
- def sample_unit_cube(state: uint32) -> vec3f:
1936
- """Uniformly sample a unit cube."""
1937
- ...
1938
-
1939
-
1940
- @over
1941
- def poisson(state: uint32, lam: float32) -> uint32:
1942
- """Generate a random sample from a Poisson distribution.
1943
-
1944
- :param state: RNG state
1945
- :param lam: The expected value of the distribution
1946
- """
1947
- ...
1948
-
1949
-
1950
- @over
1951
- def noise(state: uint32, x: float32) -> float:
1952
- """Non-periodic Perlin-style noise in 1D."""
1953
- ...
1954
-
1955
-
1956
- @over
1957
- def noise(state: uint32, xy: vec2f) -> float:
1958
- """Non-periodic Perlin-style noise in 2D."""
1959
- ...
1960
-
1961
-
1962
- @over
1963
- def noise(state: uint32, xyz: vec3f) -> float:
1964
- """Non-periodic Perlin-style noise in 3D."""
1965
- ...
1966
-
1967
-
1968
- @over
1969
- def noise(state: uint32, xyzt: vec4f) -> float:
1970
- """Non-periodic Perlin-style noise in 4D."""
1971
- ...
1972
-
1973
-
1974
- @over
1975
- def pnoise(state: uint32, x: float32, px: int32) -> float:
1976
- """Periodic Perlin-style noise in 1D."""
1977
- ...
1978
-
1979
-
1980
- @over
1981
- def pnoise(state: uint32, xy: vec2f, px: int32, py: int32) -> float:
1982
- """Periodic Perlin-style noise in 2D."""
1983
- ...
1984
-
1985
-
1986
- @over
1987
- def pnoise(state: uint32, xyz: vec3f, px: int32, py: int32, pz: int32) -> float:
1988
- """Periodic Perlin-style noise in 3D."""
1989
- ...
1990
-
1991
-
1992
- @over
1993
- def pnoise(state: uint32, xyzt: vec4f, px: int32, py: int32, pz: int32, pt: int32) -> float:
1994
- """Periodic Perlin-style noise in 4D."""
1995
- ...
1996
-
1997
-
1998
- @over
1999
- def curlnoise(state: uint32, xy: vec2f, octaves: uint32, lacunarity: float32, gain: float32) -> vec2f:
2000
- """Divergence-free vector field based on the gradient of a Perlin noise function."""
2001
- ...
2002
-
2003
-
2004
- @over
2005
- def curlnoise(state: uint32, xyz: vec3f, octaves: uint32, lacunarity: float32, gain: float32) -> vec3f:
2006
- """Divergence-free vector field based on the curl of three Perlin noise functions."""
2007
- ...
2008
-
2009
-
2010
- @over
2011
- def curlnoise(state: uint32, xyzt: vec4f, octaves: uint32, lacunarity: float32, gain: float32) -> vec3f:
2012
- """Divergence-free vector field based on the curl of three Perlin noise functions."""
2013
- ...
2014
-
2015
-
2016
- @over
2017
- def printf(fmt: str, *args: Any):
2018
- """Allows printing formatted strings using C-style format specifiers."""
2019
- ...
2020
-
2021
-
2022
- @over
2023
- def print(value: Any):
2024
- """Print variable to stdout"""
2025
- ...
2026
-
2027
-
2028
- @over
2029
- def breakpoint():
2030
- """Debugger breakpoint"""
2031
- ...
2032
-
2033
-
2034
- @over
2035
- def tid() -> int:
2036
- """Return the current thread index for a 1D kernel launch.
2037
-
2038
- Note that this is the *global* index of the thread in the range [0, dim)
2039
- where dim is the parameter passed to kernel launch.
2040
-
2041
- This function may not be called from user-defined Warp functions.
2042
- """
2043
- ...
2044
-
2045
-
2046
- @over
2047
- def tid() -> Tuple[int, int]:
2048
- """Return the current thread indices for a 2D kernel launch.
2049
-
2050
- Use ``i,j = wp.tid()`` syntax to retrieve the coordinates inside the kernel thread grid.
2051
-
2052
- This function may not be called from user-defined Warp functions.
2053
- """
2054
- ...
2055
-
2056
-
2057
- @over
2058
- def tid() -> Tuple[int, int, int]:
2059
- """Return the current thread indices for a 3D kernel launch.
2060
-
2061
- Use ``i,j,k = wp.tid()`` syntax to retrieve the coordinates inside the kernel thread grid.
2062
-
2063
- This function may not be called from user-defined Warp functions.
2064
- """
2065
- ...
2066
-
2067
-
2068
- @over
2069
- def tid() -> Tuple[int, int, int, int]:
2070
- """Return the current thread indices for a 4D kernel launch.
2071
-
2072
- Use ``i,j,k,l = wp.tid()`` syntax to retrieve the coordinates inside the kernel thread grid.
2073
-
2074
- This function may not be called from user-defined Warp functions.
2075
- """
2076
- ...
2077
-
2078
-
2079
- @over
2080
- def select(cond: bool, value_if_false: Any, value_if_true: Any) -> Any:
2081
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2082
-
2083
- .. deprecated:: 1.7
2084
- Use :func:`where` instead, which has the more intuitive argument order:
2085
- ``where(cond, value_if_true, value_if_false)``.
2086
- """
2087
- ...
2088
-
2089
-
2090
- @over
2091
- def select(cond: int8, value_if_false: Any, value_if_true: Any) -> Any:
2092
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2093
-
2094
- .. deprecated:: 1.7
2095
- Use :func:`where` instead, which has the more intuitive argument order:
2096
- ``where(cond, value_if_true, value_if_false)``.
2097
- """
2098
- ...
2099
-
2100
-
2101
- @over
2102
- def select(cond: uint8, value_if_false: Any, value_if_true: Any) -> Any:
2103
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2104
-
2105
- .. deprecated:: 1.7
2106
- Use :func:`where` instead, which has the more intuitive argument order:
2107
- ``where(cond, value_if_true, value_if_false)``.
2108
- """
2109
- ...
2110
-
2111
-
2112
- @over
2113
- def select(cond: int16, value_if_false: Any, value_if_true: Any) -> Any:
2114
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2115
-
2116
- .. deprecated:: 1.7
2117
- Use :func:`where` instead, which has the more intuitive argument order:
2118
- ``where(cond, value_if_true, value_if_false)``.
2119
- """
2120
- ...
2121
-
2122
-
2123
- @over
2124
- def select(cond: uint16, value_if_false: Any, value_if_true: Any) -> Any:
2125
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2126
-
2127
- .. deprecated:: 1.7
2128
- Use :func:`where` instead, which has the more intuitive argument order:
2129
- ``where(cond, value_if_true, value_if_false)``.
2130
- """
2131
- ...
2132
-
2133
-
2134
- @over
2135
- def select(cond: int32, value_if_false: Any, value_if_true: Any) -> Any:
2136
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2137
-
2138
- .. deprecated:: 1.7
2139
- Use :func:`where` instead, which has the more intuitive argument order:
2140
- ``where(cond, value_if_true, value_if_false)``.
2141
- """
2142
- ...
2143
-
2144
-
2145
- @over
2146
- def select(cond: uint32, value_if_false: Any, value_if_true: Any) -> Any:
2147
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2148
-
2149
- .. deprecated:: 1.7
2150
- Use :func:`where` instead, which has the more intuitive argument order:
2151
- ``where(cond, value_if_true, value_if_false)``.
2152
- """
2153
- ...
2154
-
2155
-
2156
- @over
2157
- def select(cond: int64, value_if_false: Any, value_if_true: Any) -> Any:
2158
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2159
-
2160
- .. deprecated:: 1.7
2161
- Use :func:`where` instead, which has the more intuitive argument order:
2162
- ``where(cond, value_if_true, value_if_false)``.
2163
- """
2164
- ...
2165
-
2166
-
2167
- @over
2168
- def select(cond: uint64, value_if_false: Any, value_if_true: Any) -> Any:
2169
- """Select between two arguments, if ``cond`` is ``False`` then return ``value_if_false``, otherwise return ``value_if_true``.
2170
-
2171
- .. deprecated:: 1.7
2172
- Use :func:`where` instead, which has the more intuitive argument order:
2173
- ``where(cond, value_if_true, value_if_false)``.
2174
- """
2175
- ...
2176
-
2177
-
2178
- @over
2179
- def select(arr: Array[Any], value_if_false: Any, value_if_true: Any) -> Any:
2180
- """Select between two arguments, if ``arr`` is null then return ``value_if_false``, otherwise return ``value_if_true``.
2181
-
2182
- .. deprecated:: 1.7
2183
- Use :func:`where` instead, which has the more intuitive argument order:
2184
- ``where(arr, value_if_true, value_if_false)``.
2185
- """
2186
- ...
2187
-
2188
-
2189
- @over
2190
- def where(cond: bool, value_if_true: Any, value_if_false: Any) -> Any:
2191
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2192
- ...
2193
-
2194
-
2195
- @over
2196
- def where(cond: int8, value_if_true: Any, value_if_false: Any) -> Any:
2197
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2198
- ...
2199
-
2200
-
2201
- @over
2202
- def where(cond: uint8, value_if_true: Any, value_if_false: Any) -> Any:
2203
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2204
- ...
2205
-
2206
-
2207
- @over
2208
- def where(cond: int16, value_if_true: Any, value_if_false: Any) -> Any:
2209
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2210
- ...
2211
-
2212
-
2213
- @over
2214
- def where(cond: uint16, value_if_true: Any, value_if_false: Any) -> Any:
2215
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2216
- ...
2217
-
2218
-
2219
- @over
2220
- def where(cond: int32, value_if_true: Any, value_if_false: Any) -> Any:
2221
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2222
- ...
2223
-
2224
-
2225
- @over
2226
- def where(cond: uint32, value_if_true: Any, value_if_false: Any) -> Any:
2227
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2228
- ...
2229
-
2230
-
2231
- @over
2232
- def where(cond: int64, value_if_true: Any, value_if_false: Any) -> Any:
2233
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2234
- ...
2235
-
2236
-
2237
- @over
2238
- def where(cond: uint64, value_if_true: Any, value_if_false: Any) -> Any:
2239
- """Select between two arguments, if ``cond`` is ``True`` then return ``value_if_true``, otherwise return ``value_if_false``."""
2240
- ...
2241
-
2242
-
2243
- @over
2244
- def where(arr: Array[Any], value_if_true: Any, value_if_false: Any) -> Any:
2245
- """Select between two arguments, if ``arr`` is not null then return ``value_if_true``, otherwise return ``value_if_false``."""
2246
- ...
2247
-
2248
-
2249
- @over
2250
- def atomic_add(arr: Array[Any], i: Int, value: Any) -> Any:
2251
- """Atomically adds ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
2252
- This function is automatically invoked when using the syntax ``arr[i] += value``.
2253
- """
2254
- ...
2255
-
2256
-
2257
- @over
2258
- def atomic_add(arr: Array[Any], i: Int, j: Int, value: Any) -> Any:
2259
- """Atomically adds ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
2260
- This function is automatically invoked when using the syntax ``arr[i,j] += value``.
2261
- """
2262
- ...
2263
-
2264
-
2265
- @over
2266
- def atomic_add(arr: Array[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2267
- """Atomically adds ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
2268
- This function is automatically invoked when using the syntax ``arr[i,j,k] += value``.
2269
- """
2270
- ...
2271
-
2272
-
2273
- @over
2274
- def atomic_add(arr: Array[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2275
- """Atomically adds ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
2276
- This function is automatically invoked when using the syntax ``arr[i,j,k,l] += value``.
2277
- """
2278
- ...
2279
-
2280
-
2281
- @over
2282
- def atomic_add(arr: FabricArray[Any], i: Int, value: Any) -> Any:
2283
- """Atomically adds ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
2284
- This function is automatically invoked when using the syntax ``arr[i] += value``.
2285
- """
2286
- ...
2287
-
2288
-
2289
- @over
2290
- def atomic_add(arr: FabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2291
- """Atomically adds ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
2292
- This function is automatically invoked when using the syntax ``arr[i,j] += value``.
2293
- """
2294
- ...
2295
-
2296
-
2297
- @over
2298
- def atomic_add(arr: FabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2299
- """Atomically adds ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
2300
- This function is automatically invoked when using the syntax ``arr[i,j,k] += value``.
2301
- """
2302
- ...
2303
-
2304
-
2305
- @over
2306
- def atomic_add(arr: FabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2307
- """Atomically adds ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
2308
- This function is automatically invoked when using the syntax ``arr[i,j,k,l] += value``.
2309
- """
2310
- ...
2311
-
2312
-
2313
- @over
2314
- def atomic_add(arr: IndexedFabricArray[Any], i: Int, value: Any) -> Any:
2315
- """Atomically adds ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
2316
- This function is automatically invoked when using the syntax ``arr[i] += value``.
2317
- """
2318
- ...
2319
-
2320
-
2321
- @over
2322
- def atomic_add(arr: IndexedFabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2323
- """Atomically adds ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
2324
- This function is automatically invoked when using the syntax ``arr[i,j] += value``.
2325
- """
2326
- ...
2327
-
2328
-
2329
- @over
2330
- def atomic_add(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2331
- """Atomically adds ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
2332
- This function is automatically invoked when using the syntax ``arr[i,j,k] += value``.
2333
- """
2334
- ...
2335
-
2336
-
2337
- @over
2338
- def atomic_add(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2339
- """Atomically adds ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
2340
- This function is automatically invoked when using the syntax ``arr[i,j,k,l] += value``.
2341
- """
2342
- ...
2343
-
2344
-
2345
- @over
2346
- def atomic_sub(arr: Array[Any], i: Int, value: Any) -> Any:
2347
- """Atomically subtracts ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
2348
- This function is automatically invoked when using the syntax ``arr[i] -= value``.
2349
- """
2350
- ...
2351
-
2352
-
2353
- @over
2354
- def atomic_sub(arr: Array[Any], i: Int, j: Int, value: Any) -> Any:
2355
- """Atomically subtracts ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
2356
- This function is automatically invoked when using the syntax ``arr[i,j] -= value``.
2357
- """
2358
- ...
2359
-
2360
-
2361
- @over
2362
- def atomic_sub(arr: Array[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2363
- """Atomically subtracts ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
2364
- This function is automatically invoked when using the syntax ``arr[i,j,k] -= value``.
2365
- """
2366
- ...
2367
-
2368
-
2369
- @over
2370
- def atomic_sub(arr: Array[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2371
- """Atomically subtracts ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
2372
- This function is automatically invoked when using the syntax ``arr[i,j,k,l] -= value``.
2373
- """
2374
- ...
2375
-
2376
-
2377
- @over
2378
- def atomic_sub(arr: FabricArray[Any], i: Int, value: Any) -> Any:
2379
- """Atomically subtracts ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
2380
- This function is automatically invoked when using the syntax ``arr[i] -= value``.
2381
- """
2382
- ...
2383
-
2384
-
2385
- @over
2386
- def atomic_sub(arr: FabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2387
- """Atomically subtracts ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
2388
- This function is automatically invoked when using the syntax ``arr[i,j] -= value``.
2389
- """
2390
- ...
2391
-
2392
-
2393
- @over
2394
- def atomic_sub(arr: FabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2395
- """Atomically subtracts ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
2396
- This function is automatically invoked when using the syntax ``arr[i,j,k] -= value``.
2397
- """
2398
- ...
2399
-
2400
-
2401
- @over
2402
- def atomic_sub(arr: FabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2403
- """Atomically subtracts ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
2404
- This function is automatically invoked when using the syntax ``arr[i,j,k,l] -= value``.
2405
- """
2406
- ...
2407
-
2408
-
2409
- @over
2410
- def atomic_sub(arr: IndexedFabricArray[Any], i: Int, value: Any) -> Any:
2411
- """Atomically subtracts ``value`` onto ``arr[i]`` and returns the original value of ``arr[i]``.
2412
- This function is automatically invoked when using the syntax ``arr[i] -= value``.
2413
- """
2414
- ...
2415
-
2416
-
2417
- @over
2418
- def atomic_sub(arr: IndexedFabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2419
- """Atomically subtracts ``value`` onto ``arr[i,j]`` and returns the original value of ``arr[i,j]``.
2420
- This function is automatically invoked when using the syntax ``arr[i,j] -= value``.
2421
- """
2422
- ...
2423
-
2424
-
2425
- @over
2426
- def atomic_sub(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2427
- """Atomically subtracts ``value`` onto ``arr[i,j,k]`` and returns the original value of ``arr[i,j,k]``.
2428
- This function is automatically invoked when using the syntax ``arr[i,j,k] -= value``.
2429
- """
2430
- ...
2431
-
2432
-
2433
- @over
2434
- def atomic_sub(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2435
- """Atomically subtracts ``value`` onto ``arr[i,j,k,l]`` and returns the original value of ``arr[i,j,k,l]``.
2436
- This function is automatically invoked when using the syntax ``arr[i,j,k,l] -= value``.
2437
- """
2438
- ...
2439
-
2440
-
2441
- @over
2442
- def atomic_min(arr: Array[Any], i: Int, value: Any) -> Any:
2443
- """Compute the minimum of ``value`` and ``arr[i]``, atomically update the array, and return the old value.
2444
-
2445
- The operation is only atomic on a per-component basis for vectors and matrices.
2446
- """
2447
- ...
2448
-
2449
-
2450
- @over
2451
- def atomic_min(arr: Array[Any], i: Int, j: Int, value: Any) -> Any:
2452
- """Compute the minimum of ``value`` and ``arr[i,j]``, atomically update the array, and return the old value.
2453
-
2454
- The operation is only atomic on a per-component basis for vectors and matrices.
2455
- """
2456
- ...
2457
-
2458
-
2459
- @over
2460
- def atomic_min(arr: Array[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2461
- """Compute the minimum of ``value`` and ``arr[i,j,k]``, atomically update the array, and return the old value.
2462
-
2463
- The operation is only atomic on a per-component basis for vectors and matrices.
2464
- """
2465
- ...
2466
-
2467
-
2468
- @over
2469
- def atomic_min(arr: Array[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2470
- """Compute the minimum of ``value`` and ``arr[i,j,k,l]``, atomically update the array, and return the old value.
2471
-
2472
- The operation is only atomic on a per-component basis for vectors and matrices.
2473
- """
2474
- ...
2475
-
2476
-
2477
- @over
2478
- def atomic_min(arr: FabricArray[Any], i: Int, value: Any) -> Any:
2479
- """Compute the minimum of ``value`` and ``arr[i]``, atomically update the array, and return the old value.
2480
-
2481
- The operation is only atomic on a per-component basis for vectors and matrices.
2482
- """
2483
- ...
2484
-
2485
-
2486
- @over
2487
- def atomic_min(arr: FabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2488
- """Compute the minimum of ``value`` and ``arr[i,j]``, atomically update the array, and return the old value.
2489
-
2490
- The operation is only atomic on a per-component basis for vectors and matrices.
2491
- """
2492
- ...
2493
-
2494
-
2495
- @over
2496
- def atomic_min(arr: FabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2497
- """Compute the minimum of ``value`` and ``arr[i,j,k]``, atomically update the array, and return the old value.
2498
-
2499
- The operation is only atomic on a per-component basis for vectors and matrices.
2500
- """
2501
- ...
2502
-
2503
-
2504
- @over
2505
- def atomic_min(arr: FabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2506
- """Compute the minimum of ``value`` and ``arr[i,j,k,l]``, atomically update the array, and return the old value.
2507
-
2508
- The operation is only atomic on a per-component basis for vectors and matrices.
2509
- """
2510
- ...
2511
-
2512
-
2513
- @over
2514
- def atomic_min(arr: IndexedFabricArray[Any], i: Int, value: Any) -> Any:
2515
- """Compute the minimum of ``value`` and ``arr[i]``, atomically update the array, and return the old value.
2516
-
2517
- The operation is only atomic on a per-component basis for vectors and matrices.
2518
- """
2519
- ...
2520
-
2521
-
2522
- @over
2523
- def atomic_min(arr: IndexedFabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2524
- """Compute the minimum of ``value`` and ``arr[i,j]``, atomically update the array, and return the old value.
2525
-
2526
- The operation is only atomic on a per-component basis for vectors and matrices.
2527
- """
2528
- ...
2529
-
2530
-
2531
- @over
2532
- def atomic_min(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2533
- """Compute the minimum of ``value`` and ``arr[i,j,k]``, atomically update the array, and return the old value.
2534
-
2535
- The operation is only atomic on a per-component basis for vectors and matrices.
2536
- """
2537
- ...
2538
-
2539
-
2540
- @over
2541
- def atomic_min(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2542
- """Compute the minimum of ``value`` and ``arr[i,j,k,l]``, atomically update the array, and return the old value.
2543
-
2544
- The operation is only atomic on a per-component basis for vectors and matrices.
2545
- """
2546
- ...
2547
-
2548
-
2549
- @over
2550
- def atomic_max(arr: Array[Any], i: Int, value: Any) -> Any:
2551
- """Compute the maximum of ``value`` and ``arr[i]``, atomically update the array, and return the old value.
2552
-
2553
- The operation is only atomic on a per-component basis for vectors and matrices.
2554
- """
2555
- ...
2556
-
2557
-
2558
- @over
2559
- def atomic_max(arr: Array[Any], i: Int, j: Int, value: Any) -> Any:
2560
- """Compute the maximum of ``value`` and ``arr[i,j]``, atomically update the array, and return the old value.
2561
-
2562
- The operation is only atomic on a per-component basis for vectors and matrices.
2563
- """
2564
- ...
2565
-
2566
-
2567
- @over
2568
- def atomic_max(arr: Array[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2569
- """Compute the maximum of ``value`` and ``arr[i,j,k]``, atomically update the array, and return the old value.
2570
-
2571
- The operation is only atomic on a per-component basis for vectors and matrices.
2572
- """
2573
- ...
2574
-
2575
-
2576
- @over
2577
- def atomic_max(arr: Array[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2578
- """Compute the maximum of ``value`` and ``arr[i,j,k,l]``, atomically update the array, and return the old value.
2579
-
2580
- The operation is only atomic on a per-component basis for vectors and matrices.
2581
- """
2582
- ...
2583
-
2584
-
2585
- @over
2586
- def atomic_max(arr: FabricArray[Any], i: Int, value: Any) -> Any:
2587
- """Compute the maximum of ``value`` and ``arr[i]``, atomically update the array, and return the old value.
2588
-
2589
- The operation is only atomic on a per-component basis for vectors and matrices.
2590
- """
2591
- ...
2592
-
2593
-
2594
- @over
2595
- def atomic_max(arr: FabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2596
- """Compute the maximum of ``value`` and ``arr[i,j]``, atomically update the array, and return the old value.
2597
-
2598
- The operation is only atomic on a per-component basis for vectors and matrices.
2599
- """
2600
- ...
2601
-
2602
-
2603
- @over
2604
- def atomic_max(arr: FabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2605
- """Compute the maximum of ``value`` and ``arr[i,j,k]``, atomically update the array, and return the old value.
2606
-
2607
- The operation is only atomic on a per-component basis for vectors and matrices.
2608
- """
2609
- ...
2610
-
2611
-
2612
- @over
2613
- def atomic_max(arr: FabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2614
- """Compute the maximum of ``value`` and ``arr[i,j,k,l]``, atomically update the array, and return the old value.
2615
-
2616
- The operation is only atomic on a per-component basis for vectors and matrices.
2617
- """
2618
- ...
2619
-
2620
-
2621
- @over
2622
- def atomic_max(arr: IndexedFabricArray[Any], i: Int, value: Any) -> Any:
2623
- """Compute the maximum of ``value`` and ``arr[i]``, atomically update the array, and return the old value.
2624
-
2625
- The operation is only atomic on a per-component basis for vectors and matrices.
2626
- """
2627
- ...
2628
-
2629
-
2630
- @over
2631
- def atomic_max(arr: IndexedFabricArray[Any], i: Int, j: Int, value: Any) -> Any:
2632
- """Compute the maximum of ``value`` and ``arr[i,j]``, atomically update the array, and return the old value.
2633
-
2634
- The operation is only atomic on a per-component basis for vectors and matrices.
2635
- """
2636
- ...
2637
-
2638
-
2639
- @over
2640
- def atomic_max(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, value: Any) -> Any:
2641
- """Compute the maximum of ``value`` and ``arr[i,j,k]``, atomically update the array, and return the old value.
2642
-
2643
- The operation is only atomic on a per-component basis for vectors and matrices.
2644
- """
2645
- ...
2646
-
2647
-
2648
- @over
2649
- def atomic_max(arr: IndexedFabricArray[Any], i: Int, j: Int, k: Int, l: Int, value: Any) -> Any:
2650
- """Compute the maximum of ``value`` and ``arr[i,j,k,l]``, atomically update the array, and return the old value.
2651
-
2652
- The operation is only atomic on a per-component basis for vectors and matrices.
2653
- """
2654
- ...
2655
-
2656
-
2657
- @over
2658
- def lerp(a: Float, b: Float, t: Float) -> Float:
2659
- """Linearly interpolate two values ``a`` and ``b`` using factor ``t``, computed as ``a*(1-t) + b*t``"""
2660
- ...
2661
-
2662
-
2663
- @over
2664
- def lerp(a: Vector[Any, Float], b: Vector[Any, Float], t: Float) -> Vector[Any, Float]:
2665
- """Linearly interpolate two values ``a`` and ``b`` using factor ``t``, computed as ``a*(1-t) + b*t``"""
2666
- ...
2667
-
2668
-
2669
- @over
2670
- def lerp(a: Matrix[Any, Any, Float], b: Matrix[Any, Any, Float], t: Float) -> Matrix[Any, Any, Float]:
2671
- """Linearly interpolate two values ``a`` and ``b`` using factor ``t``, computed as ``a*(1-t) + b*t``"""
2672
- ...
2673
-
2674
-
2675
- @over
2676
- def lerp(a: Quaternion[Float], b: Quaternion[Float], t: Float) -> Quaternion[Float]:
2677
- """Linearly interpolate two values ``a`` and ``b`` using factor ``t``, computed as ``a*(1-t) + b*t``"""
2678
- ...
2679
-
2680
-
2681
- @over
2682
- def lerp(a: Transformation[Float], b: Transformation[Float], t: Float) -> Transformation[Float]:
2683
- """Linearly interpolate two values ``a`` and ``b`` using factor ``t``, computed as ``a*(1-t) + b*t``"""
2684
- ...
2685
-
2686
-
2687
- @over
2688
- def smoothstep(a: Float, b: Float, x: Float) -> Float:
2689
- """Smoothly interpolate between two values ``a`` and ``b`` using a factor ``x``,
2690
- and return a result between 0 and 1 using a cubic Hermite interpolation after clamping.
2691
- """
2692
- ...
2693
-
2694
-
2695
- @over
2696
- def expect_near(a: Float, b: Float, tolerance: Float):
2697
- """Prints an error to stdout if ``a`` and ``b`` are not closer than tolerance in magnitude"""
2698
- ...
2699
-
2700
-
2701
- @over
2702
- def expect_near(a: Vector[Any, Float], b: Vector[Any, Float], tolerance: Float):
2703
- """Prints an error to stdout if any element of ``a`` and ``b`` are not closer than tolerance in magnitude"""
2704
- ...
2705
-
2706
-
2707
- @over
2708
- def expect_near(a: Quaternion[Float], b: Quaternion[Float], tolerance: Float):
2709
- """Prints an error to stdout if any element of ``a`` and ``b`` are not closer than tolerance in magnitude"""
2710
- ...
2711
-
2712
-
2713
- @over
2714
- def expect_near(a: Matrix[Any, Any, Float], b: Matrix[Any, Any, Float], tolerance: Float):
2715
- """Prints an error to stdout if any element of ``a`` and ``b`` are not closer than tolerance in magnitude"""
2716
- ...
2717
-
2718
-
2719
- @over
2720
- def lower_bound(arr: Array[Scalar], value: Scalar) -> int:
2721
- """Search a sorted array ``arr`` for the closest element greater than or equal to ``value``."""
2722
- ...
2723
-
2724
-
2725
- @over
2726
- def lower_bound(arr: Array[Scalar], arr_begin: int32, arr_end: int32, value: Scalar) -> int:
2727
- """Search a sorted array ``arr`` in the range [arr_begin, arr_end) for the closest element greater than or equal to ``value``."""
2728
- ...
2729
-
2730
-
2731
- @over
2732
- def add(a: Scalar, b: Scalar) -> Scalar:
2733
- """ """
2734
- ...
2735
-
2736
-
2737
- @over
2738
- def add(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
2739
- """ """
2740
- ...
2741
-
2742
-
2743
- @over
2744
- def add(a: Quaternion[Scalar], b: Quaternion[Scalar]) -> Quaternion[Scalar]:
2745
- """ """
2746
- ...
2747
-
2748
-
2749
- @over
2750
- def add(a: Matrix[Any, Any, Scalar], b: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
2751
- """ """
2752
- ...
2753
-
2754
-
2755
- @over
2756
- def add(a: Transformation[Scalar], b: Transformation[Scalar]) -> Transformation[Scalar]:
2757
- """ """
2758
- ...
2759
-
2760
-
2761
- @over
2762
- def add(a: Tile, b: Tile) -> Tile:
2763
- """Add each element of two tiles together"""
2764
- ...
2765
-
2766
-
2767
- @over
2768
- def sub(a: Scalar, b: Scalar) -> Scalar:
2769
- """ """
2770
- ...
2771
-
2772
-
2773
- @over
2774
- def sub(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
2775
- """ """
2776
- ...
2777
-
2778
-
2779
- @over
2780
- def sub(a: Matrix[Any, Any, Scalar], b: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
2781
- """ """
2782
- ...
2783
-
2784
-
2785
- @over
2786
- def sub(a: Quaternion[Scalar], b: Quaternion[Scalar]) -> Quaternion[Scalar]:
2787
- """ """
2788
- ...
2789
-
2790
-
2791
- @over
2792
- def sub(a: Transformation[Scalar], b: Transformation[Scalar]) -> Transformation[Scalar]:
2793
- """ """
2794
- ...
2795
-
2796
-
2797
- @over
2798
- def sub(a: Tile, b: Tile) -> Tile:
2799
- """Subtract each element b from a"""
2800
- ...
2801
-
2802
-
2803
- @over
2804
- def bit_and(a: Int, b: Int) -> Int:
2805
- """ """
2806
- ...
2807
-
2808
-
2809
- @over
2810
- def bit_or(a: Int, b: Int) -> Int:
2811
- """ """
2812
- ...
2813
-
2814
-
2815
- @over
2816
- def bit_xor(a: Int, b: Int) -> Int:
2817
- """ """
2818
- ...
2819
-
2820
-
2821
- @over
2822
- def lshift(a: Int, b: Int) -> Int:
2823
- """ """
2824
- ...
2825
-
2826
-
2827
- @over
2828
- def rshift(a: Int, b: Int) -> Int:
2829
- """ """
2830
- ...
2831
-
2832
-
2833
- @over
2834
- def invert(a: Int) -> Int:
2835
- """ """
2836
- ...
2837
-
2838
-
2839
- @over
2840
- def mul(a: Scalar, b: Scalar) -> Scalar:
2841
- """ """
2842
- ...
2843
-
2844
-
2845
- @over
2846
- def mul(a: Vector[Any, Scalar], b: Scalar) -> Vector[Any, Scalar]:
2847
- """ """
2848
- ...
2849
-
2850
-
2851
- @over
2852
- def mul(a: Scalar, b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
2853
- """ """
2854
- ...
2855
-
2856
-
2857
- @over
2858
- def mul(a: Quaternion[Scalar], b: Scalar) -> Quaternion[Scalar]:
2859
- """ """
2860
- ...
2861
-
2862
-
2863
- @over
2864
- def mul(a: Scalar, b: Quaternion[Scalar]) -> Quaternion[Scalar]:
2865
- """ """
2866
- ...
2867
-
2868
-
2869
- @over
2870
- def mul(a: Quaternion[Scalar], b: Quaternion[Scalar]) -> Quaternion[Scalar]:
2871
- """ """
2872
- ...
2873
-
2874
-
2875
- @over
2876
- def mul(a: Scalar, b: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
2877
- """ """
2878
- ...
2879
-
2880
-
2881
- @over
2882
- def mul(a: Matrix[Any, Any, Scalar], b: Scalar) -> Matrix[Any, Any, Scalar]:
2883
- """ """
2884
- ...
2885
-
2886
-
2887
- @over
2888
- def mul(a: Matrix[Any, Any, Scalar], b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
2889
- """ """
2890
- ...
2891
-
2892
-
2893
- @over
2894
- def mul(a: Vector[Any, Scalar], b: Matrix[Any, Any, Scalar]) -> Vector[Any, Scalar]:
2895
- """ """
2896
- ...
2897
-
2898
-
2899
- @over
2900
- def mul(a: Matrix[Any, Any, Scalar], b: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
2901
- """ """
2902
- ...
2903
-
2904
-
2905
- @over
2906
- def mul(a: Transformation[Scalar], b: Transformation[Scalar]) -> Transformation[Scalar]:
2907
- """ """
2908
- ...
2909
-
2910
-
2911
- @over
2912
- def mul(a: Scalar, b: Transformation[Scalar]) -> Transformation[Scalar]:
2913
- """ """
2914
- ...
2915
-
2916
-
2917
- @over
2918
- def mul(a: Transformation[Scalar], b: Scalar) -> Transformation[Scalar]:
2919
- """ """
2920
- ...
2921
-
2922
-
2923
- @over
2924
- def mul(x: Tile, y: Scalar) -> Tile:
2925
- """Multiply each element of a tile by a scalar"""
2926
- ...
2927
-
2928
-
2929
- @over
2930
- def mul(x: Scalar, y: Tile) -> Tile:
2931
- """Multiply each element of a tile by a scalar"""
2932
- ...
2933
-
2934
-
2935
- @over
2936
- def mod(a: Scalar, b: Scalar) -> Scalar:
2937
- """Modulo operation using truncated division."""
2938
- ...
2939
-
2940
-
2941
- @over
2942
- def mod(a: Vector[Any, Scalar], b: Vector[Any, Scalar]) -> Scalar:
2943
- """Modulo operation using truncated division."""
2944
- ...
2945
-
2946
-
2947
- @over
2948
- def div(a: Scalar, b: Scalar) -> Scalar:
2949
- """ """
2950
- ...
2951
-
2952
-
2953
- @over
2954
- def div(a: Vector[Any, Scalar], b: Scalar) -> Vector[Any, Scalar]:
2955
- """ """
2956
- ...
2957
-
2958
-
2959
- @over
2960
- def div(a: Scalar, b: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
2961
- """ """
2962
- ...
2963
-
2964
-
2965
- @over
2966
- def div(a: Matrix[Any, Any, Scalar], b: Scalar) -> Matrix[Any, Any, Scalar]:
2967
- """ """
2968
- ...
2969
-
2970
-
2971
- @over
2972
- def div(a: Scalar, b: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
2973
- """ """
2974
- ...
2975
-
2976
-
2977
- @over
2978
- def div(a: Quaternion[Scalar], b: Scalar) -> Quaternion[Scalar]:
2979
- """ """
2980
- ...
2981
-
2982
-
2983
- @over
2984
- def div(a: Scalar, b: Quaternion[Scalar]) -> Quaternion[Scalar]:
2985
- """ """
2986
- ...
2987
-
2988
-
2989
- @over
2990
- def floordiv(a: Scalar, b: Scalar) -> Scalar:
2991
- """ """
2992
- ...
2993
-
2994
-
2995
- @over
2996
- def pos(x: Scalar) -> Scalar:
2997
- """ """
2998
- ...
2999
-
3000
-
3001
- @over
3002
- def pos(x: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
3003
- """ """
3004
- ...
3005
-
3006
-
3007
- @over
3008
- def pos(x: Quaternion[Scalar]) -> Quaternion[Scalar]:
3009
- """ """
3010
- ...
3011
-
3012
-
3013
- @over
3014
- def pos(x: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
3015
- """ """
3016
- ...
3017
-
3018
-
3019
- @over
3020
- def neg(x: Scalar) -> Scalar:
3021
- """ """
3022
- ...
3023
-
3024
-
3025
- @over
3026
- def neg(x: Vector[Any, Scalar]) -> Vector[Any, Scalar]:
3027
- """ """
3028
- ...
3029
-
3030
-
3031
- @over
3032
- def neg(x: Quaternion[Scalar]) -> Quaternion[Scalar]:
3033
- """ """
3034
- ...
3035
-
3036
-
3037
- @over
3038
- def neg(x: Matrix[Any, Any, Scalar]) -> Matrix[Any, Any, Scalar]:
3039
- """ """
3040
- ...
3041
-
3042
-
3043
- @over
3044
- def neg(x: Tile) -> Tile:
3045
- """Negate each element of a tile"""
3046
- ...
3047
-
3048
-
3049
- @over
3050
- def unot(a: bool) -> bool:
3051
- """ """
3052
- ...
3053
-
3054
-
3055
- @over
3056
- def unot(a: int8) -> bool:
3057
- """ """
3058
- ...
3059
-
3060
-
3061
- @over
3062
- def unot(a: uint8) -> bool:
3063
- """ """
3064
- ...
3065
-
3066
-
3067
- @over
3068
- def unot(a: int16) -> bool:
3069
- """ """
3070
- ...
3071
-
3072
-
3073
- @over
3074
- def unot(a: uint16) -> bool:
3075
- """ """
3076
- ...
3077
-
3078
-
3079
- @over
3080
- def unot(a: int32) -> bool:
3081
- """ """
3082
- ...
3083
-
3084
-
3085
- @over
3086
- def unot(a: uint32) -> bool:
3087
- """ """
3088
- ...
3089
-
3090
-
3091
- @over
3092
- def unot(a: int64) -> bool:
3093
- """ """
3094
- ...
3095
-
3096
-
3097
- @over
3098
- def unot(a: uint64) -> bool:
3099
- """ """
3100
- ...
3101
-
3102
-
3103
- @over
3104
- def unot(a: Array[Any]) -> bool:
3105
- """ """
3106
- ...
3107
-
3108
-
3109
- @over
3110
- def tile_diag_add(a: Tile, d: Tile) -> Tile:
3111
- """Add a square matrix and a diagonal matrix 'd' represented as a 1D tile"""
3112
- ...
3113
-
3114
-
3115
- @over
3116
- def tile_matmul(a: Tile, b: Tile, out: Tile) -> Tile:
3117
- """Computes the matrix product and accumulates ``out += a*b``.
3118
-
3119
- Supported datatypes are:
3120
- * fp16, fp32, fp64 (real)
3121
- * vec2h, vec2f, vec2d (complex)
3122
-
3123
- All input and output tiles must have the same datatype. Tile data will automatically be migrated
3124
- to shared memory if necessary and will use TensorCore operations when available.
3125
-
3126
- :param a: A tile with ``shape=(M, K)``
3127
- :param b: A tile with ``shape=(K, N)``
3128
- :param out: A tile with ``shape=(M, N)``
3129
-
3130
- """
3131
- ...
3132
-
3133
-
3134
- @over
3135
- def tile_matmul(a: Tile, b: Tile) -> Tile:
3136
- """Computes the matrix product ``out = a*b``.
3137
-
3138
- Supported datatypes are:
3139
- * fp16, fp32, fp64 (real)
3140
- * vec2h, vec2f, vec2d (complex)
3141
-
3142
- Both input tiles must have the same datatype. Tile data will automatically be migrated
3143
- to shared memory if necessary and will use TensorCore operations when available.
3144
-
3145
- :param a: A tile with ``shape=(M, K)``
3146
- :param b: A tile with ``shape=(K, N)``
3147
- :returns: A tile with ``shape=(M, N)``
3148
-
3149
- """
3150
- ...
3151
-
3152
-
3153
- @over
3154
- def tile_fft(inout: Tile) -> Tile:
3155
- """Compute the forward FFT along the second dimension of a 2D tile of data.
3156
-
3157
- This function cooperatively computes the forward FFT on a tile of data inplace, treating each row individually.
3158
-
3159
- Note that computing the adjoint is not yet supported.
3160
-
3161
- Supported datatypes are:
3162
- * vec2f, vec2d
3163
-
3164
- :param inout: The input/output tile
3165
- """
3166
- ...
3167
-
3168
-
3169
- @over
3170
- def tile_ifft(inout: Tile) -> Tile:
3171
- """Compute the inverse FFT along the second dimension of a 2D tile of data.
3172
-
3173
- This function cooperatively computes the inverse FFT on a tile of data inplace, treating each row individually.
3174
-
3175
- Note that computing the adjoint is not yet supported.
3176
-
3177
- Supported datatypes are:
3178
- * vec2f, vec2d
3179
-
3180
- :param inout: The input/output tile
3181
- """
3182
- ...
3183
-
3184
-
3185
- @over
3186
- def tile_cholesky(A: Tile) -> Tile:
3187
- """Compute the Cholesky factorization L of a matrix A.
3188
- L is lower triangular and satisfies LL^T = A.
3189
-
3190
- Note that computing the adjoint is not yet supported.
3191
-
3192
- Supported datatypes are:
3193
- * float32
3194
- * float64
3195
-
3196
- :param A: A square, symmetric positive-definite, matrix.
3197
- :returns L: A square, lower triangular, matrix, such that LL^T = A
3198
- """
3199
- ...
3200
-
3201
-
3202
- @over
3203
- def tile_cholesky_solve(L: Tile, x: Tile):
3204
- """With L such that LL^T = A, solve for x in Ax = y
3205
-
3206
- Note that computing the adjoint is not yet supported.
3207
-
3208
- Supported datatypes are:
3209
- * float32
3210
- * float64
3211
-
3212
- :param L: A square, lower triangular, matrix, such that LL^T = A
3213
- :param x: An 1D tile of length M
3214
- :returns y: An 1D tile of length M such that LL^T y = x
3215
- """
3216
- ...
3217
-
3218
-
3219
- @over
3220
- def static(expr: Any) -> Any:
3221
- """Evaluate a static Python expression and replaces it with its result.
3222
-
3223
- See the :ref:`code generation guide <static_expressions>` for more details.
3224
-
3225
- The inner expression must only reference variables that are available from the current scope where the Warp kernel or function containing the expression is defined,
3226
- which includes constant variables and variables captured in the current closure in which the function or kernel is implemented.
3227
- The return type of the expression must be either a Warp function, a string, or a type that is supported inside Warp kernels and functions
3228
- (excluding Warp arrays since they cannot be created in a Warp kernel at the moment).
3229
- """
3230
- ...
3231
-
3232
-
3233
- @over
3234
- def len(a: Vector[Any, Scalar]) -> int:
3235
- """Return the number of elements in a vector."""
3236
- ...
3237
-
3238
-
3239
- @over
3240
- def len(a: Quaternion[Scalar]) -> int:
3241
- """Return the number of elements in a quaternion."""
3242
- ...
3243
-
3244
-
3245
- @over
3246
- def len(a: Matrix[Any, Any, Scalar]) -> int:
3247
- """Return the number of rows in a matrix."""
3248
- ...
3249
-
3250
-
3251
- @over
3252
- def len(a: Transformation[Float]) -> int:
3253
- """Return the number of elements in a transformation."""
3254
- ...
3255
-
3256
-
3257
- @over
3258
- def len(a: Array[Any]) -> int:
3259
- """Return the size of the first dimension in an array."""
3260
- ...
3261
-
3262
-
3263
- @over
3264
- def len(a: Tile) -> int:
3265
- """Return the number of rows in a tile."""
3266
- ...
3267
-
3268
-
3269
- @over
3270
- def norm_l1(v: Any):
3271
- """Computes the L1 norm of a vector v.
3272
-
3273
- .. math:: \|v\|_1 = \sum_i |v_i|
3274
-
3275
- Args:
3276
- v (Vector[Any,Float]): The vector to compute the L1 norm of.
3277
-
3278
- Returns:
3279
- float: The L1 norm of the vector.
3280
- """
3281
- ...
3282
-
3283
-
3284
- @over
3285
- def norm_l2(v: Any):
3286
- """Computes the L2 norm of a vector v.
3287
-
3288
- .. math:: \|v\|_2 = \sqrt{\sum_i v_i^2}
3289
-
3290
- Args:
3291
- v (Vector[Any,Float]): The vector to compute the L2 norm of.
3292
-
3293
- Returns:
3294
- float: The L2 norm of the vector.
3295
- """
3296
- ...
3297
-
3298
-
3299
- @over
3300
- def norm_huber(v: Any, delta: float):
3301
- """Computes the Huber norm of a vector v with a given delta.
3302
-
3303
- .. math::
3304
- H(v) = \begin{cases} \frac{1}{2} \|v\|^2 & \text{if } \|v\| \leq \delta \\ \delta(\|v\| - \frac{1}{2}\delta) & \text{otherwise} \end{cases}
3305
-
3306
- .. image:: /img/norm_huber.svg
3307
- :align: center
3308
-
3309
- Args:
3310
- v (Vector[Any,Float]): The vector to compute the Huber norm of.
3311
- delta (float): The threshold value, defaults to 1.0.
3312
-
3313
- Returns:
3314
- float: The Huber norm of the vector.
3315
- """
3316
- ...
3317
-
3318
-
3319
- @over
3320
- def norm_pseudo_huber(v: Any, delta: float):
3321
- """Computes the "pseudo" Huber norm of a vector v with a given delta.
3322
-
3323
- .. math::
3324
- H^\prime(v) = \delta \sqrt{1 + \frac{\|v\|^2}{\delta^2}}
3325
-
3326
- .. image:: /img/norm_pseudo_huber.svg
3327
- :align: center
3328
-
3329
- Args:
3330
- v (Vector[Any,Float]): The vector to compute the Huber norm of.
3331
- delta (float): The threshold value, defaults to 1.0.
3332
-
3333
- Returns:
3334
- float: The Huber norm of the vector.
3335
- """
3336
- ...
3337
-
3338
-
3339
- @over
3340
- def smooth_normalize(v: Any, delta: float):
3341
- """Normalizes a vector using the pseudo-Huber norm.
3342
-
3343
- See :func:`norm_pseudo_huber`.
3344
-
3345
- .. math::
3346
- \frac{v}{H^\prime(v)}
3347
-
3348
- Args:
3349
- v (Vector[Any,Float]): The vector to normalize.
3350
- delta (float): The threshold value, defaults to 1.0.
3351
-
3352
- Returns:
3353
- Vector[Any,Float]: The normalized vector.
3354
- """
3355
- ...
3356
-
3357
-
3358
- @over
3359
- def transform_from_matrix(mat: Matrix[4, 4, float32]) -> Transformation[float32]:
3360
- """Construct a transformation from a 4x4 matrix.
3361
-
3362
- Args:
3363
- mat (Matrix[4, 4, Float]): Matrix to convert.
3364
-
3365
- Returns:
3366
- Transformation[Float]: The transformation.
3367
- """
3368
- ...
3369
-
3370
-
3371
- @over
3372
- def transform_to_matrix(xform: Transformation[float32]) -> Matrix[4, 4, float32]:
3373
- """Convert a transformation to a 4x4 matrix.
3374
-
3375
- Args:
3376
- xform (Transformation[Float]): Transformation to convert.
3377
-
3378
- Returns:
3379
- Matrix[4, 4, Float]: The matrix.
3380
- """
3381
- ...