latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay
Tensors
Returns True if obj is a TensorPlay tensor. |
|
Returns True if the data type of |
|
Returns True if the |
|
Returns True if the data type of |
|
Returns True if |
|
Returns True if the |
|
Sets the default floating point dtype to |
|
Get the current default floating point |
|
Sets the default |
|
Gets the default |
|
Returns the total number of elements in the |
|
Set printing options for tensor output. |
Creation Ops
Constructs a tensor with no autograd history (also known as a "leaf tensor", see Autograd mechanics) by copying |
|
Constructs a sparse tensor in COO(rdinate) format with specified values at the given |
|
Constructs a sparse tensor in CSR (Compressed Sparse Row) with specified values at the given |
|
Constructs a sparse tensor in CSC (Compressed Sparse Column) with specified values at the given |
|
Constructs a sparse tensor in BSR (Block Compressed Sparse Row)) with specified 2-dimensional blocks at the given |
|
Constructs a sparse tensor in BSC (Block Compressed Sparse Column)) with specified 2-dimensional blocks at the given |
|
Converts |
|
Converts |
|
Create a view of an existing tensorplay.Tensor |
|
Creates a CPU tensor with a storage backed by a memory-mapped file. |
|
Creates a |
|
Creates a 1-dimensional |
|
Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument |
|
Returns a tensor filled with the scalar value 0, with the same size as |
|
Returns a tensor filled with the scalar value 1, with the shape defined by the variable argument |
|
Returns a tensor filled with the scalar value 1, with the same size as |
|
Returns a 1-D tensor of size with values from the interval |
|
Returns a 1-D tensor of size with values from |
|
Creates a one-dimensional tensor of size |
|
Creates a one-dimensional tensor of size |
|
Returns a 2-D tensor with ones on the diagonal and zeros elsewhere. |
|
empty(*size, *, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False, pin_memory=False, memory_format=tensorplay.contiguous_format) -> Tensor |
|
Returns an uninitialized tensor with the same size as |
|
Creates an uninitialized, non-overlapping and dense tensor with the specified |
|
Creates a tensor with the specified |
|
Creates a tensor of size |
|
Returns a tensor with the same size as |
|
Converts a float tensor to a quantized tensor with given scale and zero point. |
|
Converts a float tensor to a quantized tensor with scale and zero_point calculated dynamically based on the input. |
|
Converts a float tensor to a per-channel quantized tensor with given scales and zero points. |
|
Returns an fp32 Tensor by dequantizing a quantized Tensor |
|
Constructs a complex tensor with its real part equal to |
|
Constructs a complex tensor whose elements are Cartesian coordinates corresponding to the polar coordinates with absolute value |
|
Computes the Heaviside step function for each element in |
Indexing, Slicing, Joining, Mutating Ops
Returns a view of the tensor conjugated and with the last two dimensions transposed. |
|
Performs the same operation as |
|
Returns a tensor containing the indices of all non-zero elements of |
|
Performs the same operation as |
|
Embeds the values of the |
|
Concatenates the given sequence of tensors in |
|
Performs the same operation as |
|
Alias of |
|
Alias of |
|
Returns a view of |
|
Attempts to split a tensor into the specified number of chunks. |
|
Performs the same operation as |
|
Performs the same operation as |
|
Performs the same operation as |
|
Splits |
|
Creates a new tensor by horizontally stacking the tensors in |
|
Stack tensors in sequence depthwise (along third axis). |
|
Performs the same operation as |
|
Gathers values along an axis specified by dim. |
|
Splits |
|
Stack tensors in sequence horizontally (column wise). |
|
See |
|
See |
|
See |
|
Returns a new tensor which indexes the |
|
Performs the same operation as |
|
Returns a new 1-D tensor which indexes the |
|
Moves the dimension(s) of |
|
Alias for |
|
Returns a new tensor that is a narrowed version of |
|
Same as |
|
Returns a view of the original tensor |
|
Performs the same operation as |
|
Returns a tensor with the same data and number of elements as |
|
Alias of |
|
Slices the |
|
Performs the same operation as |
|
Out-of-place version of |
|
Embeds the values of the |
|
Embeds the values of the |
|
Performs the same operation as |
|
Embeds the values of the |
|
Out-of-place version of |
|
Out-of-place version of |
|
Perform a segment reduction operation on the input tensor along the specified axis. |
|
Performs the same operation as |
|
Performs the same operation as |
|
Returns a tensor with all specified dimensions of |
|
Performs the same operation as |
|
Concatenates a sequence of tensors along a new dimension. |
|
Alias for |
|
Alias for |
|
Expects |
|
Performs the same operation as |
|
Returns a new tensor with the elements of |
|
Selects values from |
|
Splits a tensor into multiple sub-tensors, all of which are views of |
|
Constructs a tensor by repeating the elements of |
|
Returns a tensor that is a transposed version of |
|
Performs the same operation as |
|
Removes a tensor dimension. |
|
Performs the same operation as |
|
Performs the same operation as |
|
Converts flat indices into coordinate tuples (one LongTensor per dim). |
|
Returns a new tensor with a dimension of size one inserted at the specified position. |
|
Performs the same operation as |
|
Performs the same operation as |
|
Performs the same operation as |
|
Performs the same operation as |
|
Performs the same operation as |
|
Splits |
|
Stack tensors in sequence vertically (row wise). |
|
Return a tensor of elements selected from either |
Generators
Creates and returns a generator object that manages the state of the algorithm which produces pseudo random numbers. |
Random sampling
Draws binary random numbers (0 or 1) from a Bernoulli distribution. |
|
Returns a tensor where each row contains |
|
Returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given. |
|
Returns a tensor of the same size as |
|
rand(*size, *, generator=None, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False, pin_memory=False) -> Tensor |
|
Returns a tensor with the same size as |
|
Returns a tensor filled with random integers generated uniformly between |
|
Returns a tensor with the same shape as Tensor |
|
randn(*size, *, generator=None, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False, pin_memory=False) -> Tensor |
|
Returns a tensor with the same size as |
|
Returns a random permutation of integers from |
Serialization
Parallelism
Returns the number of threads used for parallelizing CPU operations |
|
Sets the number of threads used for intraop parallelism on CPU. |
Locally disabling gradient computation
Context-manager that disables gradient calculation. |
|
Context-manager that enables gradient calculation. |
|
Context-manager that sets gradient calculation on or off. |
|
Returns True if grad mode is currently enabled. |
|
Context manager that enables or disables inference mode. |
Pointwise Ops
Computes the absolute value of each element in |
|
Alias for |
|
Computes the inverse cosine of each element in |
|
Alias for |
|
Returns a new tensor with the inverse hyperbolic cosine of the elements of |
|
Alias for |
|
Adds |
|
Performs the element-wise division of |
|
Performs the element-wise multiplication of |
|
Computes the element-wise angle (in radians) of the given |
|
Returns a new tensor with the arcsine of the elements of |
|
Alias for |
|
Returns a new tensor with the inverse hyperbolic sine of the elements of |
|
Alias for |
|
Returns a new tensor with the arctangent of the elements of |
|
Alias for |
|
Returns a new tensor with the inverse hyperbolic tangent of the elements of |
|
Alias for |
|
Element-wise arctangent of with consideration of the quadrant. |
|
Alias for |
|
Computes the bitwise NOT of the given input tensor. |
|
Computes the bitwise AND of |
|
Computes the bitwise OR of |
|
Computes the bitwise XOR of |
|
Computes the left arithmetic shift of |
|
Computes the right arithmetic shift of |
|
Returns a new tensor with the ceil of the elements of |
|
Clamps all elements in |
|
Alias for |
|
Computes the element-wise conjugate of the given |
|
Create a new floating-point tensor with the magnitude of |
|
Returns a new tensor with the cosine of the elements of |
|
Returns a new tensor with the hyperbolic cosine of the elements of |
|
Returns a new tensor with each of the elements of |
|
Divides each element of the input |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Alias for |
|
Returns a new tensor with the exponential of the elements of the input tensor |
|
Alias for |
|
Alias for |
|
Returns a new tensor with the data in |
|
Returns a new tensor with the data in |
|
Alias for |
|
Raises |
|
Returns a new tensor with the floor of the elements of |
|
Applies C++'s std::fmod entrywise. |
|
Computes the fractional portion of each element in |
|
Decomposes |
|
Estimates the gradient of a function in one or more dimensions using the second-order accurate central differences method and either first or second order estimates at the boundaries. |
|
Returns a new tensor containing imaginary values of the |
|
Multiplies |
|
Does a linear interpolation of two tensors |
|
Computes the natural logarithm of the absolute value of the gamma function on |
|
Returns a new tensor with the natural logarithm of the elements of |
|
Returns a new tensor with the logarithm to the base 10 of the elements of |
|
Returns a new tensor with the natural logarithm of (1 + |
|
Returns a new tensor with the logarithm to the base 2 of the elements of |
|
Logarithm of the sum of exponentiations of the inputs. |
|
Logarithm of the sum of exponentiations of the inputs in base-2. |
|
Computes the element-wise logical AND of the given input tensors. |
|
Computes the element-wise logical NOT of the given input tensor. |
|
Computes the element-wise logical OR of the given input tensors. |
|
Computes the element-wise logical XOR of the given input tensors. |
|
Alias for |
|
Given the legs of a right triangle, return its hypotenuse. |
|
Alias for |
|
Alias for |
|
Alias for |
|
Multiplies |
|
Alias for |
|
Alias for |
|
Replaces |
|
Returns a new tensor with the negative of the elements of |
|
Alias for |
|
Return the next floating-point value after |
|
Alias for |
|
Returns |
|
Takes the power of each element in |
|
Applies batch normalization on a 4D (NCHW) quantized tensor. |
|
Applies a 1D max pooling over an input quantized tensor composed of several input planes. |
|
Applies a 2D max pooling over an input quantized tensor composed of several input planes. |
|
Returns a new tensor with each of the elements of |
|
Returns a new tensor containing real values of the |
|
Returns a new tensor with the reciprocal of the elements of |
|
Computes Python's modulus operation entrywise. |
|
Rounds elements of |
|
Returns a new tensor with the reciprocal of the square-root of each of the elements of |
|
Alias for |
|
Returns a new tensor with the signs of the elements of |
|
This function is an extension of tensorplay.sign() to complex tensors. |
|
Tests if each element of |
|
Returns a new tensor with the sine of the elements of |
|
Alias for |
|
Returns a new tensor with the hyperbolic sine of the elements of |
|
Alias for |
|
Returns a new tensor with the square-root of the elements of |
|
Returns a new tensor with the square of the elements of |
|
Subtracts |
|
Alias for |
|
Returns a new tensor with the tangent of the elements of |
|
Returns a new tensor with the hyperbolic tangent of the elements of |
|
Alias for |
|
Returns a new tensor with the truncated integer values of the elements of |
|
Alias for |
|
Reduction Ops
Returns the indices of the maximum value of all elements in the |
|
Returns the indices of the minimum value(s) of the flattened tensor or along a dimension |
|
Returns the maximum value of each slice of the |
|
Returns the minimum value of each slice of the |
|
Tests if all elements in |
|
Tests if any element in |
|
Returns the maximum value of all elements in the |
|
Returns the minimum value of all elements in the |
|
Returns the p-norm of ( |
|
Returns the log of summed exponentials of each row of the |
|
Computes the mean of all non-NaN elements along the specified dimensions. |
|
Returns the sum of all elements, treating Not a Numbers (NaNs) as zero. |
|
Returns the product of all elements in the |
|
Computes the q-th quantiles of each row of the |
|
This is a variant of |
|
Calculates the standard deviation over the dimensions specified by |
|
Calculates the standard deviation and mean over the dimensions specified by |
|
Returns the sum of all elements in the |
|
Calculates the variance over the dimensions specified by |
|
Calculates the variance and mean over the dimensions specified by |
|
Counts the number of non-zero values in the tensor |
|
Returns a hash of all elements in the |
Comparison Ops
This function checks if |
|
Returns the indices that sort a tensor along a given dimension in ascending order by value. |
|
Computes element-wise equality |
|
|
|
Computes element-wise. |
|
Alias for |
|
Computes element-wise. |
|
Alias for |
|
Returns a new tensor with boolean elements representing if each element of |
|
Returns a new tensor with boolean elements representing if each element is finite or not. |
|
Tests if each element of |
|
Tests if each element of |
|
Tests if each element of |
|
Tests if each element of |
|
Returns a new tensor with boolean elements representing if each element of |
|
Returns a new tensor with boolean elements representing if each element of |
|
Computes element-wise. |
|
Alias for |
|
Computes element-wise. |
|
Alias for |
|
Computes the element-wise maximum of |
|
Computes the element-wise minimum of |
|
Computes the element-wise maximum of |
|
Computes the element-wise minimum of |
|
Computes element-wise. |
|
Alias for |
|
Sorts the elements of the |
Spectral Ops
Bartlett window function. |
|
Blackman window function. |
|
Hamming window function. |
|
Hann window function. |
|
Computes the Kaiser window with window length |
Other Operations
Count the frequency of each value in an array of non-negative ints. |
|
Builds a block diagonal matrix from the given blocks. |
|
Broadcasts the given tensors to a common shape. |
|
Broadcasts |
|
Returns the broadcast shape of the given shapes (right-aligned). |
|
Returns the indices of the buckets to which each value in the |
|
Returns a copy of |
|
Compute combinations of length of the given tensor. |
|
Estimates the Pearson product-moment correlation coefficient matrix of the variables given by the |
|
Estimates the covariance matrix of the variables given by the |
|
Returns the cross product of vectors in dimension |
|
Returns the cumulative product of elements of |
|
Returns the cumulative sum of elements of |
|
Creates a tensor whose diagonals of certain 2D planes (specified by |
|
Returns a partial view of |
|
Computes the n-th forward difference along the given dimension. |
|
Sums the product of the elements of the input |
|
|
|
|
|
Flattens |
|
Reverse the order of an n-D tensor along given axis in dims. |
|
Flip tensor in the left/right direction, returning a new tensor. |
|
Flip tensor in the up/down direction, returning a new tensor. |
|
Computes the element-wise greatest common divisor (GCD) of |
|
Computes the histogram of a tensor. |
|
Computes a histogram of the values in a tensor. |
|
Computes a multi-dimensional histogram of the values in a tensor. |
|
Computes the Kronecker product, denoted by , of |
|
Computes the element-wise least common multiple (LCM) of |
|
Returns the logarithm of the cumulative summation of the exponentiation of elements of |
|
Return a contiguous flattened tensor. |
|
Returns a tensor where each sub-tensor of |
|
Repeat elements of a tensor. |
|
Roll the tensor |
|
Rotate an n-D tensor by 90 degrees in the plane specified by dims axis. |
|
Find the indices from the innermost dimension of |
|
Contracts |
|
Returns the sum of the elements of the diagonal of the input 2-D matrix. |
|
Returns the lower triangular part of the matrix (2-D tensor) or batch of matrices |
|
Returns the indices of the lower triangular part of a |
|
Returns the upper triangular part of a matrix (2-D tensor) or batch of matrices |
|
Returns the indices of the upper triangular part of a |
|
Expands a dimension of the input tensor over multiple dimensions. |
|
Generates a Vandermonde matrix. |
|
Returns a view of |
|
Returns a view of |
|
Returns a new tensor with materialized conjugation if |
|
Returns a new tensor with materialized negation if |
BLAS and LAPACK Operations
Performs a batch matrix-matrix product of matrices stored in |
|
Performs a matrix multiplication of the matrices |
|
Performs a matrix-vector product of the matrix |
|
Performs the outer-product of vectors |
|
Performs a batch matrix-matrix product of matrices in |
|
Performs a batch matrix-matrix product of matrices stored in |
|
Computes the inverse of a complex Hermitian or real symmetric positive-definite matrix given its Cholesky decomposition. |
|
Computes the solution of a system of linear equations with complex Hermitian or real symmetric positive-definite lhs given its Cholesky decomposition. |
|
Computes the dot product of two 1D tensors. |
|
This is a low-level function for calling LAPACK's geqrf directly. |
|
Alias of |
|
Computes the dot product for 1D tensors. |
|
Alias for |
|
Alias for |
|
Calculates log determinant of a square matrix or batches of square matrices. |
|
Alias for |
|
Returns the LU solve of the linear system using the partially pivoted LU factorization of A from |
|
Unpacks the LU decomposition returned by |
|
Matrix product of two tensors. |
|
Alias for |
|
Alias for |
|
Performs a matrix multiplication of the matrices |
|
Performs a matrix-vector product of the matrix |
|
Alias for |
|
Computes the matrix-matrix multiplication of a product of Householder matrices with a general matrix. |
|
Outer product of |
|
Alias for |
|
Computes the singular value decomposition of either a matrix or batch of matrices |
|
Alias for |
|
Computes the trapezoidal rule along |
|
Cumulatively computes the trapezoidal rule along |
|
Solves a system of equations with a square upper or lower triangular invertible matrix and multiple right-hand sides . |
|
Computes the dot product of two 1D vectors along a dimension. |
Utilities
Return the dtype to be used for CPU autocasting. |
|
Return the dtype to be used for CUDA autocasting. |
|
Returns the |
|
described in the type promotion documentation. |
|
Returns the |
|
Sets whether TensorPlay operations must use "deterministic" algorithms. |
|
Returns True if the global deterministic flag is turned on. |
|
Returns True if the global deterministic flag is set to warn only. |
|
Sets the debug mode for deterministic operations. |
|
Returns the current value of the debug mode for deterministic operations. |
|
Sets the internal precision of float32 matrix multiplications. |
|
Returns the current value of float32 matrix multiplication precision. |
|
String representation of the type of an object. |
Symbolic Numbers
Optimizations
Compile a callable through the TensorPlay compiler frontend. |
TensorPlay-specific additions
Members: |
|
Members: |
|
Dispatch keys of the runtime, in dispatch-priority order: autocast keys outrank autograd keys, which outrank backend keys. |
|
An instance |
|
|
|
Quantization scheme attached to a quantized tensor's quantizer. |
|
Sequence of tensor dimension sizes (tuple subclass). |
|
Instances of |
|
Computes the Cholesky decomposition of a symmetric positive-definite matrix or for batches of symmetric positive-definite matrices. |
|
Create a helper decorator for backward methods of custom autograd functions. |
|
Create a helper decorator for |
|
Forks the RNG state: code inside the context gets a pristine RNG. |
|
Returns a detailed string describing parallelization settings |
|
Returns the current thread number (starting from 0) in the current parallel region, or 0 in the sequential region |
|
Performs a matrix multiplication of a sparse COO matrix |
|
Checks whether the code runs in a parallel region |
|
Return a bool indicating if autocast is available on |
|
Performs a matrix multiplication of the sparse matrix |
|
Constructs a sparse tensor in Compressed Sparse format - CSR, CSC, BSR, or BSC - with specified values at the given |
|
Matrix multiplies a sparse tensor |
|
Works like |
|
Works like |
|
Help improve this page
Found an error, an unclear step, or a missing example?
Tensor views
A view is a tensor that shares its underlying data with another tensor. Reshaping, selecting dimensions, or reversing a tensor are all cheap — instead of copying the elements, the view stores different metadata (shape, s
tensorplay._stax
tensorplay._stax is TensorPlay’s private compilation package. It owns capture orchestration, specialization guards, backend registration, code caching, and the native Stax and TVM lowering implementations.

