Built-Ins#
Warp built-in types and functions.
Built-in types and functions are available within Warp kernels and optionally also from the Warp Python runtime API.
Each built-in function is tagged to indicate where it can be used:
Kernel - Can be called from inside a Warp kernel
Python - Can be called at the Python scope
Differentiable - Propagates gradients when used in reverse mode automatic differentiation
For a listing of the API that is exclusively intended to be used at the Python scope and run inside the CPython interpreter, see warp.
Scalar Math#
Return the absolute value of |
|
Return arccos of |
|
Return arcsin of |
|
Return the arctangent of |
|
Return the 2-argument arctangent, atan2, of the point |
|
Return the cube root of |
|
Return the smallest integer that is greater than or equal to |
|
Clamp the value of |
|
Return the cosine of |
|
Return the cosh of |
|
Convert |
|
Return the error function of |
|
Return the complementary error function of |
|
Return the inverse complementary error function of |
|
Return the inverse error function of |
|
Return the value of the exponential function \(e^x\). |
|
Return the largest integer that is less than or equal to |
|
Retrieve the fractional part of |
|
Return |
|
Return |
|
Return |
|
Return the natural logarithm (base-e) of |
|
Return the binary logarithm (base-2) of |
|
Return the common logarithm (base-10) of |
|
Return the maximum of two scalars. |
|
Return the minimum of two scalars. |
|
Return 1.0 if |
|
Return the result of |
|
Convert |
|
Return the nearest integer value to |
|
Return the nearest integer value to |
|
Return -1 if |
|
Return the sine of |
|
Return the sinh of |
|
Return the square root of |
|
Return 1.0 if |
|
Return the tangent of |
|
Return the tanh of |
|
Return the nearest integer that is closer to zero than |
Vector Math#
Return the index of the maximum element of a vector |
|
Return the index of the minimum element of a vector |
|
Compute the cross product of two 3D vectors. |
|
Component-wise division of two vectors. |
|
Component-wise multiplication of two vectors. |
|
Compute the double dot product between two matrices. |
|
Return the determinant of a 2x2 matrix |
|
Returns a matrix with the components of the vector |
|
Compute the dot product between two vectors. |
|
Compute the eigendecomposition of a 3x3 matrix |
|
Returns a vector containing the diagonal elements of the square matrix |
|
Create an identity matrix with shape=(n,n) with the type given by |
|
Return the inverse of a 2x2 matrix |
|
Compute the length of a floating-point vector |
|
Compute the squared length of a vector |
|
Construct a matrix. |
|
Construct a matrix from column vectors. |
|
Construct a matrix from row vectors. |
|
Computes the Huber norm of a vector v with a given delta. |
|
Computes the L1 norm of a vector v. |
|
Computes the L2 norm of a vector v. |
|
Computes the "pseudo" Huber norm of a vector v with a given delta. |
|
Compute the normalized value of |
|
Compute the outer product |
|
Compute the QR decomposition of a 3x3 matrix |
|
Compute the skew-symmetric 3x3 matrix for a 3D vector |
|
Normalizes a vector using the pseudo-Huber norm. |
|
Compute the SVD of a 2x2 matrix |
|
Compute the SVD of a 3x3 matrix |
|
Return the trace of the matrix |
|
Return the transpose of the matrix |
|
Construct a vector of given length and dtype. |
Quaternion Math#
Construct a quaternion representing a rotation of angle radians around the given axis. |
|
Construct a quaternion from a 3x3 matrix. |
|
Construct an identity quaternion with zero imaginary part and real part of 1.0 |
|
Compute quaternion conjugate. |
|
Rotate a vector by a quaternion. |
|
Rotate a vector by the inverse of a quaternion. |
|
Construct a quaternion representing a combined roll (z), pitch (x), yaw rotations (y) in radians. |
|
Linearly interpolate between two quaternions. |
|
Extract the rotation axis and angle radians a quaternion represents. |
|
Convert a quaternion to a 3x3 rotation matrix. |
|
Construct a zero-initialized quaternion. |
Transformations#
Compose a 4x4 transformation matrix from a 3D position, quaternion orientation, and 3D scale. |
|
Decompose a 4x4 transformation matrix into 3D position, quaternion orientation, and 3D scale. |
|
Construct a transformation from a 4x4 matrix. |
|
Return the rotational part of a transform |
|
Return the translational part of a transform |
|
Construct an identity transform with zero translation and identity rotation. |
|
Compute the inverse of the transformation |
|
Multiply two rigid body transformations together. |
|
Apply the transform to a point |
|
Set the rotational part of a transform |
|
Set the translational part of a transform |
|
Convert a transformation to a 4x4 matrix. |
|
Apply the transform to a vector |
|
Construct a rigid-body transformation with translation part |
Spatial Math#
Construct a 6x6 spatial inertial matrix from two 3x3 diagonal blocks. |
|
Return the bottom (second) part of a 6D screw vector. |
|
Compute the cross product of two 6D screw vectors. |
|
Compute the dual cross product of two 6D screw vectors. |
|
Compute the dot product of two 6D screw vectors. |
|
Return the top (first) part of a 6D screw vector. |
|
Zero-initialize a 6D screw vector. |
Tile Primitives#
Construct a new tile from per-thread kernel values. |
|
Generate a tile of linearly spaced elements. |
|
Cooperatively compute the index of the maximum element in the tile using all threads in the block. |
|
Cooperatively compute the index of the minimum element in the tile using all threads in the block. |
|
Assign a tile to a subrange of a destination tile. |
|
Return a new tile with the same data as the input tile, but with a different data type. |
|
Atomically add a tile onto the array a, each element will be updated atomically. |
|
Atomically add a tile to a global memory array, with storage along a specified axis mapped according to a 1D tile of indices. |
|
Broadcast a tile. |
|
Construct an axis-aligned bounding box query against a BVH object for thread-block parallel traversal. |
|
Move to the next bound in a thread-block parallel BVH query and return results as a tile. |
|
Construct a ray query against a BVH object for thread-block parallel traversal. |
|
Compute the Cholesky factorization L of a matrix A. |
|
Compute the Cholesky factorization L of a matrix A. |
|
With L such that LL^T = A, solve for x in Ax = y |
|
With L such that LL^T = A, solve for x in Ax = y by overwriting y with x |
|
Add a square matrix and a diagonal matrix 'd' represented as a 1D tile |
|
Extract a single element from the tile. |
|
Compute the forward FFT along the second dimension of a 2D tile of data. |
|
Allocate a tile filled with the specified value. |
|
Compute the inverse FFT along the second dimension of a 2D tile of data. |
|
Loads a tile from a global memory array. |
|
Loads a tile from a global memory array, with loads along a specified axis mapped according to a 1D tile of indices. |
|
Solve for z in Lz = y, where L is a lower triangular matrix. |
|
Solve for z in Lz = y, where L is a lower triangular matrix by overwriting y with z. |
|
Apply a unary function onto the tile. |
|
Computes the matrix product and accumulates |
|
Cooperatively compute the maximum of the tile elements using all threads in the block. |
|
Construct an axis-aligned bounding box query against a |
|
Move to the next triangle in a thread-block parallel mesh AABB query and return results as a tile. |
|
Cooperatively compute the minimum of the tile elements using all threads in the block. |
|
Allocate a tile of one-initialized items. |
|
Generate a tile of random floats. |
|
Generate a tile of random integers. |
|
Apply a custom reduction operator across the tile. |
|
Return a reshaped view of a tile with the same data. |
|
Exclusive scan (prefix sum) across the tile. |
|
Inclusive scan (prefix sum) across the tile. |
|
Inclusive max scan across the tile. |
|
Inclusive min scan across the tile. |
|
Cooperatively sort the elements of two tiles in ascending order based on the keys, using all threads in the block. |
|
Return a squeezed view of a tile with the same data. |
|
Store a tile to a global memory array. |
|
Store a tile to a global memory array, with storage along a specified axis mapped according to a 1D tile of indices. |
|
Cooperatively compute the sum of the tile elements using all threads in the block. |
|
Transpose a tile. |
|
Solve for x in Ux = z, where U is an upper triangular matrix. |
|
Solve for x in Ux = z, where U is an upper triangular matrix by overwriting z with x. |
|
Return a slice of a given tile [offset, offset+shape], if shape is not specified it will be inferred from the unspecified offset dimensions. |
|
Allocate a tile of zero-initialized items. |
|
Convert a tile back to per-thread values. |
Geometry#
Get the root of a group in a BVH. |
|
Construct an axis-aligned bounding box query against a BVH object. |
|
Construct an axis-aligned bounding box query against a BVH object for thread-block parallel traversal. |
|
Move to the next bound returned by the query. |
|
Move to the next bound in a thread-block parallel BVH query and return results as a tile. |
|
Construct a ray query against a BVH object. |
|
Construct a ray query against a BVH object for thread-block parallel traversal. |
|
Finds the closest points between two edges. |
|
Return the index of a point in the |
|
Construct a point query against a |
|
Move to the next point in the hash grid query. |
|
Tests for intersection between two triangles (v0, v1, v2) and (u0, u1, u2) using Moller's method. |
|
Evaluates the face normal the mesh given a face index. |
|
Evaluates the position on the |
|
Evaluates the velocity on the |
|
Retrieves the mesh given its index. |
|
Get the root of a group in a |
|
Returns the point-index of the mesh given a face-vertex index. |
|
Returns the point of the mesh given a index. |
|
Returns the velocity of the mesh given a index. |
|
Construct an axis-aligned bounding box query against a |
|
Move to the next triangle whose bounding box overlaps the query bounding box. |
|
Move to the next triangle in a thread-block parallel mesh AABB query and return results as a tile. |
|
Construct an axis-aligned bounding box query against a |
|
Computes the furthest point on the mesh with identifier id to the given point in space. |
|
Computes the closest point on the |
|
Computes the closest point on the |
|
Computes the closest point on the |
|
Computes the closest point on the |
|
Computes the closest point on the |
|
Computes the closest ray hit on the |
|
Returns |
|
Count the number of intersections between a ray and a |
Utility#
Atomically adds |
|
Atomically performs a bitwise AND between |
|
Atomically compare and swap |
|
Atomically exchange |
|
Compute the maximum of |
|
Compute the minimum of |
|
Atomically performs a bitwise OR between |
|
Atomically subtracts |
|
Atomically performs a bitwise XOR between |
|
Returns the number of threads in the current block. |
|
Debugger breakpoint |
|
Reinterpret a value as a different type while preserving its bit pattern. |
|
Prints an error to stdout if |
|
Return the number of elements in a vector. |
|
Linearly interpolate two values |
|
Print variable to stdout |
|
Allows printing formatted strings using C-style format specifiers. |
|
Returns the range in reversed order. |
|
Select between two arguments, if |
|
Smoothly interpolate between two values |
|
Return the current thread index for a 1D kernel launch. |
|
Select between two arguments, if |
|
Volumes#
Transform a point |
|
Transform a direction |
|
Returns the value of voxel with coordinates |
|
Returns the value of voxel with coordinates |
|
Returns the |
|
Returns the index associated to the voxel with coordinates |
|
Returns the vector value of voxel with coordinates |
|
Sample the volume of type dtype given by |
|
Sample the volume given by |
|
Sample the volume given by |
|
Sample the volume and its gradient given by |
|
Sample the volume given by |
|
Sample the |
|
Sample the volume given by |
|
Sample the vector volume given by |
|
Store |
|
Store |
|
Store |
|
Store |
|
Transform a point |
|
Transform a direction |
Random#
Divergence-free vector field based on the gradient of a Perlin noise function. |
|
Non-periodic Perlin-style noise in 1D. |
|
Periodic Perlin-style noise in 1D. |
|
Generate a random sample from a Poisson distribution. |
|
Initialize a new random number generator given a user-defined seed. |
|
Return a random float between [0.0, 1.0). |
|
Return a random integer in the range [-2^31, 2^31). |
|
Sample a normal (Gaussian) distribution of mean 0 and variance 1. |
|
Return a random unsigned integer in the range [0, 2^32). |
|
Inverse-transform sample a cumulative distribution function. |
|
Uniformly sample a triangle. |
|
Uniformly sample a unit cube. |
|
Uniformly sample a disk in the xy plane. |
|
Uniformly sample a unit hemisphere. |
|
Uniformly sample a unit hemisphere surface. |
|
Uniformly sample a ring in the xy plane. |
|
Uniformly sample a unit sphere. |
|
Uniformly sample a unit sphere surface. |
|
Uniformly sample a unit square. |
Other#
Search a sorted array |
Operators#
Code Generation#
Evaluate a static Python expression and replaces it with its result. |