.. _dpctl.tensor_pyapi: ############ dpctl.tensor ############ .. currentmodule:: dpctl.tensor .. automodule:: dpctl.tensor .. _dpctl.tensor_classes: Classes ------- .. toctree:: :hidden: Device dtype usm_ndarray .. list-table:: :widths: 25,50 * - :class:`Device` - An object representing Data-API concept of device. * - :class:`dtype` - Create a data type object. * - :class:`usm_ndarray` - An array object represents a multidimensional tensor of numeric elements stored in a USM allocation on a SYCL device. .. _dpctl.tensor_array_construction: Array Construction ------------------ .. list-table:: :widths: 25,50 * - :func:`arange()` - Returns evenly spaced values within the half-open interval [start, stop) as a one-dimensional array. * - :func:`asarray()` - Converts `obj` to :class:`dpctl.tensor.usm_ndarray`. * - :func:`asnumpy()` - Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary` into :class:`numpy.ndarray` instance of the same shape and same data type. * - :func:`astype()` - Returns a copy of the :class:`dpctl.tensor.usm_ndarray`, cast to a specified type. * - :func:`copy()` - Creates a copy of given instance of :class:`dpctl.tensor.usm_ndarray`. * - :func:`empty()` - Creates :class:`dpctl.tensor.usm_ndarray` from uninitialized USM allocation. * - :func:`empty_like()` - Returns an uninitialized :class:`dpctl.tensor.usm_ndarray` with the same `shape` as the input array `x`. * - :func:`eye()` - Creates :class:`dpctl.tensor.usm_ndarray` with ones on the `k`-th diagonal. * - :func:`from_numpy()` - Creates :class:`dpctl.tensor.usm_ndarray` from instance of :class:`numpy.ndarray`. * - :func:`full()` - Returns a new :class:`dpctl.tensor.usm_ndarray` having a specified shape and filled with `fill_value`. * - :func:`full_like()` - Returns a new :class:`dpctl.tensor.usm_ndarray` filled with `fill_value` and having the same `shape` as the input array `x`. * - :func:`linspace()` - Returns :class:`dpctl.tensor.usm_ndarray` array populated with evenly spaced numbers of specified interval. * - :func:`meshgrid()` - Creates list of :class:`dpctl.tensor.usm_ndarray` coordinate matrices from vectors. * - :func:`ones()` - Returns a new :class:`dpctl.tensor.usm_ndarray` having a specified shape and filled with ones. * - :func:`ones_like()` - Returns a new :class:`dpctl.tensor.usm_ndarray` filled with ones and having the same `shape` as the input array `x`. * - :func:`to_numpy()` - Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary` into :class:`numpy.ndarray` instance of the same shape and same data type. * - :func:`tril()` - Returns the lower triangular part of a matrix (or a stack of matrices) `x`. * - :func:`triu()` - Returns the upper triangular part of a matrix (or a stack of matrices) `x`. * - :func:`zeros()` - Returns a new :class:`dpctl.tensor.usm_ndarray` having a specified shape and filled with zeros. * - :func:`zeros_like()` - Creates :class:`dpctl.tensor.usm_ndarray` from USM allocation initialized with zeros. .. _dpctl.tensor_array_manipulation: Array Manipulation ------------------ .. list-table:: :widths: 25,50 * - :func:`broadcast_arrays()` - Broadcasts one or more :class:`dpctl.tensor.usm_ndarrays` against one another. * - :func:`broadcast_to()` - Broadcast an array to a new `shape`; returns the broadcasted :class:`dpctl.tensor.usm_ndarray` as a view. * - :func:`can_cast()` - Determines if one data type can be cast to another data type according to Type Promotion Rules. * - :func:`concat()` - Joins a sequence of arrays along an existing axis. * - :func:`expand_dims()` - Expands the shape of an array by inserting a new axis (dimension) of size one at the position specified by axis. * - :func:`finfo()` - Returns machine limits for floating-point data types. * - :func:`flip()` - Reverses the order of elements in an array `x` along the given `axis`. * - :func:`iinfo()` - Returns machine limits for integer data types. * - :func:`moveaxis()` - Moves axes of an array to new positions. * - :func:`permute_dims()` - Permute the axes (dimensions) of an array; returns the permuted array as a view. * - :func:`repeat()` - Repeat elements of an array. * - :func:`reshape()` - Reshapes array `x` into new shape. * - :func:`result_type()` - Returns the dtype that results from applying the Type Promotion Rules to the arguments. * - :func:`roll()` - Rolls array elements along a specified axis. * - :func:`squeeze()` - Removes singleton dimensions (axes) from array `x`. * - :func:`stack()` - Joins a sequence of arrays along a new axis. * - :func:`swapaxes()` - Interchanges two axes of an array. * - :func:`tile()` - Repeat an input array `x` along each axis a number of times given by `repetitions`. * - :func:`unstack()` - Splits an array in a sequence of arrays along the given axis. .. _dpctl.tensor_other_functions: Other Functions --------------- .. list-table:: :widths: 25,50 * - :func:`all()` - Tests whether all input array elements evaluate to True along a given axis. * - :func:`allclose()` - Returns True if two arrays are element-wise equal within tolerances. * - :func:`any()` - Tests whether any input array elements evaluate to True along a given axis. * - :func:`argmax()` - Returns the indices of the maximum values of the input array `x` along a specified axis. * - :func:`argmin()` - Returns the indices of the minimum values of the input array `x` along a specified axis. * - :func:`clip()` - Clips to the range [`min_i`, `max_i`] for each element `x_i` in `x`. * - :func:`extract()` - Returns the elements of an array that satisfies the condition. * - :func:`get_print_options()` - Returns a copy of current options for printing :class:`dpctl.tensor.usm_ndarray` class. * - :func:`isdtype()` - Returns a boolean indicating whether a provided `dtype` is of a specified data type `kind`. * - :func:`logsumexp()` - Calculates the logarithm of the sum of exponentials of elements in the input array `x`. * - :func:`matrix_transpose()` - Transposes the innermost two dimensions of `x`, where `x` is a 2-dimensional matrix or a stack of 2-dimensional matrices. * - :func:`max()` - Calculates the maximum value of the input array `x`. * - :func:`min()` - Calculates the minimum value of the input array `x`. * - :func:`nonzero()` - Return the indices of non-zero elements. * - :func:`place()` - Change elements of an array based on conditional and input values. * - :func:`print_options()` - Context manager for print options. * - :func:`prod()` - Calculates the product of elements in the input array `x`. * - :func:`put()` - Puts values of an array into another array along a given axis. * - :func:`reduce_hypot()` - Calculates the square root of the sum of squares of elements in the input array `x`. * - :func:`set_print_options()` - Set options for printing :class:`dpctl.tensor.usm_ndarray` class. * - :func:`sum()` - Calculates the sum of elements in the input array `x`. * - :func:`take()` - Takes elements from array along a given axis. * - :func:`usm_ndarray_repr()` - Returns a formatted string representing the elements of a :class:`dpctl.tensor.usm_ndarray` and its data type, if not a default type. * - :func:`usm_ndarray_str()` - Returns a string representing the elements of a :class:`dpctl.tensor.usm_ndarray`. * - :func:`where()` - Returns :class:`dpctl.tensor.usm_ndarray` with elements chosen from `x1` or `x2` depending on `condition`.