# tensorplay API Source: https://www.tensorplay.cn/docs/api/index.html ## Functions 543 [#](#api-tensorplay.as_tensor) ### as_tensor function[Full reference ↗](/docs/generated/tensorplay.as_tensor.html) ```python tensorplay.as_tensor(data: Any, dtype: Optional[dtype] = None, device: Optional[DeviceLikeType]) → Tensor ``` Converts [data](/docs/generated/tensorplay.data.html#tensorplay.data) into a tensor, sharing data and preserving autograd history if possible. If [data](/docs/generated/tensorplay.data.html#tensorplay.data) is already a tensor with the requested dtype and device then [data](/docs/generated/tensorplay.data.html#tensorplay.data) itself is returned, but if [data](/docs/generated/tensorplay.data.html#tensorplay.data) is a tensor with a different dtype or device then it’s copied as if using data.to(dtype=dtype, device=device). If [data](/docs/generated/tensorplay.data.html#tensorplay.data) is a NumPy array (an ndarray) with the same dtype and device then a tensor is constructed using [tensorplay.from_numpy()](/docs/generated/tensorplay.from_numpy.html#tensorplay.from_numpy). If [data](/docs/generated/tensorplay.data.html#tensorplay.data) is a CuPy array, the returned tensor will be located on the same device as the CuPy array unless specifically overwritten by [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) or a default device. The device of the CuPy array is inferred from the pointer of the array using cudaPointerGetAttributes unless [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) is provided with an explicit device index. > **See also** > > tensorplay.tensor() never shares its data and creates a new “leaf tensor” (see Autograd mechanics). Parameters: - data (array_like) – Initial data for the tensor. Can be a list, tuple, NumPy ndarray, scalar, and other types. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, infers data type from [data](/docs/generated/tensorplay.data.html#tensorplay.data). - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the device of the constructed tensor. If None and data is a tensor then the device of data is used. If None and data is not a tensor then the result tensor is constructed on the current device. Example: ``` >>> a = numpy.array([1, 2, 3]) >>> t = tensorplay.as_tensor(a) >>> t tensor([ 1, 2, 3]) >>> t[0] = -1 >>> a array([-1, 2, 3]) >>> a = numpy.array([1, 2, 3]) >>> t = tensorplay.as_tensor(a, device=tensorplay.device('cuda')) >>> t tensor([ 1, 2, 3]) >>> t[0] = -1 >>> a array([1, 2, 3]) ``` [#](#api-tensorplay.absolute_) ### absolute_ function[Full reference ↗](/docs/generated/tensorplay.absolute_.html) ```python tensorplay.absolute_(input) ``` [#](#api-tensorplay.adaptive_avg_pool2d) ### adaptive_avg_pool2d function[Full reference ↗](/docs/generated/tensorplay.adaptive_avg_pool2d.html) ```python tensorplay.adaptive_avg_pool2d(input, output_size, *, out=None) ``` [#](#api-tensorplay.adaptive_avg_pool3d) ### adaptive_avg_pool3d function[Full reference ↗](/docs/generated/tensorplay.adaptive_avg_pool3d.html) ```python tensorplay.adaptive_avg_pool3d(input, output_size, *, out=None) ``` [#](#api-tensorplay.adaptive_max_pool2d_with_indices) ### adaptive_max_pool2d_with_indices function[Full reference ↗](/docs/generated/tensorplay.adaptive_max_pool2d_with_indices.html) ```python tensorplay.adaptive_max_pool2d_with_indices(input, output_size) ``` [#](#api-tensorplay.adaptive_max_pool2d) ### adaptive_max_pool2d function[Full reference ↗](/docs/generated/tensorplay.adaptive_max_pool2d.html) ```python tensorplay.adaptive_max_pool2d(input, output_size, *, out=None) ``` [#](#api-tensorplay.adaptive_max_pool3d) ### adaptive_max_pool3d function[Full reference ↗](/docs/generated/tensorplay.adaptive_max_pool3d.html) ```python tensorplay.adaptive_max_pool3d(input, output_size, *, out=None) ``` [#](#api-tensorplay.add_) ### add_ function[Full reference ↗](/docs/generated/tensorplay.add_.html) ```python tensorplay.add_(input, other, alpha=1) ``` [#](#api-tensorplay.add_relu) ### add_relu function[Full reference ↗](/docs/generated/tensorplay.add_relu.html) ```python tensorplay.add_relu(input, other) ``` [#](#api-tensorplay.addbmm_) ### addbmm_ function[Full reference ↗](/docs/generated/tensorplay.addbmm_.html) ```python tensorplay.addbmm_(input, batch1, batch2, beta=1, alpha=1) ``` [#](#api-tensorplay.addcdiv_) ### addcdiv_ function[Full reference ↗](/docs/generated/tensorplay.addcdiv_.html) ```python tensorplay.addcdiv_(input, tensor1, tensor2, value=1) ``` [#](#api-tensorplay.addcmul_) ### addcmul_ function[Full reference ↗](/docs/generated/tensorplay.addcmul_.html) ```python tensorplay.addcmul_(input, tensor1, tensor2, value=1) ``` [#](#api-tensorplay.addmm_) ### addmm_ function[Full reference ↗](/docs/generated/tensorplay.addmm_.html) ```python tensorplay.addmm_(input, mat1, mat2, beta=1, alpha=1) ``` [#](#api-tensorplay.addr_) ### addr_ function[Full reference ↗](/docs/generated/tensorplay.addr_.html) ```python tensorplay.addr_(input, vec1, vec2, beta=1, alpha=1) ``` [#](#api-tensorplay.airy_ai) ### airy_ai function[Full reference ↗](/docs/generated/tensorplay.airy_ai.html) ```python tensorplay.airy_ai(input) ``` [#](#api-tensorplay.alias) ### alias function[Full reference ↗](/docs/generated/tensorplay.alias.html) ```python tensorplay.alias(input) ``` [#](#api-tensorplay.arctan2_) ### arctan2_ function[Full reference ↗](/docs/generated/tensorplay.arctan2_.html) ```python tensorplay.arctan2_(input, other) ``` [#](#api-tensorplay.are_deterministic_algorithms_enabled) ### are_deterministic_algorithms_enabled function[Full reference ↗](/docs/generated/tensorplay.are_deterministic_algorithms_enabled.html) ```python tensorplay.are_deterministic_algorithms_enabled() → bool ``` Returns True if the global deterministic flag is turned on. Refer to [tensorplay.use_deterministic_algorithms()](/docs/generated/tensorplay.use_deterministic_algorithms.html#tensorplay.use_deterministic_algorithms) documentation for more details. [#](#api-tensorplay.asarray) ### asarray function[Full reference ↗](/docs/generated/tensorplay.asarray.html) ```python tensorplay.asarray(obj: Any, *, dtype: dtype | None, device: DeviceLikeType | None, copy: bool | None = None, requires_grad: bool = False) → Tensor ``` Converts obj to a tensor. obj can be one of: - a tensor - a NumPy array or a NumPy scalar - a DLPack capsule - an object that implements Python’s buffer protocol - a scalar - a sequence of scalars When obj is a tensor, NumPy array, or DLPack capsule the returned tensor will, by default, not require a gradient, have the same datatype as obj, be on the same device, and share memory with it. These properties can be controlled with the [dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), [device](/docs/generated/tensorplay.Device.html#tensorplay.Device), [copy](/docs/generated/tensorplay.copy.html#tensorplay.copy), and requires_grad keyword arguments. If the returned tensor is of a different datatype, on a different device, or a copy is requested then it will not share its memory with obj. If requires_grad is True then the returned tensor will require a gradient, and if obj is also a tensor with an autograd history then the returned tensor will have the same history. When obj is not a tensor, NumPy array, or DLPack capsule but implements Python’s buffer protocol then the buffer is interpreted as an array of bytes grouped according to the size of the datatype passed to the [dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType) keyword argument. (If no datatype is passed then the default floating point datatype is used, instead.) The returned tensor will have the specified datatype (or default floating point datatype if none is specified) and, by default, be on the CPU device and share memory with the buffer. When obj is a NumPy scalar, the returned tensor will be a 0-dimensional tensor on the CPU and that doesn’t share its memory (i.e. copy=True). By default datatype will When obj is none of the above but a scalar, or a sequence of scalars then the returned tensor will, by default, infer its datatype from the scalar values, be on the current default device, and not share its memory. > **See also** > > tensorplay.tensor() creates a tensor that always copies the data from the input object. tensorplay.from_numpy() creates a tensor that always shares memory from NumPy arrays. tensorplay.frombuffer() creates a tensor that always shares memory from objects that implement the buffer protocol. tensorplay.from_dlpack() creates a tensor that always shares memory from DLPack capsules. Parameters: obj ([object](https://docs.python.org/3/builtins/functions.html#object)) – a tensor, NumPy array, DLPack Capsule, object that implements Python’s buffer protocol, scalar, or sequence of scalars. Keyword Arguments: - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the datatype of the returned tensor. Default: None, which causes the datatype of the returned tensor to be inferred from obj. - copy ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – controls whether the returned tensor shares memory with obj. Default: None, which causes the returned tensor to share memory with obj whenever possible. If True then the returned tensor does not share its memory. If False then the returned tensor shares its memory with obj and an error is thrown if it cannot. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the device of the returned tensor. Default: None, which causes the device of obj to be used. Or, if obj is a Python sequence, the current default device will be used. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – whether the returned tensor requires grad. Default: False, which causes the returned tensor not to require a gradient. If True, then the returned tensor will require a gradient, and if obj is also a tensor with an autograd history then the returned tensor will have the same history. Example: ``` >>> a = tensorplay.tensor([1, 2, 3]) >>> # Shares memory with tensor 'a' >>> b = tensorplay.asarray(a) >>> a.data_ptr() == b.data_ptr() True >>> # Forces memory copy >>> c = tensorplay.asarray(a, copy=True) >>> a.data_ptr() == c.data_ptr() False >>> a = tensorplay.tensor([1., 2., 3.], requires_grad=True) >>> b = a + 2 >>> b tensor([3., 4., 5.], grad_fn=) >>> # Shares memory with tensor 'b', with no grad >>> c = tensorplay.asarray(b) >>> c tensor([3., 4., 5.]) >>> # Shares memory with tensor 'b', retaining autograd history >>> d = tensorplay.asarray(b, requires_grad=True) >>> d tensor([3., 4., 5.], grad_fn=) >>> array = numpy.array([1, 2, 3]) >>> # Shares memory with array 'array' >>> t1 = tensorplay.asarray(array) >>> array.__array_interface__['data'][0] == t1.data_ptr() True >>> # Copies memory due to dtype mismatch >>> t2 = tensorplay.asarray(array, dtype=tensorplay.float32) >>> array.__array_interface__['data'][0] == t2.data_ptr() False >>> scalar = numpy.float64(0.5) >>> tensorplay.asarray(scalar) tensor(0.5000, dtype=tensorplay.float64) ``` [#](#api-tensorplay.atan2_) ### atan2_ function[Full reference ↗](/docs/generated/tensorplay.atan2_.html) ```python tensorplay.atan2_(input, other) ``` [#](#api-tensorplay.autocast_decrement_nesting) ### autocast_decrement_nesting function[Full reference ↗](/docs/generated/tensorplay.autocast_decrement_nesting.html) ```python tensorplay.autocast_decrement_nesting() → int ``` [#](#api-tensorplay.autocast_increment_nesting) ### autocast_increment_nesting function[Full reference ↗](/docs/generated/tensorplay.autocast_increment_nesting.html) ```python tensorplay.autocast_increment_nesting() → int ``` [#](#api-tensorplay.avg_pool2d) ### avg_pool2d function[Full reference ↗](/docs/generated/tensorplay.avg_pool2d.html) ```python tensorplay.avg_pool2d(input, kernel_size, stride=[], padding=[], ceil_mode=False, count_include_pad=True, divisor_override=None, *, out=None) ``` [#](#api-tensorplay.avg_pool3d) ### avg_pool3d function[Full reference ↗](/docs/generated/tensorplay.avg_pool3d.html) ```python tensorplay.avg_pool3d(input, kernel_size, stride=[], padding=[], ceil_mode=False, count_include_pad=True, divisor_override=None, *, out=None) ``` [#](#api-tensorplay.baddbmm_) ### baddbmm_ function[Full reference ↗](/docs/generated/tensorplay.baddbmm_.html) ```python tensorplay.baddbmm_(input, batch1, batch2, beta=1, alpha=1) ``` [#](#api-tensorplay.batch_norm) ### batch_norm function[Full reference ↗](/docs/generated/tensorplay.batch_norm.html) ```python tensorplay.batch_norm(input, weight, bias, running_mean, running_var, training, momentum, eps) ``` [#](#api-tensorplay.bernoulli_) ### bernoulli_ function[Full reference ↗](/docs/generated/tensorplay.bernoulli_.html) ```python tensorplay.bernoulli_(input, p, generator=None) ``` [#](#api-tensorplay.bessel_j0) ### bessel_j0 function[Full reference ↗](/docs/generated/tensorplay.bessel_j0.html) ```python tensorplay.bessel_j0(input) ``` [#](#api-tensorplay.bessel_j1) ### bessel_j1 function[Full reference ↗](/docs/generated/tensorplay.bessel_j1.html) ```python tensorplay.bessel_j1(input) ``` [#](#api-tensorplay.bessel_y0) ### bessel_y0 function[Full reference ↗](/docs/generated/tensorplay.bessel_y0.html) ```python tensorplay.bessel_y0(input) ``` [#](#api-tensorplay.bessel_y1) ### bessel_y1 function[Full reference ↗](/docs/generated/tensorplay.bessel_y1.html) ```python tensorplay.bessel_y1(input) ``` [#](#api-tensorplay.binary_cross_entropy_with_logits) ### binary_cross_entropy_with_logits function[Full reference ↗](/docs/generated/tensorplay.binary_cross_entropy_with_logits.html) ```python tensorplay.binary_cross_entropy_with_logits(input, target, weight=None, pos_weight=None) ``` [#](#api-tensorplay.binary_cross_entropy) ### binary_cross_entropy function[Full reference ↗](/docs/generated/tensorplay.binary_cross_entropy.html) ```python tensorplay.binary_cross_entropy(input, target, weight=None, reduction=1, *, out=None) ``` [#](#api-tensorplay.bitwise_and_) ### bitwise_and_ function[Full reference ↗](/docs/generated/tensorplay.bitwise_and_.html) ```python tensorplay.bitwise_and_(input, other) ``` [#](#api-tensorplay.bitwise_left_shift_) ### bitwise_left_shift_ function[Full reference ↗](/docs/generated/tensorplay.bitwise_left_shift_.html) ```python tensorplay.bitwise_left_shift_(input, other) ``` [#](#api-tensorplay.bitwise_not_) ### bitwise_not_ function[Full reference ↗](/docs/generated/tensorplay.bitwise_not_.html) ```python tensorplay.bitwise_not_(input) ``` [#](#api-tensorplay.bitwise_or_) ### bitwise_or_ function[Full reference ↗](/docs/generated/tensorplay.bitwise_or_.html) ```python tensorplay.bitwise_or_(input, other) ``` [#](#api-tensorplay.bitwise_right_shift_) ### bitwise_right_shift_ function[Full reference ↗](/docs/generated/tensorplay.bitwise_right_shift_.html) ```python tensorplay.bitwise_right_shift_(input, other) ``` [#](#api-tensorplay.bitwise_xor_) ### bitwise_xor_ function[Full reference ↗](/docs/generated/tensorplay.bitwise_xor_.html) ```python tensorplay.bitwise_xor_(input, other) ``` [#](#api-tensorplay.cauchy_) ### cauchy_ function[Full reference ↗](/docs/generated/tensorplay.cauchy_.html) ```python tensorplay.cauchy_(input, median=0.0, sigma=1.0, generator=None) ``` [#](#api-tensorplay.ccol_indices) ### ccol_indices function[Full reference ↗](/docs/generated/tensorplay.ccol_indices.html) ```python tensorplay.ccol_indices(input) ``` [#](#api-tensorplay.celu) ### celu function[Full reference ↗](/docs/generated/tensorplay.celu.html) ```python tensorplay.celu(input, alpha=1.0) ``` [#](#api-tensorplay.chebyshev_polynomial_t) ### chebyshev_polynomial_t function[Full reference ↗](/docs/generated/tensorplay.chebyshev_polynomial_t.html) ```python tensorplay.chebyshev_polynomial_t(x, n) ``` [#](#api-tensorplay.chebyshev_polynomial_u) ### chebyshev_polynomial_u function[Full reference ↗](/docs/generated/tensorplay.chebyshev_polynomial_u.html) ```python tensorplay.chebyshev_polynomial_u(x, n) ``` [#](#api-tensorplay.chebyshev_polynomial_v) ### chebyshev_polynomial_v function[Full reference ↗](/docs/generated/tensorplay.chebyshev_polynomial_v.html) ```python tensorplay.chebyshev_polynomial_v(x, n) ``` [#](#api-tensorplay.chebyshev_polynomial_w) ### chebyshev_polynomial_w function[Full reference ↗](/docs/generated/tensorplay.chebyshev_polynomial_w.html) ```python tensorplay.chebyshev_polynomial_w(x, n) ``` [#](#api-tensorplay.cholesky) ### cholesky function[Full reference ↗](/docs/generated/tensorplay.cholesky.html) ```python tensorplay.cholesky(input, upper=False, *, out=None) → Tensor ``` Computes the Cholesky decomposition of a symmetric positive-definite matrix $A$ or for batches of symmetric positive-definite matrices. If upper is True, the returned matrix U is upper-triangular, and the decomposition has the form: $$A = U^TU$$ If upper is False, the returned matrix L is lower-triangular, and the decomposition has the form: $$A = LL^T$$ If upper is True, and $A$ is a batch of symmetric positive-definite matrices, then the returned tensor will be composed of upper-triangular Cholesky factors of each of the individual matrices. Similarly, when upper is False, the returned tensor will be composed of lower-triangular Cholesky factors of each of the individual matrices. > **Warning** > > tensorplay.cholesky() is deprecated in favor of tensorplay.linalg.cholesky() L = tensorplay.cholesky(A) should be replaced with @@TPBLOCK_2@@ U = tensorplay.cholesky(A, upper=True) should be replaced with ``` U = tensorplay.linalg.cholesky(A).mH ``` This transform will produce equivalent results for all valid (symmetric positive definite) inputs. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor $A$ of size $(*, n, n)$ where * is zero or more batch dimensions consisting of symmetric positive-definite matrices. - upper ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – flag that indicates whether to return a upper or lower triangular matrix. Default: False Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output matrix Example: ``` >>> a = tensorplay.randn(3, 3) >>> a = a @ a.mT + 1e-3 # make symmetric positive-definite >>> l = tensorplay.cholesky(a) >>> a tensor([[ 2.4112, -0.7486, 1.4551], [-0.7486, 1.3544, 0.1294], [ 1.4551, 0.1294, 1.6724]]) >>> l tensor([[ 1.5528, 0.0000, 0.0000], [-0.4821, 1.0592, 0.0000], [ 0.9371, 0.5487, 0.7023]]) >>> l @ l.mT tensor([[ 2.4112, -0.7486, 1.4551], [-0.7486, 1.3544, 0.1294], [ 1.4551, 0.1294, 1.6724]]) >>> a = tensorplay.randn(3, 2, 2) # Example for batched input >>> a = a @ a.mT + 1e-03 # make symmetric positive-definite >>> l = tensorplay.cholesky(a) >>> z = l @ l.mT >>> tensorplay.dist(z, a) tensor(2.3842e-07) ``` [#](#api-tensorplay.circular_pad_nd) ### circular_pad_nd function[Full reference ↗](/docs/generated/tensorplay.circular_pad_nd.html) ```python tensorplay.circular_pad_nd(input, pad) ``` [#](#api-tensorplay.clamp_max) ### clamp_max function[Full reference ↗](/docs/generated/tensorplay.clamp_max.html) ```python tensorplay.clamp_max(input, max) ``` [#](#api-tensorplay.clamp_min) ### clamp_min function[Full reference ↗](/docs/generated/tensorplay.clamp_min.html) ```python tensorplay.clamp_min(input, min) ``` [#](#api-tensorplay.clear_autocast_cache) ### clear_autocast_cache function[Full reference ↗](/docs/generated/tensorplay.clear_autocast_cache.html) ```python tensorplay.clear_autocast_cache() → None ``` [#](#api-tensorplay.coalesce) ### coalesce function[Full reference ↗](/docs/generated/tensorplay.coalesce.html) ```python tensorplay.coalesce(input) ``` [#](#api-tensorplay.col_indices) ### col_indices function[Full reference ↗](/docs/generated/tensorplay.col_indices.html) ```python tensorplay.col_indices(input) ``` [#](#api-tensorplay.col2im) ### col2im function[Full reference ↗](/docs/generated/tensorplay.col2im.html) ```python tensorplay.col2im(input, output_size, kernel_size, dilation=[], padding=[], stride=[], *, out=None) ``` [#](#api-tensorplay.constant_pad_nd) ### constant_pad_nd function[Full reference ↗](/docs/generated/tensorplay.constant_pad_nd.html) ```python tensorplay.constant_pad_nd(input, pad, value) ``` [#](#api-tensorplay.contiguous) ### contiguous function[Full reference ↗](/docs/generated/tensorplay.contiguous.html) ```python tensorplay.contiguous(input, memory_format=tensorplay.contiguous_format) ``` [#](#api-tensorplay.conv_depthwise3d) ### conv_depthwise3d function[Full reference ↗](/docs/generated/tensorplay.conv_depthwise3d.html) ```python tensorplay.conv_depthwise3d(input, weight, kernel_size, bias, stride, padding, dilation) ``` [#](#api-tensorplay.conv_transpose1d_grad_bias) ### conv_transpose1d_grad_bias function[Full reference ↗](/docs/generated/tensorplay.conv_transpose1d_grad_bias.html) ```python tensorplay.conv_transpose1d_grad_bias(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose1d_grad_input) ### conv_transpose1d_grad_input function[Full reference ↗](/docs/generated/tensorplay.conv_transpose1d_grad_input.html) ```python tensorplay.conv_transpose1d_grad_input(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose1d_grad_weight) ### conv_transpose1d_grad_weight function[Full reference ↗](/docs/generated/tensorplay.conv_transpose1d_grad_weight.html) ```python tensorplay.conv_transpose1d_grad_weight(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose2d_grad_bias) ### conv_transpose2d_grad_bias function[Full reference ↗](/docs/generated/tensorplay.conv_transpose2d_grad_bias.html) ```python tensorplay.conv_transpose2d_grad_bias(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose2d_grad_input) ### conv_transpose2d_grad_input function[Full reference ↗](/docs/generated/tensorplay.conv_transpose2d_grad_input.html) ```python tensorplay.conv_transpose2d_grad_input(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose2d_grad_weight) ### conv_transpose2d_grad_weight function[Full reference ↗](/docs/generated/tensorplay.conv_transpose2d_grad_weight.html) ```python tensorplay.conv_transpose2d_grad_weight(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose3d_grad_bias) ### conv_transpose3d_grad_bias function[Full reference ↗](/docs/generated/tensorplay.conv_transpose3d_grad_bias.html) ```python tensorplay.conv_transpose3d_grad_bias(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose3d_grad_input) ### conv_transpose3d_grad_input function[Full reference ↗](/docs/generated/tensorplay.conv_transpose3d_grad_input.html) ```python tensorplay.conv_transpose3d_grad_input(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv_transpose3d_grad_weight) ### conv_transpose3d_grad_weight function[Full reference ↗](/docs/generated/tensorplay.conv_transpose3d_grad_weight.html) ```python tensorplay.conv_transpose3d_grad_weight(grad_output, input, weight, stride, padding, output_padding, groups, dilation) ``` [#](#api-tensorplay.conv1d_grad_bias) ### conv1d_grad_bias function[Full reference ↗](/docs/generated/tensorplay.conv1d_grad_bias.html) ```python tensorplay.conv1d_grad_bias(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv1d_grad_input) ### conv1d_grad_input function[Full reference ↗](/docs/generated/tensorplay.conv1d_grad_input.html) ```python tensorplay.conv1d_grad_input(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv1d_grad_weight) ### conv1d_grad_weight function[Full reference ↗](/docs/generated/tensorplay.conv1d_grad_weight.html) ```python tensorplay.conv1d_grad_weight(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv2d_grad_bias) ### conv2d_grad_bias function[Full reference ↗](/docs/generated/tensorplay.conv2d_grad_bias.html) ```python tensorplay.conv2d_grad_bias(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv2d_grad_input) ### conv2d_grad_input function[Full reference ↗](/docs/generated/tensorplay.conv2d_grad_input.html) ```python tensorplay.conv2d_grad_input(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv2d_grad_weight) ### conv2d_grad_weight function[Full reference ↗](/docs/generated/tensorplay.conv2d_grad_weight.html) ```python tensorplay.conv2d_grad_weight(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv2d_relu) ### conv2d_relu function[Full reference ↗](/docs/generated/tensorplay.conv2d_relu.html) ```python tensorplay.conv2d_relu(input, weight, bias=None, stride=[1, 1], padding=[0, 0], dilation=[1, 1], groups=1) ``` [#](#api-tensorplay.conv2d) ### conv2d function[Full reference ↗](/docs/generated/tensorplay.conv2d.html) ```python tensorplay.conv2d(input, weight, bias=None, stride=[1, 1], padding=[0, 0], dilation=[1, 1], groups=1) ``` [#](#api-tensorplay.conv3d_grad_bias) ### conv3d_grad_bias function[Full reference ↗](/docs/generated/tensorplay.conv3d_grad_bias.html) ```python tensorplay.conv3d_grad_bias(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv3d_grad_input) ### conv3d_grad_input function[Full reference ↗](/docs/generated/tensorplay.conv3d_grad_input.html) ```python tensorplay.conv3d_grad_input(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.conv3d_grad_weight) ### conv3d_grad_weight function[Full reference ↗](/docs/generated/tensorplay.conv3d_grad_weight.html) ```python tensorplay.conv3d_grad_weight(grad_output, input, weight, stride, padding, dilation, groups) ``` [#](#api-tensorplay.convolution_backward_overrideable) ### convolution_backward_overrideable function[Full reference ↗](/docs/generated/tensorplay.convolution_backward_overrideable.html) ```python tensorplay.convolution_backward_overrideable(grad_output, input, weight, stride, padding, dilation, transposed, output_padding, groups, output_mask) ``` [#](#api-tensorplay.convolution_overrideable) ### convolution_overrideable function[Full reference ↗](/docs/generated/tensorplay.convolution_overrideable.html) ```python tensorplay.convolution_overrideable(input, weight, bias, stride, padding, dilation, transposed, output_padding, groups) ``` [#](#api-tensorplay.copy_) ### copy_ function[Full reference ↗](/docs/generated/tensorplay.copy_.html) ```python tensorplay.copy_(input, src, non_blocking=False) ``` [#](#api-tensorplay.copy_sparse_to_sparse_) ### copy_sparse_to_sparse_ function[Full reference ↗](/docs/generated/tensorplay.copy_sparse_to_sparse_.html) ```python tensorplay.copy_sparse_to_sparse_(input, src, non_blocking=False) ``` [#](#api-tensorplay.copy) ### copy function[Full reference ↗](/docs/generated/tensorplay.copy.html) ```python tensorplay.copy(input, src, non_blocking=False) ``` [#](#api-tensorplay.copysign_) ### copysign_ function[Full reference ↗](/docs/generated/tensorplay.copysign_.html) ```python tensorplay.copysign_(input, other) ``` [#](#api-tensorplay.cross_entropy_loss) ### cross_entropy_loss function[Full reference ↗](/docs/generated/tensorplay.cross_entropy_loss.html) ```python tensorplay.cross_entropy_loss(input, target, weight=None, reduction=1, ignore_index=-100, label_smoothing=0.0) ``` [#](#api-tensorplay.crow_indices) ### crow_indices function[Full reference ↗](/docs/generated/tensorplay.crow_indices.html) ```python tensorplay.crow_indices(input) ``` [#](#api-tensorplay.cumprod_) ### cumprod_ function[Full reference ↗](/docs/generated/tensorplay.cumprod_.html) ```python tensorplay.cumprod_(input, dim, dtype=None) ``` [#](#api-tensorplay.cumsum_) ### cumsum_ function[Full reference ↗](/docs/generated/tensorplay.cumsum_.html) ```python tensorplay.cumsum_(input, dim=0, dtype=None) ``` [#](#api-tensorplay.custom_bwd) ### custom_bwd function[Full reference ↗](/docs/generated/tensorplay.custom_bwd.html) ```python tensorplay.custom_bwd(bwd=None, *, device_type: str) ``` Create a helper decorator for backward methods of custom autograd functions. Autograd functions are subclasses of tensorplay.autograd.Function. Ensures that backward executes with the same autocast state as forward. Parameters: device_type ([str](https://docs.python.org/3/builtins/stdtypes.html#str)) – Device type to use. ‘cuda’, ‘cpu’. The type is the same as the type attribute of a [tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device). Thus, you may obtain the device type of a tensor using Tensor.device.type. [#](#api-tensorplay.custom_fwd) ### custom_fwd function[Full reference ↗](/docs/generated/tensorplay.custom_fwd.html) ```python tensorplay.custom_fwd(fwd=None, *, device_type: str, cast_inputs=None) ``` Create a helper decorator for forward methods of custom autograd functions. Autograd functions are subclasses of tensorplay.autograd.Function. Parameters: - device_type ([str](https://docs.python.org/3/builtins/stdtypes.html#str)) – Device type to use. ‘cuda’, ‘cpu’. The type is the same as the type attribute of a [tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device). Thus, you may obtain the device type of a tensor using Tensor.device.type. - cast_inputs ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType) or None, optional, default=None) – If not None, when forward runs in an autocast-enabled region, casts incoming floating-point Tensors to the target dtype (non-floating-point Tensors are not affected), then executes forward with autocast disabled. If None, forward’s internal ops execute with the current autocast state. > **Note** > > If the decorated forward is called outside an autocast-enabled region, custom_fwd is a no-op and cast_inputs has no effect. [#](#api-tensorplay.data) ### data function[Full reference ↗](/docs/generated/tensorplay.data.html) ```python tensorplay.data(input) ``` [#](#api-tensorplay.dense_dim) ### dense_dim function[Full reference ↗](/docs/generated/tensorplay.dense_dim.html) ```python tensorplay.dense_dim(input) ``` [#](#api-tensorplay.digamma_) ### digamma_ function[Full reference ↗](/docs/generated/tensorplay.digamma_.html) ```python tensorplay.digamma_(input) ``` [#](#api-tensorplay.dim) ### dim function[Full reference ↗](/docs/generated/tensorplay.dim.html) ```python tensorplay.dim(input) ``` [#](#api-tensorplay.div_) ### div_ function[Full reference ↗](/docs/generated/tensorplay.div_.html) ```python tensorplay.div_(input, other, rounding_mode=None) ``` [#](#api-tensorplay.divide_) ### divide_ function[Full reference ↗](/docs/generated/tensorplay.divide_.html) ```python tensorplay.divide_(input, other, rounding_mode=None) ``` [#](#api-tensorplay.dropout) ### dropout function[Full reference ↗](/docs/generated/tensorplay.dropout.html) ```python tensorplay.dropout(input, p=0.5, train=True) ``` [#](#api-tensorplay.elu_) ### elu_ function[Full reference ↗](/docs/generated/tensorplay.elu_.html) ```python tensorplay.elu_(input, alpha=1, scale=1, input_scale=1) ``` [#](#api-tensorplay.elu) ### elu function[Full reference ↗](/docs/generated/tensorplay.elu.html) ```python tensorplay.elu(input, alpha=1, scale=1, input_scale=1, *, out=None) ``` [#](#api-tensorplay.embedding_bag) ### embedding_bag function[Full reference ↗](/docs/generated/tensorplay.embedding_bag.html) ```python tensorplay.embedding_bag(input, indices=None, offsets=None, scale_grad_by_freq=False, mode=0, sparse=False, per_sample_weights=None, include_last_offset=False, padding_idx=None) ``` [#](#api-tensorplay.empty) ### empty function[Full reference ↗](/docs/generated/tensorplay.empty.html) ```python tensorplay.empty() ``` empty(*size, *, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False, pin_memory=False, memory_format=tensorplay.contiguous_format) -> Tensor Returns a tensor filled with uninitialized data. The shape of the tensor is defined by the variable argument [size](/docs/generated/tensorplay.size.html#tensorplay.size). > **Note** > > The returned storage is uninitialized, and tensorplay.use_deterministic_algorithms() does not change that. If the contents matter, allocate with tensorplay.zeros() or fill the tensor before reading it, otherwise the output becomes a source of nondeterminism. Floating point and complex tensors are filled with NaN, and integer tensors are filled with the maximum value. Parameters: size ([int](https://docs.python.org/3/builtins/functions.html#int)...) – a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple. Keyword Arguments: - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, uses a global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout (tensorplay.layout, optional) – the desired layout of returned Tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. - pin_memory ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False. - memory_format ([tensorplay.memory_format](/docs/generated/tensorplay.MemoryFormat.html#tensorplay.MemoryFormat), optional) – the desired memory format of returned Tensor. Default: tensorplay.contiguous_format. Example: ``` >>> tensorplay.empty((2,3), dtype=tensorplay.int64) tensor([[ 9.4064e+13, 2.8000e+01, 9.3493e+13], [ 7.5751e+18, 7.1428e+18, 7.5955e+18]]) ``` [#](#api-tensorplay.entr) ### entr function[Full reference ↗](/docs/generated/tensorplay.entr.html) ```python tensorplay.entr(input) ``` [#](#api-tensorplay.eq_) ### eq_ function[Full reference ↗](/docs/generated/tensorplay.eq_.html) ```python tensorplay.eq_(input, other) ``` [#](#api-tensorplay.erfcx) ### erfcx function[Full reference ↗](/docs/generated/tensorplay.erfcx.html) ```python tensorplay.erfcx(input) ``` [#](#api-tensorplay.erfinv_) ### erfinv_ function[Full reference ↗](/docs/generated/tensorplay.erfinv_.html) ```python tensorplay.erfinv_(input) ``` [#](#api-tensorplay.expand_as) ### expand_as function[Full reference ↗](/docs/generated/tensorplay.expand_as.html) ```python tensorplay.expand_as(input, other) ``` [#](#api-tensorplay.expand) ### expand function[Full reference ↗](/docs/generated/tensorplay.expand.html) ```python tensorplay.expand(input, size, implicit=False) ``` [#](#api-tensorplay.exponential_) ### exponential_ function[Full reference ↗](/docs/generated/tensorplay.exponential_.html) ```python tensorplay.exponential_(input, lambd=1.0, generator=None) ``` [#](#api-tensorplay.fake_quantize_per_channel_affine_cachemask) ### fake_quantize_per_channel_affine_cachemask function[Full reference ↗](/docs/generated/tensorplay.fake_quantize_per_channel_affine_cachemask.html) ```python tensorplay.fake_quantize_per_channel_affine_cachemask(input, scale, zero_point, axis, quant_min, quant_max) ``` [#](#api-tensorplay.fake_quantize_per_tensor_affine_cachemask) ### fake_quantize_per_tensor_affine_cachemask function[Full reference ↗](/docs/generated/tensorplay.fake_quantize_per_tensor_affine_cachemask.html) ```python tensorplay.fake_quantize_per_tensor_affine_cachemask(input, scale, zero_point, quant_min, quant_max) ``` [#](#api-tensorplay.fft_fft) ### fft_fft function[Full reference ↗](/docs/generated/tensorplay.fft_fft.html) ```python tensorplay.fft_fft(input, n=-1, dim=-1, norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_fft2) ### fft_fft2 function[Full reference ↗](/docs/generated/tensorplay.fft_fft2.html) ```python tensorplay.fft_fft2(input, s=None, dim=[-2, -1], norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_fftfreq) ### fft_fftfreq function[Full reference ↗](/docs/generated/tensorplay.fft_fftfreq.html) ```python tensorplay.fft_fftfreq(n, d=1.0, *, dtype=None, layout=None, device=None, pin_memory=None, out=None) ``` [#](#api-tensorplay.fft_fftn) ### fft_fftn function[Full reference ↗](/docs/generated/tensorplay.fft_fftn.html) ```python tensorplay.fft_fftn(input, s=None, dim=None, norm=None, *, out=None) ``` [#](#api-tensorplay.fft_fftshift) ### fft_fftshift function[Full reference ↗](/docs/generated/tensorplay.fft_fftshift.html) ```python tensorplay.fft_fftshift(input, dim=None) ``` [#](#api-tensorplay.fft_hfft) ### fft_hfft function[Full reference ↗](/docs/generated/tensorplay.fft_hfft.html) ```python tensorplay.fft_hfft(input, n=None, dim=-1, norm=None, *, out=None) ``` [#](#api-tensorplay.fft_hfft2) ### fft_hfft2 function[Full reference ↗](/docs/generated/tensorplay.fft_hfft2.html) ```python tensorplay.fft_hfft2(input, s=None, dim=[-2, -1], norm=None, *, out=None) ``` [#](#api-tensorplay.fft_hfftn) ### fft_hfftn function[Full reference ↗](/docs/generated/tensorplay.fft_hfftn.html) ```python tensorplay.fft_hfftn(input, s=None, dim=None, norm=None, *, out=None) ``` [#](#api-tensorplay.fft_ifft) ### fft_ifft function[Full reference ↗](/docs/generated/tensorplay.fft_ifft.html) ```python tensorplay.fft_ifft(input, n=-1, dim=-1, norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_ifft2) ### fft_ifft2 function[Full reference ↗](/docs/generated/tensorplay.fft_ifft2.html) ```python tensorplay.fft_ifft2(input, s=None, dim=[-2, -1], norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_ifftn) ### fft_ifftn function[Full reference ↗](/docs/generated/tensorplay.fft_ifftn.html) ```python tensorplay.fft_ifftn(input, s=None, dim=None, norm=None, *, out=None) ``` [#](#api-tensorplay.fft_ifftshift) ### fft_ifftshift function[Full reference ↗](/docs/generated/tensorplay.fft_ifftshift.html) ```python tensorplay.fft_ifftshift(input, dim=None) ``` [#](#api-tensorplay.fft_ihfft) ### fft_ihfft function[Full reference ↗](/docs/generated/tensorplay.fft_ihfft.html) ```python tensorplay.fft_ihfft(input, n=None, dim=-1, norm=None, *, out=None) ``` [#](#api-tensorplay.fft_ihfft2) ### fft_ihfft2 function[Full reference ↗](/docs/generated/tensorplay.fft_ihfft2.html) ```python tensorplay.fft_ihfft2(input, s=None, dim=[-2, -1], norm=None, *, out=None) ``` [#](#api-tensorplay.fft_ihfftn) ### fft_ihfftn function[Full reference ↗](/docs/generated/tensorplay.fft_ihfftn.html) ```python tensorplay.fft_ihfftn(input, s=None, dim=None, norm=None, *, out=None) ``` [#](#api-tensorplay.fft_irfft) ### fft_irfft function[Full reference ↗](/docs/generated/tensorplay.fft_irfft.html) ```python tensorplay.fft_irfft(input, n=-1, dim=-1, norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_irfft2) ### fft_irfft2 function[Full reference ↗](/docs/generated/tensorplay.fft_irfft2.html) ```python tensorplay.fft_irfft2(input, s=None, dim=[-2, -1], norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_irfftn) ### fft_irfftn function[Full reference ↗](/docs/generated/tensorplay.fft_irfftn.html) ```python tensorplay.fft_irfftn(input, s=None, dim=None, norm=None, *, out=None) ``` [#](#api-tensorplay.fft_rfft) ### fft_rfft function[Full reference ↗](/docs/generated/tensorplay.fft_rfft.html) ```python tensorplay.fft_rfft(input, n=-1, dim=-1, norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_rfft2) ### fft_rfft2 function[Full reference ↗](/docs/generated/tensorplay.fft_rfft2.html) ```python tensorplay.fft_rfft2(input, s=None, dim=[-2, -1], norm='backward', *, out=None) ``` [#](#api-tensorplay.fft_rfftfreq) ### fft_rfftfreq function[Full reference ↗](/docs/generated/tensorplay.fft_rfftfreq.html) ```python tensorplay.fft_rfftfreq(n, d=1.0, *, dtype=None, layout=None, device=None, pin_memory=None, out=None) ``` [#](#api-tensorplay.fft_rfftn) ### fft_rfftn function[Full reference ↗](/docs/generated/tensorplay.fft_rfftn.html) ```python tensorplay.fft_rfftn(input, s=None, dim=None, norm=None, *, out=None) ``` [#](#api-tensorplay.fill_diagonal_) ### fill_diagonal_ function[Full reference ↗](/docs/generated/tensorplay.fill_diagonal_.html) ```python tensorplay.fill_diagonal_(input, fill_value, wrap=False) ``` [#](#api-tensorplay.flatten_dense_tensors) ### flatten_dense_tensors function[Full reference ↗](/docs/generated/tensorplay.flatten_dense_tensors.html) ```python tensorplay.flatten_dense_tensors(*args) ``` [#](#api-tensorplay.float_power_) ### float_power_ function[Full reference ↗](/docs/generated/tensorplay.float_power_.html) ```python tensorplay.float_power_(input, exponent) ``` [#](#api-tensorplay.floor_divide_) ### floor_divide_ function[Full reference ↗](/docs/generated/tensorplay.floor_divide_.html) ```python tensorplay.floor_divide_(input, other) ``` [#](#api-tensorplay.fmod_) ### fmod_ function[Full reference ↗](/docs/generated/tensorplay.fmod_.html) ```python tensorplay.fmod_(input, other) ``` [#](#api-tensorplay.fork_rng) ### fork_rng function[Full reference ↗](/docs/generated/tensorplay.fork_rng.html) ```python tensorplay.fork_rng(devices=None, enabled=True, _caller='fork_rng', _devices_kw='devices') ``` Forks the RNG state: code inside the context gets a pristine RNG. Saves the CPU RNG state and the RNG state of every CUDA device listed in devices on entry and restores them on exit, so random operations inside the block do not advance the outer streams. devices=[] forks only the CPU generator. [#](#api-tensorplay.forward_add) ### forward_add function[Full reference ↗](/docs/generated/tensorplay.forward_add.html) ```python tensorplay.forward_add(a, da, b, db) ``` [#](#api-tensorplay.forward_cos) ### forward_cos function[Full reference ↗](/docs/generated/tensorplay.forward_cos.html) ```python tensorplay.forward_cos(a, da) ``` [#](#api-tensorplay.forward_div) ### forward_div function[Full reference ↗](/docs/generated/tensorplay.forward_div.html) ```python tensorplay.forward_div(a, da, b, db) ``` [#](#api-tensorplay.forward_exp) ### forward_exp function[Full reference ↗](/docs/generated/tensorplay.forward_exp.html) ```python tensorplay.forward_exp(a, da) ``` [#](#api-tensorplay.forward_log) ### forward_log function[Full reference ↗](/docs/generated/tensorplay.forward_log.html) ```python tensorplay.forward_log(a, da) ``` [#](#api-tensorplay.forward_mm) ### forward_mm function[Full reference ↗](/docs/generated/tensorplay.forward_mm.html) ```python tensorplay.forward_mm(a, da, b, db) ``` [#](#api-tensorplay.forward_mul) ### forward_mul function[Full reference ↗](/docs/generated/tensorplay.forward_mul.html) ```python tensorplay.forward_mul(a, da, b, db) ``` [#](#api-tensorplay.forward_neg) ### forward_neg function[Full reference ↗](/docs/generated/tensorplay.forward_neg.html) ```python tensorplay.forward_neg(a, da) ``` [#](#api-tensorplay.forward_pow) ### forward_pow function[Full reference ↗](/docs/generated/tensorplay.forward_pow.html) ```python tensorplay.forward_pow(a, da, b, db) ``` [#](#api-tensorplay.forward_relu) ### forward_relu function[Full reference ↗](/docs/generated/tensorplay.forward_relu.html) ```python tensorplay.forward_relu(a, da) ``` [#](#api-tensorplay.forward_sigmoid) ### forward_sigmoid function[Full reference ↗](/docs/generated/tensorplay.forward_sigmoid.html) ```python tensorplay.forward_sigmoid(a, da) ``` [#](#api-tensorplay.forward_sin) ### forward_sin function[Full reference ↗](/docs/generated/tensorplay.forward_sin.html) ```python tensorplay.forward_sin(a, da) ``` [#](#api-tensorplay.forward_sqrt) ### forward_sqrt function[Full reference ↗](/docs/generated/tensorplay.forward_sqrt.html) ```python tensorplay.forward_sqrt(a, da) ``` [#](#api-tensorplay.forward_sub) ### forward_sub function[Full reference ↗](/docs/generated/tensorplay.forward_sub.html) ```python tensorplay.forward_sub(a, da, b, db) ``` [#](#api-tensorplay.forward_tanh) ### forward_tanh function[Full reference ↗](/docs/generated/tensorplay.forward_tanh.html) ```python tensorplay.forward_tanh(a, da) ``` [#](#api-tensorplay.fractional_max_pool2d) ### fractional_max_pool2d function[Full reference ↗](/docs/generated/tensorplay.fractional_max_pool2d.html) ```python tensorplay.fractional_max_pool2d(input, kernel_size, output_size, random_samples, *, out=None) ``` [#](#api-tensorplay.fractional_max_pool3d) ### fractional_max_pool3d function[Full reference ↗](/docs/generated/tensorplay.fractional_max_pool3d.html) ```python tensorplay.fractional_max_pool3d(input, kernel_size, output_size, random_samples, *, out=None) ``` [#](#api-tensorplay.frobenius_norm) ### frobenius_norm function[Full reference ↗](/docs/generated/tensorplay.frobenius_norm.html) ```python tensorplay.frobenius_norm(input, dim, keepdim=False, *, out=None) ``` [#](#api-tensorplay.from_dlpack) ### from_dlpack function[Full reference ↗](/docs/generated/tensorplay.from_dlpack.html) ```python tensorplay.from_dlpack(obj: object) → tensorplay::Tensor ``` [#](#api-tensorplay.from_numpy) ### from_numpy function[Full reference ↗](/docs/generated/tensorplay.from_numpy.html) ```python tensorplay.from_numpy(ndarray) → Tensor ``` Creates a [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) from a numpy.ndarray. The returned tensor and ndarray share the same memory. Modifications to the tensor will be reflected in the ndarray and vice versa. The returned tensor is not resizable. It currently accepts ndarray with dtypes of numpy.float64, numpy.float32, numpy.float16, numpy.complex64, numpy.complex128, numpy.int64, numpy.int32, numpy.int16, numpy.int8, numpy.uint8, and bool. > **Warning** > > Writing to a tensor created from a read-only NumPy array is not supported and will result in undefined behavior. Example: ``` >>> a = numpy.array([1, 2, 3]) >>> t = tensorplay.from_numpy(a) >>> t tensor([ 1, 2, 3]) >>> t[0] = -1 >>> a array([-1, 2, 3]) ``` [#](#api-tensorplay.frombuffer) ### frombuffer function[Full reference ↗](/docs/generated/tensorplay.frombuffer.html) ```python tensorplay.frombuffer(buffer, *, dtype, count=-1, offset=0, requires_grad=False) → Tensor ``` Creates a 1-dimensional [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) from an object that implements the Python buffer protocol. Skips the first offset bytes in the buffer, and interprets the rest of the raw bytes as a 1-dimensional tensor of type [dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType) with count elements. Note that either of the following must be true: 1. count is a positive non-zero number, and the total number of bytes in the buffer is more than offset plus count times the size (in bytes) of [dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType). 2. count is negative, and the length (number of bytes) of the buffer subtracted by the offset is a multiple of the size (in bytes) of [dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType). The returned tensor and buffer share the same memory. Modifications to the tensor will be reflected in the buffer and vice versa. The returned tensor is not resizable. > **Note** > > This function increments the reference count for the object that owns the shared memory. Therefore, such memory will not be deallocated before the returned tensor goes out of scope. > **Warning** > > This function’s behavior is undefined when passed an object implementing the buffer protocol whose data is not on the CPU. Doing so is likely to cause a segmentation fault. > **Warning** > > This function does not try to infer the dtype (hence, it is not optional). Passing a different dtype than its source may result in unexpected behavior. Parameters: buffer ([object](https://docs.python.org/3/builtins/functions.html#object)) – a Python object that exposes the buffer interface. Keyword Arguments: - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType)) – the desired data type of returned tensor. - count ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – the number of desired elements to be read. If negative, all the elements (until the end of the buffer) will be read. Default: -1. - offset ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – the number of bytes to skip at the start of the buffer. Default: 0. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. Example: ``` >>> import array >>> a = array.array('i', [1, 2, 3]) >>> t = tensorplay.frombuffer(a, dtype=tensorplay.int32) >>> t tensor([ 1, 2, 3]) >>> t[0] = -1 >>> a array([-1, 2, 3]) >>> # Interprets the signed char bytes as 32-bit integers. >>> # Each 4 signed char elements will be interpreted as >>> # 1 signed 32-bit integer. >>> import array >>> a = array.array('b', [-1, 0, 0, 0]) >>> tensorplay.frombuffer(a, dtype=tensorplay.int32) tensor([255], dtype=tensorplay.int32) ``` [#](#api-tensorplay.full) ### full function[Full reference ↗](/docs/generated/tensorplay.full.html) ```python tensorplay.full(size, fill_value, \*, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False) → Tensor ``` Creates a tensor of size [size](/docs/generated/tensorplay.size.html#tensorplay.size) filled with fill_value. The tensor’s dtype is inferred from fill_value. Parameters: - size ([int](https://docs.python.org/3/builtins/functions.html#int)...) – a list, tuple, or [tensorplay.Size](/docs/generated/tensorplay.Size.html#tensorplay.Size) of integers defining the shape of the output tensor. - fill_value ([Scalar](/docs/generated/tensorplay.Scalar.html#tensorplay.Scalar)) – the value to fill the output tensor with. Keyword Arguments: - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, uses a global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout (tensorplay.layout, optional) – the desired layout of returned Tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. Example: ``` >>> tensorplay.full((2, 3), 3.141592) tensor([[ 3.1416, 3.1416, 3.1416], [ 3.1416, 3.1416, 3.1416]]) ``` [#](#api-tensorplay.fused_mul_add) ### fused_mul_add function[Full reference ↗](/docs/generated/tensorplay.fused_mul_add.html) ```python tensorplay.fused_mul_add(input, other, addend) ``` [#](#api-tensorplay.fused_rope) ### fused_rope function[Full reference ↗](/docs/generated/tensorplay.fused_rope.html) ```python tensorplay.fused_rope(query, key, cos, sin, position_offset=0) ``` [#](#api-tensorplay.fused_swiglu) ### fused_swiglu function[Full reference ↗](/docs/generated/tensorplay.fused_swiglu.html) ```python tensorplay.fused_swiglu(gate, up) ``` [#](#api-tensorplay.gammainc) ### gammainc function[Full reference ↗](/docs/generated/tensorplay.gammainc.html) ```python tensorplay.gammainc(a, x) ``` [#](#api-tensorplay.gammaincc) ### gammaincc function[Full reference ↗](/docs/generated/tensorplay.gammaincc.html) ```python tensorplay.gammaincc(a, x) ``` [#](#api-tensorplay.ge_) ### ge_ function[Full reference ↗](/docs/generated/tensorplay.ge_.html) ```python tensorplay.ge_(input, other) ``` [#](#api-tensorplay.gelu_) ### gelu_ function[Full reference ↗](/docs/generated/tensorplay.gelu_.html) ```python tensorplay.gelu_(input, approximate='none') ``` [#](#api-tensorplay.gelu) ### gelu function[Full reference ↗](/docs/generated/tensorplay.gelu.html) ```python tensorplay.gelu(input, approximate='none', *, out=None) ``` [#](#api-tensorplay.geometric_) ### geometric_ function[Full reference ↗](/docs/generated/tensorplay.geometric_.html) ```python tensorplay.geometric_(input, p, generator=None) ``` [#](#api-tensorplay.get_autocast_dtype) ### get_autocast_dtype function[Full reference ↗](/docs/generated/tensorplay.get_autocast_dtype.html) ```python tensorplay.get_autocast_dtype(device_type: str = 'cuda') → tensorplay._C.DType ``` [#](#api-tensorplay.get_default_device) ### get_default_device function[Full reference ↗](/docs/generated/tensorplay.get_default_device.html) ```python tensorplay.get_default_device() → device ``` Gets the default tensorplay.Tensor to be allocated on device [#](#api-tensorplay.get_default_dtype) ### get_default_dtype function[Full reference ↗](/docs/generated/tensorplay.get_default_dtype.html) ```python tensorplay.get_default_dtype() → tensorplay.dtype ``` Get the current default floating point [tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType). Example: ``` >>> tensorplay.get_default_dtype() # initial default for floating point is tensorplay.float32 tensorplay.float32 >>> tensorplay.set_default_dtype(tensorplay.float64) >>> tensorplay.get_default_dtype() # default is now changed to tensorplay.float64 tensorplay.float64 ``` [#](#api-tensorplay.get_deterministic_debug_mode) ### get_deterministic_debug_mode function[Full reference ↗](/docs/generated/tensorplay.get_deterministic_debug_mode.html) ```python tensorplay.get_deterministic_debug_mode() → int ``` Returns the current value of the debug mode for deterministic operations. Refer to [tensorplay.set_deterministic_debug_mode()](/docs/generated/tensorplay.set_deterministic_debug_mode.html#tensorplay.set_deterministic_debug_mode) documentation for more details. [#](#api-tensorplay.get_float32_matmul_precision) ### get_float32_matmul_precision function[Full reference ↗](/docs/generated/tensorplay.get_float32_matmul_precision.html) ```python tensorplay.get_float32_matmul_precision() → str ``` Returns the current value of float32 matrix multiplication precision. Refer to [tensorplay.set_float32_matmul_precision()](/docs/generated/tensorplay.set_float32_matmul_precision.html#tensorplay.set_float32_matmul_precision) documentation for more details. [#](#api-tensorplay.get_num_threads) ### get_num_threads function[Full reference ↗](/docs/generated/tensorplay.get_num_threads.html) ```python tensorplay.get_num_threads() → int ``` Returns the number of threads used for parallelizing CPU operations [#](#api-tensorplay.get_parallel_info) ### get_parallel_info function[Full reference ↗](/docs/generated/tensorplay.get_parallel_info.html) ```python tensorplay.get_parallel_info() → str ``` Returns a detailed string describing parallelization settings [#](#api-tensorplay.get_rng_state) ### get_rng_state function[Full reference ↗](/docs/generated/tensorplay.get_rng_state.html) ```python tensorplay.get_rng_state() → tensorplay::Tensor ``` [#](#api-tensorplay.get_thread_num) ### get_thread_num function[Full reference ↗](/docs/generated/tensorplay.get_thread_num.html) ```python tensorplay.get_thread_num() → int ``` Returns the current thread number (starting from 0) in the current parallel region, or 0 in the sequential region [#](#api-tensorplay.glu_backward_jvp) ### glu_backward_jvp function[Full reference ↗](/docs/generated/tensorplay.glu_backward_jvp.html) ```python tensorplay.glu_backward_jvp(grad_x, grad_glu, x, dgrad_glu, dx, dim) ``` [#](#api-tensorplay.glu_jvp) ### glu_jvp function[Full reference ↗](/docs/generated/tensorplay.glu_jvp.html) ```python tensorplay.glu_jvp(glu, x, dx, dim) ``` [#](#api-tensorplay.glu) ### glu function[Full reference ↗](/docs/generated/tensorplay.glu.html) ```python tensorplay.glu(input, dim=-1, *, out=None) ``` [#](#api-tensorplay.gradient) ### gradient function[Full reference ↗](/docs/generated/tensorplay.gradient.html) ```python tensorplay.gradient(input, *, spacing=1, dim=None, edge_order=1) → List of Tensors ``` Estimates the gradient of a function $g : \mathbb{R}^n \rightarrow \mathbb{R}$ in one or more dimensions using the [second-order accurate central differences method](https://www.ams.org/journals/mcom/1988-51-184/S0025-5718-1988-0935077-0/S0025-5718-1988-0935077-0.pdf) and either first or second order estimates at the boundaries. The gradient of $g$ is estimated using samples. By default, when spacing is not specified, the samples are entirely described by input, and the mapping of input coordinates to an output is the same as the tensor’s mapping of indices to values. For example, for a three-dimensional input the function described is $g : \mathbb{R}^3 \rightarrow \mathbb{R}$, and $g(1, 2, 3)\ == input[1, 2, 3]$. When spacing is specified, it modifies the relationship between input and input coordinates. This is detailed in the “Keyword Arguments” section below. The gradient is estimated by estimating each partial derivative of $g$ independently. This estimation is accurate if $g$ is in $C^3$ (it has at least 3 continuous derivatives), and the estimation can be improved by providing closer samples. Mathematically, the value at each interior point of a partial derivative is estimated using [Taylor’s theorem with remainder](https://en.wikipedia.org/wiki/Taylor%27s_theorem). Letting $x$ be an interior point with $x-h_l$ and $x+h_r$ be points neighboring it to the left and right respectively, $f(x+h_r)$ and $f(x-h_l)$ can be estimated using: $$\begin{split}\begin{aligned} f(x+h_r) = f(x) + h_r f'(x) + {h_r}^2 \frac{f''(x)}{2} + {h_r}^3 \frac{f'''(\xi_1)}{6}, \xi_1 \in (x, x+h_r) \\ f(x-h_l) = f(x) - h_l f'(x) + {h_l}^2 \frac{f''(x)}{2} - {h_l}^3 \frac{f'''(\xi_2)}{6}, \xi_2 \in (x, x-h_l) \\ \end{aligned}\end{split}$$ Using the fact that $f \in C^3$ and solving the linear system, we derive: $$f'(x) \approx \frac{ {h_l}^2 f(x+h_r) - {h_r}^2 f(x-h_l) + ({h_r}^2-{h_l}^2 ) f(x) }{ {h_r} {h_l}^2 + {h_r}^2 {h_l} }$$ > **Note** > > We estimate the gradient of functions in complex domain $g : \mathbb{C}^n \rightarrow \mathbb{C}$ in the same way. The value of each partial derivative at the boundary points is computed differently. See edge_order below. Parameters: input (Tensor) – the tensor that represents the values of the function Keyword Arguments: - spacing (scalar, list of scalar, list of Tensor, optional) – spacing can be used to modify how the input tensor’s indices relate to sample coordinates. If spacing is a scalar then the indices are multiplied by the scalar to produce the coordinates. For example, if spacing=2 the indices (1, 2, 3) become coordinates (2, 4, 6). If spacing is a list of scalars then the corresponding indices are multiplied. For example, if spacing=(2, -1, 3) the indices (1, 2, 3) become coordinates (2, -2, 9). Finally, if spacing is a list of one-dimensional tensors then each tensor specifies the coordinates for the corresponding dimension. For example, if the indices are (1, 2, 3) and the tensors are (t0, t1, t2), then the coordinates are (t0[1], t1[2], t2[3]) - dim (int, list of int, optional) – the dimension or dimensions to approximate the gradient over. By default the partial gradient in every dimension is computed. Note that when [dim](/docs/generated/tensorplay.dim.html#tensorplay.dim) is specified the elements of the spacing argument must correspond with the specified dims.” - edge_order (int, optional) – 1 or 2, for [first-order](https://www.ams.org/journals/mcom/1988-51-184/S0025-5718-1988-0935077-0/S0025-5718-1988-0935077-0.pdf) or [second-order](https://www.ams.org/journals/mcom/1988-51-184/S0025-5718-1988-0935077-0/S0025-5718-1988-0935077-0.pdf) estimation of the boundary (“edge”) values, respectively. Note that when edge_order is specified, each dimension size of input should be at least edge_order+1 Examples: ``` >>> # Estimates the gradient of f(x)=x^2 at points [-2, -1, 2, 4] >>> coordinates = (tensorplay.tensor([-2., -1., 1., 4.]),) >>> values = tensorplay.tensor([4., 1., 1., 16.], ) >>> tensorplay.gradient(values, spacing = coordinates) (tensor([-3., -2., 2., 5.]),) >>> # Estimates the gradient of the R^2 -> R function whose samples are >>> # described by the tensor t. Implicit coordinates are [0, 1] for the outermost >>> # dimension and [0, 1, 2, 3] for the innermost dimension, and function estimates >>> # partial derivative for both dimensions. >>> t = tensorplay.tensor([[1, 2, 4, 8], [10, 20, 40, 80]]) >>> tensorplay.gradient(t) (tensor([[ 9., 18., 36., 72.], [ 9., 18., 36., 72.]]), tensor([[ 1.0000, 1.5000, 3.0000, 4.0000], [10.0000, 15.0000, 30.0000, 40.0000]])) >>> # A scalar value for spacing modifies the relationship between tensor indices >>> # and input coordinates by multiplying the indices to find the >>> # coordinates. For example, below the indices of the innermost >>> # 0, 1, 2, 3 translate to coordinates of [0, 2, 4, 6], and the indices of >>> # the outermost dimension 0, 1 translate to coordinates of [0, 2]. >>> tensorplay.gradient(t, spacing = 2.0) # dim = None (implicitly [0, 1]) (tensor([[ 4.5000, 9.0000, 18.0000, 36.0000], [ 4.5000, 9.0000, 18.0000, 36.0000]]), tensor([[ 0.5000, 0.7500, 1.5000, 2.0000], [ 5.0000, 7.5000, 15.0000, 20.0000]])) >>> # doubling the spacing between samples halves the estimated partial gradients. >>> >>> # Estimates only the partial derivative for dimension 1 >>> tensorplay.gradient(t, dim = 1) # spacing = None (implicitly 1.) (tensor([[ 1.0000, 1.5000, 3.0000, 4.0000], [10.0000, 15.0000, 30.0000, 40.0000]]),) >>> # When spacing is a list of scalars, the relationship between the tensor >>> # indices and input coordinates changes based on dimension. >>> # For example, below, the indices of the innermost dimension 0, 1, 2, 3 translate >>> # to coordinates of [0, 3, 6, 9], and the indices of the outermost dimension >>> # 0, 1 translate to coordinates of [0, 2]. >>> tensorplay.gradient(t, spacing = [3., 2.]) (tensor([[ 4.5000, 9.0000, 18.0000, 36.0000], [ 4.5000, 9.0000, 18.0000, 36.0000]]), tensor([[ 0.3333, 0.5000, 1.0000, 1.3333], [ 3.3333, 5.0000, 10.0000, 13.3333]])) >>> # The following example is a replication of the previous one with explicit >>> # coordinates. >>> coords = (tensorplay.tensor([0, 2]), tensorplay.tensor([0, 3, 6, 9])) >>> tensorplay.gradient(t, spacing = coords) (tensor([[ 4.5000, 9.0000, 18.0000, 36.0000], [ 4.5000, 9.0000, 18.0000, 36.0000]]), tensor([[ 0.3333, 0.5000, 1.0000, 1.3333], [ 3.3333, 5.0000, 10.0000, 13.3333]])) ``` [#](#api-tensorplay.greater_) ### greater_ function[Full reference ↗](/docs/generated/tensorplay.greater_.html) ```python tensorplay.greater_(input, other) ``` [#](#api-tensorplay.greater_equal_) ### greater_equal_ function[Full reference ↗](/docs/generated/tensorplay.greater_equal_.html) ```python tensorplay.greater_equal_(input, other) ``` [#](#api-tensorplay.grid_sampler) ### grid_sampler function[Full reference ↗](/docs/generated/tensorplay.grid_sampler.html) ```python tensorplay.grid_sampler(input, grid, interpolation_mode, padding_mode, align_corners) ``` [#](#api-tensorplay.grouped_mm) ### grouped_mm function[Full reference ↗](/docs/generated/tensorplay.grouped_mm.html) ```python tensorplay.grouped_mm(input, mat2, offs) ``` [#](#api-tensorplay.gt_) ### gt_ function[Full reference ↗](/docs/generated/tensorplay.gt_.html) ```python tensorplay.gt_(input, other) ``` [#](#api-tensorplay.hardsigmoid_) ### hardsigmoid_ function[Full reference ↗](/docs/generated/tensorplay.hardsigmoid_.html) ```python tensorplay.hardsigmoid_(input) ``` [#](#api-tensorplay.hardsigmoid) ### hardsigmoid function[Full reference ↗](/docs/generated/tensorplay.hardsigmoid.html) ```python tensorplay.hardsigmoid(input, *, out=None) ``` [#](#api-tensorplay.hardswish_) ### hardswish_ function[Full reference ↗](/docs/generated/tensorplay.hardswish_.html) ```python tensorplay.hardswish_(input) ``` [#](#api-tensorplay.hardswish) ### hardswish function[Full reference ↗](/docs/generated/tensorplay.hardswish.html) ```python tensorplay.hardswish(input, *, out=None) ``` [#](#api-tensorplay.hardtanh_) ### hardtanh_ function[Full reference ↗](/docs/generated/tensorplay.hardtanh_.html) ```python tensorplay.hardtanh_(input, min_val=-1, max_val=1) ``` [#](#api-tensorplay.hardtanh) ### hardtanh function[Full reference ↗](/docs/generated/tensorplay.hardtanh.html) ```python tensorplay.hardtanh(input, min_val=-1, max_val=1, *, out=None) ``` [#](#api-tensorplay.heaviside_) ### heaviside_ function[Full reference ↗](/docs/generated/tensorplay.heaviside_.html) ```python tensorplay.heaviside_(input, values) ``` [#](#api-tensorplay.hermite_polynomial_h) ### hermite_polynomial_h function[Full reference ↗](/docs/generated/tensorplay.hermite_polynomial_h.html) ```python tensorplay.hermite_polynomial_h(x, n) ``` [#](#api-tensorplay.hermite_polynomial_he) ### hermite_polynomial_he function[Full reference ↗](/docs/generated/tensorplay.hermite_polynomial_he.html) ```python tensorplay.hermite_polynomial_he(x, n) ``` [#](#api-tensorplay.hspmm) ### hspmm function[Full reference ↗](/docs/generated/tensorplay.hspmm.html) ```python tensorplay.hspmm(mat1, mat2, *, out=None) → Tensor ``` Performs a matrix multiplication of a [sparse COO matrix](/docs/sparse.html#sparse-coo-docs) mat1 and a strided matrix mat2. The result is a (1 + 1)-dimensional [hybrid COO matrix](/docs/sparse.html#sparse-hybrid-coo-docs). Parameters: - mat1 ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the first sparse matrix to be matrix multiplied - mat2 ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the second strided matrix to be matrix multiplied Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. [#](#api-tensorplay.huber_loss) ### huber_loss function[Full reference ↗](/docs/generated/tensorplay.huber_loss.html) ```python tensorplay.huber_loss(input, target, reduction=1, delta=1.0, *, out=None) ``` [#](#api-tensorplay.hypot_) ### hypot_ function[Full reference ↗](/docs/generated/tensorplay.hypot_.html) ```python tensorplay.hypot_(input, other) ``` [#](#api-tensorplay.i0e) ### i0e function[Full reference ↗](/docs/generated/tensorplay.i0e.html) ```python tensorplay.i0e(input) ``` [#](#api-tensorplay.i1) ### i1 function[Full reference ↗](/docs/generated/tensorplay.i1.html) ```python tensorplay.i1(input) ``` [#](#api-tensorplay.i1e) ### i1e function[Full reference ↗](/docs/generated/tensorplay.i1e.html) ```python tensorplay.i1e(input) ``` [#](#api-tensorplay.igamma_) ### igamma_ function[Full reference ↗](/docs/generated/tensorplay.igamma_.html) ```python tensorplay.igamma_(input, other) ``` [#](#api-tensorplay.igammac_) ### igammac_ function[Full reference ↗](/docs/generated/tensorplay.igammac_.html) ```python tensorplay.igammac_(input, other) ``` [#](#api-tensorplay.im2col) ### im2col function[Full reference ↗](/docs/generated/tensorplay.im2col.html) ```python tensorplay.im2col(input, kernel_size, dilation=[], padding=[], stride=[], *, out=None) ``` [#](#api-tensorplay.in_parallel_region) ### in_parallel_region function[Full reference ↗](/docs/generated/tensorplay.in_parallel_region.html) ```python tensorplay.in_parallel_region() → bool ``` Checks whether the code runs in a parallel region [#](#api-tensorplay.index_add_) ### index_add_ function[Full reference ↗](/docs/generated/tensorplay.index_add_.html) ```python tensorplay.index_add_(input, dim, index, source) ``` [#](#api-tensorplay.index_copy_) ### index_copy_ function[Full reference ↗](/docs/generated/tensorplay.index_copy_.html) ```python tensorplay.index_copy_(input, dim, index, source) ``` [#](#api-tensorplay.index_fill_) ### index_fill_ function[Full reference ↗](/docs/generated/tensorplay.index_fill_.html) ```python tensorplay.index_fill_(input, dim, index, value) ``` [#](#api-tensorplay.index_fill) ### index_fill function[Full reference ↗](/docs/generated/tensorplay.index_fill.html) ```python tensorplay.index_fill(input, dim, index, value) ``` [#](#api-tensorplay.index_put) ### index_put function[Full reference ↗](/docs/generated/tensorplay.index_put.html) ```python tensorplay.index_put(input, indices, values, accumulate=False) ``` [#](#api-tensorplay.index_reduce_) ### index_reduce_ function[Full reference ↗](/docs/generated/tensorplay.index_reduce_.html) ```python tensorplay.index_reduce_(input, dim, index, source, reduce, include_self=True) ``` [#](#api-tensorplay.index) ### index function[Full reference ↗](/docs/generated/tensorplay.index.html) ```python tensorplay.index(input, indices, *, out=None) ``` [#](#api-tensorplay.indices) ### indices function[Full reference ↗](/docs/generated/tensorplay.indices.html) ```python tensorplay.indices(input) ``` [#](#api-tensorplay.initial_seed) ### initial_seed function[Full reference ↗](/docs/generated/tensorplay.initial_seed.html) ```python tensorplay.initial_seed() → int ``` [#](#api-tensorplay.inner_backward_other) ### inner_backward_other function[Full reference ↗](/docs/generated/tensorplay.inner_backward_other.html) ```python tensorplay.inner_backward_other(grad_output, input, other) ``` [#](#api-tensorplay.inner_backward_self) ### inner_backward_self function[Full reference ↗](/docs/generated/tensorplay.inner_backward_self.html) ```python tensorplay.inner_backward_self(grad_output, input, other) ``` [#](#api-tensorplay.inspect_checkpoint) ### inspect_checkpoint function[Full reference ↗](/docs/generated/tensorplay.inspect_checkpoint.html) ```python tensorplay.inspect_checkpoint(f, *, verify_checksums: bool = False) → dict ``` [#](#api-tensorplay.is_autocast_available) ### is_autocast_available function[Full reference ↗](/docs/generated/tensorplay.is_autocast_available.html) ```python tensorplay.is_autocast_available(device_type: str) → bool ``` Return a bool indicating if autocast is available on device_type. Parameters: device_type ([str](https://docs.python.org/3/builtins/stdtypes.html#str)) – Device type to use. Possible values are: ‘cuda’, ‘cpu’. The type is the same as the type attribute of a [tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device). Thus, you may obtain the device type of a tensor using Tensor.device.type. [#](#api-tensorplay.is_autocast_cache_enabled) ### is_autocast_cache_enabled function[Full reference ↗](/docs/generated/tensorplay.is_autocast_cache_enabled.html) ```python tensorplay.is_autocast_cache_enabled() → bool ``` [#](#api-tensorplay.is_autocast_enabled) ### is_autocast_enabled function[Full reference ↗](/docs/generated/tensorplay.is_autocast_enabled.html) ```python tensorplay.is_autocast_enabled(device_type: str = 'cuda') → bool ``` [#](#api-tensorplay.is_coalesced) ### is_coalesced function[Full reference ↗](/docs/generated/tensorplay.is_coalesced.html) ```python tensorplay.is_coalesced(input) ``` [#](#api-tensorplay.is_contiguous) ### is_contiguous function[Full reference ↗](/docs/generated/tensorplay.is_contiguous.html) ```python tensorplay.is_contiguous(input) ``` [#](#api-tensorplay.is_deterministic_algorithms_warn_only_enabled) ### is_deterministic_algorithms_warn_only_enabled function[Full reference ↗](/docs/generated/tensorplay.is_deterministic_algorithms_warn_only_enabled.html) ```python tensorplay.is_deterministic_algorithms_warn_only_enabled() → bool ``` Returns True if the global deterministic flag is set to warn only. Refer to [tensorplay.use_deterministic_algorithms()](/docs/generated/tensorplay.use_deterministic_algorithms.html#tensorplay.use_deterministic_algorithms) documentation for more details. [#](#api-tensorplay.is_leaf) ### is_leaf function[Full reference ↗](/docs/generated/tensorplay.is_leaf.html) ```python tensorplay.is_leaf(input) ``` [#](#api-tensorplay.is_pinned) ### is_pinned function[Full reference ↗](/docs/generated/tensorplay.is_pinned.html) ```python tensorplay.is_pinned(input, device=None) ``` [#](#api-tensorplay.is_quantized) ### is_quantized function[Full reference ↗](/docs/generated/tensorplay.is_quantized.html) ```python tensorplay.is_quantized(input) ``` [#](#api-tensorplay.is_set_to) ### is_set_to function[Full reference ↗](/docs/generated/tensorplay.is_set_to.html) ```python tensorplay.is_set_to(input, tensor) ``` [#](#api-tensorplay.is_storage) ### is_storage function[Full reference ↗](/docs/generated/tensorplay.is_storage.html) ```python tensorplay.is_storage(obj: object) → bool ``` [#](#api-tensorplay.is_tensor) ### is_tensor function[Full reference ↗](/docs/generated/tensorplay.is_tensor.html) ```python tensorplay.is_tensor(obj: Any, /) → TypeIs[Tensor] ``` Returns True if obj is a TensorPlay tensor. Note that this function is simply doing isinstance(obj, Tensor). Using that isinstance check is better for type checking with mypy, and more explicit - so it’s recommended to use that instead of is_tensor. Parameters: obj ([object](https://docs.python.org/3/builtins/functions.html#object)) – Object to test Example: ``` >>> x = tensorplay.tensor([1, 2, 3]) >>> tensorplay.is_tensor(x) True ``` [#](#api-tensorplay.item) ### item function[Full reference ↗](/docs/generated/tensorplay.item.html) ```python tensorplay.item(input) ``` [#](#api-tensorplay.l1_loss) ### l1_loss function[Full reference ↗](/docs/generated/tensorplay.l1_loss.html) ```python tensorplay.l1_loss(input, target) ``` [#](#api-tensorplay.laguerre_polynomial_l) ### laguerre_polynomial_l function[Full reference ↗](/docs/generated/tensorplay.laguerre_polynomial_l.html) ```python tensorplay.laguerre_polynomial_l(x, n) ``` [#](#api-tensorplay.layer_norm) ### layer_norm function[Full reference ↗](/docs/generated/tensorplay.layer_norm.html) ```python tensorplay.layer_norm(input, normalized_shape, weight=None, bias=None, eps=1e-05) ``` [#](#api-tensorplay.le_) ### le_ function[Full reference ↗](/docs/generated/tensorplay.le_.html) ```python tensorplay.le_(input, other) ``` [#](#api-tensorplay.leaky_relu_) ### leaky_relu_ function[Full reference ↗](/docs/generated/tensorplay.leaky_relu_.html) ```python tensorplay.leaky_relu_(input, negative_slope=0.01) ``` [#](#api-tensorplay.leaky_relu) ### leaky_relu function[Full reference ↗](/docs/generated/tensorplay.leaky_relu.html) ```python tensorplay.leaky_relu(input, negative_slope=0.01, *, out=None) ``` [#](#api-tensorplay.legendre_polynomial_p) ### legendre_polynomial_p function[Full reference ↗](/docs/generated/tensorplay.legendre_polynomial_p.html) ```python tensorplay.legendre_polynomial_p(x, n) ``` [#](#api-tensorplay.lerp_) ### lerp_ function[Full reference ↗](/docs/generated/tensorplay.lerp_.html) ```python tensorplay.lerp_(input, end, weight) ``` [#](#api-tensorplay.less_) ### less_ function[Full reference ↗](/docs/generated/tensorplay.less_.html) ```python tensorplay.less_(input, other) ``` [#](#api-tensorplay.less_equal_) ### less_equal_ function[Full reference ↗](/docs/generated/tensorplay.less_equal_.html) ```python tensorplay.less_equal_(input, other) ``` [#](#api-tensorplay.lgamma_) ### lgamma_ function[Full reference ↗](/docs/generated/tensorplay.lgamma_.html) ```python tensorplay.lgamma_(input) ``` [#](#api-tensorplay.lift_fresh_copy) ### lift_fresh_copy function[Full reference ↗](/docs/generated/tensorplay.lift_fresh_copy.html) ```python tensorplay.lift_fresh_copy(input) ``` [#](#api-tensorplay.lift_fresh) ### lift_fresh function[Full reference ↗](/docs/generated/tensorplay.lift_fresh.html) ```python tensorplay.lift_fresh(input) ``` [#](#api-tensorplay.lift) ### lift function[Full reference ↗](/docs/generated/tensorplay.lift.html) ```python tensorplay.lift(input) ``` [#](#api-tensorplay.linear) ### linear function[Full reference ↗](/docs/generated/tensorplay.linear.html) ```python tensorplay.linear(input, weight, bias=None) ``` [#](#api-tensorplay.log_ndtr) ### log_ndtr function[Full reference ↗](/docs/generated/tensorplay.log_ndtr.html) ```python tensorplay.log_ndtr(input) ``` [#](#api-tensorplay.log_normal_) ### log_normal_ function[Full reference ↗](/docs/generated/tensorplay.log_normal_.html) ```python tensorplay.log_normal_(input, mean=1.0, std=2.0, generator=None) ``` [#](#api-tensorplay.log_sigmoid_forward) ### log_sigmoid_forward function[Full reference ↗](/docs/generated/tensorplay.log_sigmoid_forward.html) ```python tensorplay.log_sigmoid_forward(input, *, out=None) ``` [#](#api-tensorplay.log_sigmoid) ### log_sigmoid function[Full reference ↗](/docs/generated/tensorplay.log_sigmoid.html) ```python tensorplay.log_sigmoid(input, *, out=None) ``` [#](#api-tensorplay.log_softmax) ### log_softmax function[Full reference ↗](/docs/generated/tensorplay.log_softmax.html) ```python tensorplay.log_softmax(input, dim, dtype=tensorplay.undefined, *, out=None) ``` [#](#api-tensorplay.logical_and_) ### logical_and_ function[Full reference ↗](/docs/generated/tensorplay.logical_and_.html) ```python tensorplay.logical_and_(input, other) ``` [#](#api-tensorplay.logical_not_) ### logical_not_ function[Full reference ↗](/docs/generated/tensorplay.logical_not_.html) ```python tensorplay.logical_not_(input) ``` [#](#api-tensorplay.logical_or_) ### logical_or_ function[Full reference ↗](/docs/generated/tensorplay.logical_or_.html) ```python tensorplay.logical_or_(input, other) ``` [#](#api-tensorplay.logical_xor_) ### logical_xor_ function[Full reference ↗](/docs/generated/tensorplay.logical_xor_.html) ```python tensorplay.logical_xor_(input, other) ``` [#](#api-tensorplay.lt_) ### lt_ function[Full reference ↗](/docs/generated/tensorplay.lt_.html) ```python tensorplay.lt_(input, other) ``` [#](#api-tensorplay.manual_seed) ### manual_seed function[Full reference ↗](/docs/generated/tensorplay.manual_seed.html) ```python tensorplay.manual_seed(seed: SupportsInt | SupportsIndex) → None ``` [#](#api-tensorplay.masked_fill_) ### masked_fill_ function[Full reference ↗](/docs/generated/tensorplay.masked_fill_.html) ```python tensorplay.masked_fill_(input, mask, value) ``` [#](#api-tensorplay.masked_scatter_) ### masked_scatter_ function[Full reference ↗](/docs/generated/tensorplay.masked_scatter_.html) ```python tensorplay.masked_scatter_(input, mask, source) ``` [#](#api-tensorplay.masked_scatter) ### masked_scatter function[Full reference ↗](/docs/generated/tensorplay.masked_scatter.html) ```python tensorplay.masked_scatter(input, mask, source) ``` [#](#api-tensorplay.matmul_backward_other) ### matmul_backward_other function[Full reference ↗](/docs/generated/tensorplay.matmul_backward_other.html) ```python tensorplay.matmul_backward_other(grad_output, input, other) ``` [#](#api-tensorplay.matmul_backward_self) ### matmul_backward_self function[Full reference ↗](/docs/generated/tensorplay.matmul_backward_self.html) ```python tensorplay.matmul_backward_self(grad_output, input, other) ``` [#](#api-tensorplay.matrix_H) ### matrix_H function[Full reference ↗](/docs/generated/tensorplay.matrix_H.html) ```python tensorplay.matrix_H(input) ``` [#](#api-tensorplay.max_pool1d_with_indices) ### max_pool1d_with_indices function[Full reference ↗](/docs/generated/tensorplay.max_pool1d_with_indices.html) ```python tensorplay.max_pool1d_with_indices(input, kernel_size, stride=[], padding=0, dilation=1, ceil_mode=False) ``` [#](#api-tensorplay.max_pool2d_with_indices) ### max_pool2d_with_indices function[Full reference ↗](/docs/generated/tensorplay.max_pool2d_with_indices.html) ```python tensorplay.max_pool2d_with_indices(input, kernel_size, stride=[], padding=[], dilation=[], ceil_mode=False, *, out=None) ``` [#](#api-tensorplay.max_pool2d) ### max_pool2d function[Full reference ↗](/docs/generated/tensorplay.max_pool2d.html) ```python tensorplay.max_pool2d(input, kernel_size, stride=[], padding=[0, 0], dilation=[1, 1], ceil_mode=False) ``` [#](#api-tensorplay.max_pool3d_with_indices) ### max_pool3d_with_indices function[Full reference ↗](/docs/generated/tensorplay.max_pool3d_with_indices.html) ```python tensorplay.max_pool3d_with_indices(input, kernel_size, stride=[], padding=[], dilation=[], ceil_mode=False, *, out=None) ``` [#](#api-tensorplay.max_unpool2d) ### max_unpool2d function[Full reference ↗](/docs/generated/tensorplay.max_unpool2d.html) ```python tensorplay.max_unpool2d(input, indices, output_size, *, out=None) ``` [#](#api-tensorplay.max_unpool3d) ### max_unpool3d function[Full reference ↗](/docs/generated/tensorplay.max_unpool3d.html) ```python tensorplay.max_unpool3d(input, indices, output_size, stride, padding, *, out=None) ``` [#](#api-tensorplay.max) ### max function[Full reference ↗](/docs/generated/tensorplay.max.html) ```python tensorplay.max(input, *, out=None) → Tensor ``` Returns the maximum value of all elements in the input tensor. > **Note** > > The difference between max / min and amax / amin is: amax/amin supports reducing on multiple dimensions, amax/amin does not return indices. Both amax/amin evenly distribute gradients between equal values when there are multiple input elements with the same minimum or maximum value. For max / min : If reduce over all dimensions(no dim specified), gradients evenly distribute between equally max/min values. If reduce over one specified axis, only propagate to the indexed element. Parameters: input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor. Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. Example: ``` >>> a = tensorplay.randn(1, 3) >>> a tensor([[ 0.6763, 0.7445, -2.2369]]) >>> tensorplay.max(a) tensor(0.7445) ``` ```python tensorplay.max(input, dim, keepdim=False, *, out=None) ``` Returns a namedtuple (values, indices) where values is the maximum value of each row of the input tensor in the given dimension [dim](/docs/generated/tensorplay.dim.html#tensorplay.dim). And indices is the index location of each maximum value found (argmax). If keepdim is True, the output tensors are of the same size as input except in the dimension dim where they are of size 1. Otherwise, dim is squeezed (see tensorplay.squeeze()), resulting in the output tensors having 1 fewer dimension than input. > **Note** > > If there are multiple maximal values in a reduced row then the indices of the first maximal value are returned. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor. - dim ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – the dimension to reduce. If omitted, all dimensions are reduced. Explicit None is not supported. keepdim (bool, optional): whether the output tensor has [dim](/docs/generated/tensorplay.dim.html#tensorplay.dim) retained or not. Default: False. Keyword Arguments: out ([tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple), optional) – the result tuple of two output tensors (max, max_indices) Example: ``` >>> a = tensorplay.randn(4, 4) >>> a tensor([[-1.2360, -0.2942, -0.1222, 0.8475], [ 1.1949, -1.1127, -2.2379, -0.6702], [ 1.5717, -0.9207, 0.1297, -1.8768], [-0.6172, 1.0036, -0.6060, -0.2432]]) >>> tensorplay.max(a, 1) tensorplay.return_types.max(values=tensor([0.8475, 1.1949, 1.5717, 1.0036]), indices=tensor([3, 0, 0, 1])) >>> a = tensorplay.tensor([[1.0, 2.0], [3.0, 4.0]]) >>> a.max(dim=1, keepdim=True) tensorplay.return_types.max( values=tensor([[2.], [4.]]), indices=tensor([[1], [1]])) >>> a.max(dim=1, keepdim=False) tensorplay.return_types.max( values=tensor([2., 4.]), indices=tensor([1, 1])) ``` ```python tensorplay.max(input, other, *, out=None) → Tensor ``` See tensorplay.maximum(). [#](#api-tensorplay.mH) ### mH function[Full reference ↗](/docs/generated/tensorplay.mH.html) ```python tensorplay.mH(input) ``` [#](#api-tensorplay.min) ### min function[Full reference ↗](/docs/generated/tensorplay.min.html) ```python tensorplay.min(input, *, out=None) → Tensor ``` Returns the minimum value of all elements in the input tensor. > **Note** > > The difference between max / min and amax / amin is: amax/amin supports reducing on multiple dimensions, amax/amin does not return indices. Both amax/amin evenly distribute gradients between equal values when there are multiple input elements with the same minimum or maximum value. For max / min : If reduce over all dimensions(no dim specified), gradients evenly distribute between equally max/min values. If reduce over one specified axis, only propagate to the indexed element. Parameters: input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor. Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. Example: ``` >>> a = tensorplay.randn(1, 3) >>> a tensor([[ 0.6750, 1.0857, 1.7197]]) >>> tensorplay.min(a) tensor(0.6750) ``` ```python tensorplay.min(input, dim, keepdim=False, *, out=None) ``` Returns a namedtuple (values, indices) where values is the minimum value of each row of the input tensor in the given dimension [dim](/docs/generated/tensorplay.dim.html#tensorplay.dim). And indices is the index location of each minimum value found (argmin). If keepdim is True, the output tensors are of the same size as input except in the dimension [dim](/docs/generated/tensorplay.dim.html#tensorplay.dim) where they are of size 1. Otherwise, [dim](/docs/generated/tensorplay.dim.html#tensorplay.dim) is squeezed (see tensorplay.squeeze()), resulting in the output tensors having 1 fewer dimension than input. > **Note** > > If there are multiple minimal values in a reduced row then the indices of the first minimal value are returned. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor. - dim ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – the dimension to reduce. If omitted, all dimensions are reduced. Explicit None is not supported. keepdim (bool, optional): whether the output tensor has [dim](/docs/generated/tensorplay.dim.html#tensorplay.dim) retained or not. Default: False. Keyword Arguments: out ([tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple), optional) – the tuple of two output tensors (min, min_indices) Example: ``` >>> a = tensorplay.randn(4, 4) >>> a tensor([[-0.6248, 1.1334, -1.1899, -0.2803], [-1.4644, -0.2635, -0.3651, 0.6134], [ 0.2457, 0.0384, 1.0128, 0.7015], [-0.1153, 2.9849, 2.1458, 0.5788]]) >>> tensorplay.min(a, 1) tensorplay.return_types.min(values=tensor([-1.1899, -1.4644, 0.0384, -0.1153]), indices=tensor([2, 0, 1, 0])) ``` ```python tensorplay.min(input, other, *, out=None) → Tensor ``` See tensorplay.minimum(). [#](#api-tensorplay.mish_) ### mish_ function[Full reference ↗](/docs/generated/tensorplay.mish_.html) ```python tensorplay.mish_(input) ``` [#](#api-tensorplay.mish) ### mish function[Full reference ↗](/docs/generated/tensorplay.mish.html) ```python tensorplay.mish(input, *, out=None) ``` [#](#api-tensorplay.mkldnn_linear_backward_input) ### mkldnn_linear_backward_input function[Full reference ↗](/docs/generated/tensorplay.mkldnn_linear_backward_input.html) ```python tensorplay.mkldnn_linear_backward_input(input_size, grad_output, weight) ``` [#](#api-tensorplay.mkldnn_linear) ### mkldnn_linear function[Full reference ↗](/docs/generated/tensorplay.mkldnn_linear.html) ```python tensorplay.mkldnn_linear(input, weight, bias=None) ``` [#](#api-tensorplay.mkldnn_reorder_conv2d_weight) ### mkldnn_reorder_conv2d_weight function[Full reference ↗](/docs/generated/tensorplay.mkldnn_reorder_conv2d_weight.html) ```python tensorplay.mkldnn_reorder_conv2d_weight(input, padding=0, stride=1, dilation=1, groups=1, input_size=None) ``` [#](#api-tensorplay.mkldnn_reorder_conv3d_weight) ### mkldnn_reorder_conv3d_weight function[Full reference ↗](/docs/generated/tensorplay.mkldnn_reorder_conv3d_weight.html) ```python tensorplay.mkldnn_reorder_conv3d_weight(input, padding=0, stride=1, dilation=1, groups=1, input_size=None) ``` [#](#api-tensorplay.modified_bessel_i0) ### modified_bessel_i0 function[Full reference ↗](/docs/generated/tensorplay.modified_bessel_i0.html) ```python tensorplay.modified_bessel_i0(input) ``` [#](#api-tensorplay.modified_bessel_i1) ### modified_bessel_i1 function[Full reference ↗](/docs/generated/tensorplay.modified_bessel_i1.html) ```python tensorplay.modified_bessel_i1(input) ``` [#](#api-tensorplay.modified_bessel_k0) ### modified_bessel_k0 function[Full reference ↗](/docs/generated/tensorplay.modified_bessel_k0.html) ```python tensorplay.modified_bessel_k0(input) ``` [#](#api-tensorplay.modified_bessel_k1) ### modified_bessel_k1 function[Full reference ↗](/docs/generated/tensorplay.modified_bessel_k1.html) ```python tensorplay.modified_bessel_k1(input) ``` [#](#api-tensorplay.mse_loss) ### mse_loss function[Full reference ↗](/docs/generated/tensorplay.mse_loss.html) ```python tensorplay.mse_loss(input, target, reduction=1, *, out=None) ``` [#](#api-tensorplay.mT) ### mT function[Full reference ↗](/docs/generated/tensorplay.mT.html) ```python tensorplay.mT(input) ``` [#](#api-tensorplay.mul_) ### mul_ function[Full reference ↗](/docs/generated/tensorplay.mul_.html) ```python tensorplay.mul_(input, other) ``` [#](#api-tensorplay.multi_margin_loss) ### multi_margin_loss function[Full reference ↗](/docs/generated/tensorplay.multi_margin_loss.html) ```python tensorplay.multi_margin_loss(input, target, p=1, margin=1, weight=None, reduction=1, *, out=None) ``` [#](#api-tensorplay.multilabel_margin_loss_forward) ### multilabel_margin_loss_forward function[Full reference ↗](/docs/generated/tensorplay.multilabel_margin_loss_forward.html) ```python tensorplay.multilabel_margin_loss_forward(input, target, reduction, *, out=None) ``` [#](#api-tensorplay.multilabel_margin_loss) ### multilabel_margin_loss function[Full reference ↗](/docs/generated/tensorplay.multilabel_margin_loss.html) ```python tensorplay.multilabel_margin_loss(input, target, reduction=1, *, out=None) ``` [#](#api-tensorplay.multilabel_soft_margin_loss) ### multilabel_soft_margin_loss function[Full reference ↗](/docs/generated/tensorplay.multilabel_soft_margin_loss.html) ```python tensorplay.multilabel_soft_margin_loss(input, target) ``` [#](#api-tensorplay.multiply_) ### multiply_ function[Full reference ↗](/docs/generated/tensorplay.multiply_.html) ```python tensorplay.multiply_(input, other) ``` [#](#api-tensorplay.mvlgamma_) ### mvlgamma_ function[Full reference ↗](/docs/generated/tensorplay.mvlgamma_.html) ```python tensorplay.mvlgamma_(input, p) ``` [#](#api-tensorplay.native_alpha_dropout) ### native_alpha_dropout function[Full reference ↗](/docs/generated/tensorplay.native_alpha_dropout.html) ```python tensorplay.native_alpha_dropout(input, p) ``` [#](#api-tensorplay.native_dropout) ### native_dropout function[Full reference ↗](/docs/generated/tensorplay.native_dropout.html) ```python tensorplay.native_dropout(input, p, train) ``` [#](#api-tensorplay.native_feature_dropout) ### native_feature_dropout function[Full reference ↗](/docs/generated/tensorplay.native_feature_dropout.html) ```python tensorplay.native_feature_dropout(input, p) ``` [#](#api-tensorplay.ndtr) ### ndtr function[Full reference ↗](/docs/generated/tensorplay.ndtr.html) ```python tensorplay.ndtr(input) ``` [#](#api-tensorplay.ndtri) ### ndtri function[Full reference ↗](/docs/generated/tensorplay.ndtri.html) ```python tensorplay.ndtri(input) ``` [#](#api-tensorplay.ne_) ### ne_ function[Full reference ↗](/docs/generated/tensorplay.ne_.html) ```python tensorplay.ne_(input, other) ``` [#](#api-tensorplay.nested_to_padded_tensor) ### nested_to_padded_tensor function[Full reference ↗](/docs/generated/tensorplay.nested_to_padded_tensor.html) ```python tensorplay.nested_to_padded_tensor(input, padding, output_size=None) ``` [#](#api-tensorplay.new_empty_strided) ### new_empty_strided function[Full reference ↗](/docs/generated/tensorplay.new_empty_strided.html) ```python tensorplay.new_empty_strided(input, size, stride, dtype=None, layout=None, device=None, pin_memory=None) ``` [#](#api-tensorplay.new_empty) ### new_empty function[Full reference ↗](/docs/generated/tensorplay.new_empty.html) ```python tensorplay.new_empty(input, size, dtype=None, layout=None, device=None, pin_memory=None) ``` [#](#api-tensorplay.new_full) ### new_full function[Full reference ↗](/docs/generated/tensorplay.new_full.html) ```python tensorplay.new_full(input, size, fill_value, dtype=None, layout=None, device=None, pin_memory=None) ``` [#](#api-tensorplay.new_ones) ### new_ones function[Full reference ↗](/docs/generated/tensorplay.new_ones.html) ```python tensorplay.new_ones(input, size, dtype=None, layout=None, device=None, pin_memory=None) ``` [#](#api-tensorplay.new_zeros) ### new_zeros function[Full reference ↗](/docs/generated/tensorplay.new_zeros.html) ```python tensorplay.new_zeros(input, size, dtype=None, layout=None, device=None, pin_memory=None) ``` [#](#api-tensorplay.nextafter_) ### nextafter_ function[Full reference ↗](/docs/generated/tensorplay.nextafter_.html) ```python tensorplay.nextafter_(input, other) ``` [#](#api-tensorplay.nll_loss_forward) ### nll_loss_forward function[Full reference ↗](/docs/generated/tensorplay.nll_loss_forward.html) ```python tensorplay.nll_loss_forward(input, target, weight, reduction, ignore_index, *, out=None) ``` [#](#api-tensorplay.nll_loss_nd) ### nll_loss_nd function[Full reference ↗](/docs/generated/tensorplay.nll_loss_nd.html) ```python tensorplay.nll_loss_nd(input, target, weight=None, reduction=1, ignore_index=-100) ``` [#](#api-tensorplay.nll_loss) ### nll_loss function[Full reference ↗](/docs/generated/tensorplay.nll_loss.html) ```python tensorplay.nll_loss(input, target, weight=None, reduction=1, ignore_index=-100, *, out=None) ``` [#](#api-tensorplay.nll_loss2d_forward) ### nll_loss2d_forward function[Full reference ↗](/docs/generated/tensorplay.nll_loss2d_forward.html) ```python tensorplay.nll_loss2d_forward(input, target, weight, reduction, ignore_index, *, out=None) ``` [#](#api-tensorplay.nll_loss2d) ### nll_loss2d function[Full reference ↗](/docs/generated/tensorplay.nll_loss2d.html) ```python tensorplay.nll_loss2d(input, target, weight=None, reduction=1, ignore_index=-100, *, out=None) ``` [#](#api-tensorplay.nonzero_numpy) ### nonzero_numpy function[Full reference ↗](/docs/generated/tensorplay.nonzero_numpy.html) ```python tensorplay.nonzero_numpy(input) ``` [#](#api-tensorplay.normal_) ### normal_ function[Full reference ↗](/docs/generated/tensorplay.normal_.html) ```python tensorplay.normal_(input, mean=0.0, std=1.0, generator=None) ``` [#](#api-tensorplay.normal_functional) ### normal_functional function[Full reference ↗](/docs/generated/tensorplay.normal_functional.html) ```python tensorplay.normal_functional(input, mean=0, std=1, generator=None) ``` [#](#api-tensorplay.not_equal_) ### not_equal_ function[Full reference ↗](/docs/generated/tensorplay.not_equal_.html) ```python tensorplay.not_equal_(input, other) ``` [#](#api-tensorplay.numpy_T) ### numpy_T function[Full reference ↗](/docs/generated/tensorplay.numpy_T.html) ```python tensorplay.numpy_T(input) ``` [#](#api-tensorplay.one_hot) ### one_hot function[Full reference ↗](/docs/generated/tensorplay.one_hot.html) ```python tensorplay.one_hot(input, num_classes=-1) ``` [#](#api-tensorplay.ones) ### ones function[Full reference ↗](/docs/generated/tensorplay.ones.html) ```python tensorplay.ones(\*size, \*, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False) → Tensor ``` Returns a tensor filled with the scalar value 1, with the shape defined by the variable argument [size](/docs/generated/tensorplay.size.html#tensorplay.size). Parameters: size ([int](https://docs.python.org/3/builtins/functions.html#int)...) – a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple. Keyword Arguments: - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, uses a global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout (tensorplay.layout, optional) – the desired layout of returned Tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. Example: ``` >>> tensorplay.ones(2, 3) tensor([[ 1., 1., 1.], [ 1., 1., 1.]]) >>> tensorplay.ones(5) tensor([ 1., 1., 1., 1., 1.]) ``` [#](#api-tensorplay.output_nr) ### output_nr function[Full reference ↗](/docs/generated/tensorplay.output_nr.html) ```python tensorplay.output_nr(input) ``` [#](#api-tensorplay.pad_sequence) ### pad_sequence function[Full reference ↗](/docs/generated/tensorplay.pad_sequence.html) ```python tensorplay.pad_sequence(sequences, batch_first=False, padding_value=0.0, padding_side='right') ``` [#](#api-tensorplay.pad) ### pad function[Full reference ↗](/docs/generated/tensorplay.pad.html) ```python tensorplay.pad(input, pad, mode='constant', value=None) ``` [#](#api-tensorplay.pin_memory) ### pin_memory function[Full reference ↗](/docs/generated/tensorplay.pin_memory.html) ```python tensorplay.pin_memory(input, device=None) ``` [#](#api-tensorplay.pixel_shuffle) ### pixel_shuffle function[Full reference ↗](/docs/generated/tensorplay.pixel_shuffle.html) ```python tensorplay.pixel_shuffle(input, upscale_factor) ``` [#](#api-tensorplay.polygamma_) ### polygamma_ function[Full reference ↗](/docs/generated/tensorplay.polygamma_.html) ```python tensorplay.polygamma_(input, n) ``` [#](#api-tensorplay.pow_) ### pow_ function[Full reference ↗](/docs/generated/tensorplay.pow_.html) ```python tensorplay.pow_(input, exponent) ``` [#](#api-tensorplay.put_) ### put_ function[Full reference ↗](/docs/generated/tensorplay.put_.html) ```python tensorplay.put_(input, index, source, accumulate=False) ``` [#](#api-tensorplay.qscheme) ### qscheme function[Full reference ↗](/docs/generated/tensorplay.qscheme.html) ```python tensorplay.qscheme(input) ``` [#](#api-tensorplay.quantized_add) ### quantized_add function[Full reference ↗](/docs/generated/tensorplay.quantized_add.html) ```python tensorplay.quantized_add(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point) ``` [#](#api-tensorplay.quantized_clamp) ### quantized_clamp function[Full reference ↗](/docs/generated/tensorplay.quantized_clamp.html) ```python tensorplay.quantized_clamp(input, self_scale, self_zero_point, out_scale, out_zero_point, min=None, max=None) ``` [#](#api-tensorplay.quantized_conv2d_prepack) ### quantized_conv2d_prepack function[Full reference ↗](/docs/generated/tensorplay.quantized_conv2d_prepack.html) ```python tensorplay.quantized_conv2d_prepack(weight, weight_scales, weight_zero_points, bias=None, transposed=False) ``` [#](#api-tensorplay.quantized_conv2d_run) ### quantized_conv2d_run function[Full reference ↗](/docs/generated/tensorplay.quantized_conv2d_run.html) ```python tensorplay.quantized_conv2d_run(input, weight_packed, bias_packed, weight_sizes, input_scale, input_zero_point, out_scale, out_zero_point, stride=1, padding=0, dilation=1, output_padding=0, groups=1, transposed=False, output_min=None, output_max=None) ``` [#](#api-tensorplay.quantized_conv2d_unpack) ### quantized_conv2d_unpack function[Full reference ↗](/docs/generated/tensorplay.quantized_conv2d_unpack.html) ```python tensorplay.quantized_conv2d_unpack(weight_packed, bias_packed, weight_sizes, transposed=False, depthwise=False) ``` [#](#api-tensorplay.quantized_conv2d) ### quantized_conv2d function[Full reference ↗](/docs/generated/tensorplay.quantized_conv2d.html) ```python tensorplay.quantized_conv2d(input, weight, bias, input_scale, input_zero_point, weight_scale, weight_zero_point, out_scale, out_zero_point, stride=1, padding=0, dilation=1, groups=1) ``` [#](#api-tensorplay.quantized_div) ### quantized_div function[Full reference ↗](/docs/generated/tensorplay.quantized_div.html) ```python tensorplay.quantized_div(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point) ``` [#](#api-tensorplay.quantized_linear) ### quantized_linear function[Full reference ↗](/docs/generated/tensorplay.quantized_linear.html) ```python tensorplay.quantized_linear(input, weight, input_scale, input_zero_point, weight_scales, weight_zero_points, bias=None, out_scale=1.0, out_zero_point=0) ``` [#](#api-tensorplay.quantized_mul) ### quantized_mul function[Full reference ↗](/docs/generated/tensorplay.quantized_mul.html) ```python tensorplay.quantized_mul(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point) ``` [#](#api-tensorplay.quantized_sub) ### quantized_sub function[Full reference ↗](/docs/generated/tensorplay.quantized_sub.html) ```python tensorplay.quantized_sub(a, b, a_scale, a_zero_point, b_scale, b_zero_point, out_scale, out_zero_point) ``` [#](#api-tensorplay.rand) ### rand function[Full reference ↗](/docs/generated/tensorplay.rand.html) ```python tensorplay.rand() ``` rand(*size, *, generator=None, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False, pin_memory=False) -> Tensor Returns a tensor filled with random numbers from a uniform distribution on the interval $[0, 1)$ The shape of the tensor is defined by the variable argument [size](/docs/generated/tensorplay.size.html#tensorplay.size). Parameters: size ([int](https://docs.python.org/3/builtins/functions.html#int)...) – a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple. Keyword Arguments: - generator ([tensorplay.Generator](/docs/generated/tensorplay.Generator.html#tensorplay.Generator), optional) – a pseudorandom number generator for sampling - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, uses a global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout (tensorplay.layout, optional) – the desired layout of returned Tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. - pin_memory ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False. Example: ``` >>> tensorplay.rand(4) tensor([ 0.5204, 0.2503, 0.3525, 0.5673]) >>> tensorplay.rand(2, 3) tensor([[ 0.8237, 0.5781, 0.6879], [ 0.3816, 0.7249, 0.0998]]) ``` [#](#api-tensorplay.randn) ### randn function[Full reference ↗](/docs/generated/tensorplay.randn.html) ```python tensorplay.randn() ``` randn(*size, *, generator=None, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False, pin_memory=False) -> Tensor Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution). $$\text{out}_{i} \sim \mathcal{N}(0, 1)$$ For complex dtypes, the tensor is i.i.d. sampled from a [complex normal distribution](https://en.wikipedia.org/wiki/Complex_normal_distribution) with zero mean and unit variance as $$\text{out}_{i} \sim \mathcal{CN}(0, 1)$$ This is equivalent to separately sampling the real $(\operatorname{Re})$ and imaginary $(\operatorname{Im})$ part of $\text{out}_i$ as $$\operatorname{Re}(\text{out}_{i}) \sim \mathcal{N}(0, \frac{1}{2}),\quad \operatorname{Im}(\text{out}_{i}) \sim \mathcal{N}(0, \frac{1}{2})$$ The shape of the tensor is defined by the variable argument [size](/docs/generated/tensorplay.size.html#tensorplay.size). Parameters: size ([int](https://docs.python.org/3/builtins/functions.html#int)...) – a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple. Keyword Arguments: - generator ([tensorplay.Generator](/docs/generated/tensorplay.Generator.html#tensorplay.Generator), optional) – a pseudorandom number generator for sampling - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, uses a global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout (tensorplay.layout, optional) – the desired layout of returned Tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. - pin_memory ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False. Example: ``` >>> tensorplay.randn(4) tensor([-2.1436, 0.9966, 2.3426, -0.6366]) >>> tensorplay.randn(2, 3) tensor([[ 1.5954, 2.8929, -1.0923], [ 1.1719, -0.4709, -0.1996]]) ``` [#](#api-tensorplay.random_) ### random_ function[Full reference ↗](/docs/generated/tensorplay.random_.html) ```python tensorplay.random_(input, generator=None) ``` [#](#api-tensorplay.reflection_pad_nd) ### reflection_pad_nd function[Full reference ↗](/docs/generated/tensorplay.reflection_pad_nd.html) ```python tensorplay.reflection_pad_nd(input, pad) ``` [#](#api-tensorplay.reflection_pad1d) ### reflection_pad1d function[Full reference ↗](/docs/generated/tensorplay.reflection_pad1d.html) ```python tensorplay.reflection_pad1d(input, padding, *, out=None) ``` [#](#api-tensorplay.reflection_pad2d) ### reflection_pad2d function[Full reference ↗](/docs/generated/tensorplay.reflection_pad2d.html) ```python tensorplay.reflection_pad2d(input, padding, *, out=None) ``` [#](#api-tensorplay.reflection_pad3d) ### reflection_pad3d function[Full reference ↗](/docs/generated/tensorplay.reflection_pad3d.html) ```python tensorplay.reflection_pad3d(input, padding, *, out=None) ``` [#](#api-tensorplay.relu) ### relu function[Full reference ↗](/docs/generated/tensorplay.relu.html) ```python tensorplay.relu(input) ``` [#](#api-tensorplay.relu6_) ### relu6_ function[Full reference ↗](/docs/generated/tensorplay.relu6_.html) ```python tensorplay.relu6_(input) ``` [#](#api-tensorplay.relu6) ### relu6 function[Full reference ↗](/docs/generated/tensorplay.relu6.html) ```python tensorplay.relu6(input) ``` [#](#api-tensorplay.remainder_) ### remainder_ function[Full reference ↗](/docs/generated/tensorplay.remainder_.html) ```python tensorplay.remainder_(input, other) ``` [#](#api-tensorplay.renorm_) ### renorm_ function[Full reference ↗](/docs/generated/tensorplay.renorm_.html) ```python tensorplay.renorm_(input, p, dim, maxnorm) ``` [#](#api-tensorplay.repeat) ### repeat function[Full reference ↗](/docs/generated/tensorplay.repeat.html) ```python tensorplay.repeat(input, repeats) ``` [#](#api-tensorplay.replication_pad_nd) ### replication_pad_nd function[Full reference ↗](/docs/generated/tensorplay.replication_pad_nd.html) ```python tensorplay.replication_pad_nd(input, pad) ``` [#](#api-tensorplay.replication_pad1d) ### replication_pad1d function[Full reference ↗](/docs/generated/tensorplay.replication_pad1d.html) ```python tensorplay.replication_pad1d(input, padding, *, out=None) ``` [#](#api-tensorplay.replication_pad2d) ### replication_pad2d function[Full reference ↗](/docs/generated/tensorplay.replication_pad2d.html) ```python tensorplay.replication_pad2d(input, padding, *, out=None) ``` [#](#api-tensorplay.replication_pad3d) ### replication_pad3d function[Full reference ↗](/docs/generated/tensorplay.replication_pad3d.html) ```python tensorplay.replication_pad3d(input, padding, *, out=None) ``` [#](#api-tensorplay.requires_grad_) ### requires_grad_ function[Full reference ↗](/docs/generated/tensorplay.requires_grad_.html) ```python tensorplay.requires_grad_(input, requires_grad=True) ``` [#](#api-tensorplay.reshape_as) ### reshape_as function[Full reference ↗](/docs/generated/tensorplay.reshape_as.html) ```python tensorplay.reshape_as(input, other) ``` [#](#api-tensorplay.resize_) ### resize_ function[Full reference ↗](/docs/generated/tensorplay.resize_.html) ```python tensorplay.resize_(input, size) ``` [#](#api-tensorplay.retain_grad) ### retain_grad function[Full reference ↗](/docs/generated/tensorplay.retain_grad.html) ```python tensorplay.retain_grad(input) ``` [#](#api-tensorplay.retains_grad) ### retains_grad function[Full reference ↗](/docs/generated/tensorplay.retains_grad.html) ```python tensorplay.retains_grad(input) ``` [#](#api-tensorplay.rotary_embedding) ### rotary_embedding function[Full reference ↗](/docs/generated/tensorplay.rotary_embedding.html) ```python tensorplay.rotary_embedding(input, cos, sin, position_offset=0) ``` [#](#api-tensorplay.row_indices) ### row_indices function[Full reference ↗](/docs/generated/tensorplay.row_indices.html) ```python tensorplay.row_indices(input) ``` [#](#api-tensorplay.rrelu_with_noise_) ### rrelu_with_noise_ function[Full reference ↗](/docs/generated/tensorplay.rrelu_with_noise_.html) ```python tensorplay.rrelu_with_noise_(input, noise, lower=0.125, upper=0.3333333333333333, training=False, generator=None) ``` [#](#api-tensorplay.rrelu_with_noise) ### rrelu_with_noise function[Full reference ↗](/docs/generated/tensorplay.rrelu_with_noise.html) ```python tensorplay.rrelu_with_noise(input, noise, lower=0.125, upper=0.3333333333333333, training=False, generator=None, *, out=None) ``` [#](#api-tensorplay.sample) ### sample function[Full reference ↗](/docs/generated/tensorplay.sample.html) ```python tensorplay.sample(logits, temperature=1.0, top_k=0, top_p=1.0, impl=0) ``` [#](#api-tensorplay.scaled_dot_product_attention) ### scaled_dot_product_attention function[Full reference ↗](/docs/generated/tensorplay.scaled_dot_product_attention.html) ```python tensorplay.scaled_dot_product_attention(query, key, value, attn_mask=None, dropout_p=0.0, is_causal=False, scale=None, enable_gqa=False) ``` [#](#api-tensorplay.scaled_modified_bessel_k0) ### scaled_modified_bessel_k0 function[Full reference ↗](/docs/generated/tensorplay.scaled_modified_bessel_k0.html) ```python tensorplay.scaled_modified_bessel_k0(input) ``` [#](#api-tensorplay.scaled_modified_bessel_k1) ### scaled_modified_bessel_k1 function[Full reference ↗](/docs/generated/tensorplay.scaled_modified_bessel_k1.html) ```python tensorplay.scaled_modified_bessel_k1(input) ``` [#](#api-tensorplay.scatter_) ### scatter_ function[Full reference ↗](/docs/generated/tensorplay.scatter_.html) ```python tensorplay.scatter_(input, dim, index, src) ``` [#](#api-tensorplay.scatter_add_) ### scatter_add_ function[Full reference ↗](/docs/generated/tensorplay.scatter_add_.html) ```python tensorplay.scatter_add_(input, dim, index, src) ``` [#](#api-tensorplay.scatter_reduce_) ### scatter_reduce_ function[Full reference ↗](/docs/generated/tensorplay.scatter_reduce_.html) ```python tensorplay.scatter_reduce_(input, dim, index, src, reduce, include_self=True) ``` [#](#api-tensorplay.seed) ### seed function[Full reference ↗](/docs/generated/tensorplay.seed.html) ```python tensorplay.seed() → int ``` [#](#api-tensorplay.set_) ### set_ function[Full reference ↗](/docs/generated/tensorplay.set_.html) ```python tensorplay.set_(input, source) ``` [#](#api-tensorplay.set_autocast_cache_enabled) ### set_autocast_cache_enabled function[Full reference ↗](/docs/generated/tensorplay.set_autocast_cache_enabled.html) ```python tensorplay.set_autocast_cache_enabled(enabled: bool) → None ``` [#](#api-tensorplay.set_autocast_dtype) ### set_autocast_dtype function[Full reference ↗](/docs/generated/tensorplay.set_autocast_dtype.html) ```python tensorplay.set_autocast_dtype(device_type: str, dtype: tensorplay._C.DType) → None ``` [#](#api-tensorplay.set_autocast_enabled) ### set_autocast_enabled function[Full reference ↗](/docs/generated/tensorplay.set_autocast_enabled.html) ```python tensorplay.set_autocast_enabled(device_type: str, enabled: bool) → None ``` [#](#api-tensorplay.set_data) ### set_data function[Full reference ↗](/docs/generated/tensorplay.set_data.html) ```python tensorplay.set_data(input, new_data) ``` [#](#api-tensorplay.set_default_device) ### set_default_device function[Full reference ↗](/docs/generated/tensorplay.set_default_device.html) ```python tensorplay.set_default_device(device: device) → None ``` Sets the default tensorplay.Tensor to be allocated on device. This does not affect factory function calls which are called with an explicit device argument. Factory calls will be performed as if they were passed device as an argument. To only temporarily change the default device instead of setting it globally, use with tensorplay.device(device): instead. The default device is initially cpu. If you set the default tensor device to another device (e.g., cuda) without a device index, tensors will be allocated on whatever the current device for the device type, even after [tensorplay.cuda.set_device()](/docs/generated/tensorplay.cuda.set_device.html#tensorplay.cuda.set_device) is called. > **Warning** > > This function imposes a slight performance cost on every Python call to the tensorplay API (not just factory functions). > **Note** > > This doesn’t affect functions that create tensors that share the same memory as the input, like: tensorplay.from_numpy() and tensorplay.frombuffer() Parameters: device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), str, int, or None) – the device to set as default, or None to clear the override. An integer is interpreted as an index for the current accelerator. Example: ``` >>> # xdoctest: +SKIP("requires cuda, changes global state") >>> tensorplay.get_default_device() device(type='cpu') >>> tensorplay.set_default_device('cuda') # current device is 0 >>> tensorplay.get_default_device() device(type='cuda', index=0) >>> tensorplay.set_default_device('cuda') >>> tensorplay.cuda.set_device('cuda:1') # current device is 1 >>> tensorplay.get_default_device() device(type='cuda', index=1) >>> tensorplay.set_default_device('cuda:1') >>> tensorplay.get_default_device() device(type='cuda', index=1) ``` [#](#api-tensorplay.set_default_dtype) ### set_default_dtype function[Full reference ↗](/docs/generated/tensorplay.set_default_dtype.html) ```python tensorplay.set_default_dtype(d: dtype, /) → None ``` Sets the default floating point dtype to d. Supports floating point dtype as inputs. Other dtypes will cause tensorplay to raise an exception. When TensorPlay is initialized its default floating point dtype is float32, and the intent of set_default_dtype(float64) is to facilitate NumPy-like type inference. The default floating point dtype is used to: - Implicitly determine the default complex dtype. When the default floating type is float16, the default complex dtype is complex32. For float32, the default complex dtype is complex64. For float64, it is complex128. For bfloat16, an exception will be raised because there is no corresponding complex type for bfloat16. - Infer the dtype for tensors constructed using Python floats or complex Python numbers. See examples below. - Determine the result of type promotion between bool and integer tensors and Python floats and complex Python numbers. Parameters: d ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType)) – the floating point dtype to make the default. Example ``` >>> # xdoctest: +SKIP("Other tests may have changed the default type. Can we reset it?") >>> # initial default for floating point is float32 >>> # Python floats are interpreted as float32 >>> tensorplay.tensor([1.2, 3]).dtype tensorplay.float32 >>> # initial default for floating point is complex64 >>> # Complex Python numbers are interpreted as complex64 >>> tensorplay.tensor([1.2, 3j]).dtype tensorplay.complex64 ``` ``` >>> tensorplay.set_default_dtype(tensorplay.float64) >>> # Python floats are now interpreted as float64 >>> tensorplay.tensor([1.2, 3]).dtype # a new floating point tensor tensorplay.float64 >>> # Complex Python numbers are now interpreted as complex128 >>> tensorplay.tensor([1.2, 3j]).dtype # a new complex tensor tensorplay.complex128 ``` ``` >>> tensorplay.set_default_dtype(tensorplay.float16) >>> # Python floats are now interpreted as float16 >>> tensorplay.tensor([1.2, 3]).dtype # a new floating point tensor tensorplay.float16 >>> # Complex Python numbers are now interpreted as complex128 >>> tensorplay.tensor([1.2, 3j]).dtype # a new complex tensor tensorplay.complex32 ``` [#](#api-tensorplay.set_deterministic_debug_mode) ### set_deterministic_debug_mode function[Full reference ↗](/docs/generated/tensorplay.set_deterministic_debug_mode.html) ```python tensorplay.set_deterministic_debug_mode(debug_mode: int | str) → None ``` Sets the debug mode for deterministic operations. > **Note** > > This is an alternative interface for tensorplay.use_deterministic_algorithms(). Refer to that function’s documentation for details about affected operations. Parameters: debug_mode ([str](https://docs.python.org/3/builtins/stdtypes.html#str) or [int](https://docs.python.org/3/builtins/functions.html#int)) – If “default” or 0, don’t error or warn on nondeterministic operations. If “warn” or 1, warn on nondeterministic operations. If “error” or 2, error on nondeterministic operations. [#](#api-tensorplay.set_float32_matmul_precision) ### set_float32_matmul_precision function[Full reference ↗](/docs/generated/tensorplay.set_float32_matmul_precision.html) ```python tensorplay.set_float32_matmul_precision(precision: str) → None ``` Sets the internal precision of float32 matrix multiplications. Running float32 matrix multiplications in lower precision may significantly increase performance, and in some programs the loss of precision has a negligible impact. Supports three settings: - “highest”, float32 matrix multiplications use the float32 datatype (24 mantissa bits with 23 bits explicitly stored) for internal computations. - “high”, float32 matrix multiplications either use the TensorFloat32 datatype (10 mantissa bits explicitly stored) or treat each float32 number as the sum of two bfloat16 numbers (approximately 16 mantissa bits with 14 bits explicitly stored), if the appropriate fast matrix multiplication algorithms are available. Otherwise float32 matrix multiplications are computed as if the precision is “highest”. See below for more information on the bfloat16 approach. - “medium”, float32 matrix multiplications use the bfloat16 datatype (8 mantissa bits with 7 bits explicitly stored) for internal computations, if a fast matrix multiplication algorithm using that datatype internally is available. Otherwise float32 matrix multiplications are computed as if the precision is “high”. > **Note** > > This does not change the output dtype of float32 matrix multiplications, it controls how the internal computation of the matrix multiplication is performed. > **Note** > > This does not change the precision of convolution operations. Other flags, like tensorplay.backends.cudnn.allow_tf32, may control the precision of convolution operations. > **Note** > > This flag currently only affects one native device type: CUDA. If “high” or “medium” are set then the TensorFloat32 datatype will be used when computing float32 matrix multiplications, equivalent to setting tensorplay.backends.cuda.matmul.allow_tf32 = True. When “highest” (the default) is set then the float32 datatype is used for internal computations, equivalent to setting tensorplay.backends.cuda.matmul.allow_tf32 = False. Parameters: precision ([str](https://docs.python.org/3/builtins/stdtypes.html#str)) – can be set to “highest” (default), “high”, or “medium” (see above). [#](#api-tensorplay.set_num_threads) ### set_num_threads function[Full reference ↗](/docs/generated/tensorplay.set_num_threads.html) ```python tensorplay.set_num_threads(int) ``` Sets the number of threads used for intraop parallelism on CPU. > **Warning** > > To ensure that the correct number of threads is used, set_num_threads must be called before running eager, JIT or autograd code. [#](#api-tensorplay.set_printoptions) ### set_printoptions function[Full reference ↗](/docs/generated/tensorplay.set_printoptions.html) ```python tensorplay.set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, edge_items=None, **kwargs) ``` Set printing options for tensor output. Parameters: - precision ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – digits after the decimal point. - threshold ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – total elements above which large tensors are summarized instead of printed fully. - edgeitems ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – edge items printed per dimension when summarizing. edge_items is accepted as an alias. - linewidth ([int](https://docs.python.org/3/builtins/functions.html#int), optional) – line width for wrapping output. Unset (None) arguments keep their current values. [#](#api-tensorplay.set_rng_state) ### set_rng_state function[Full reference ↗](/docs/generated/tensorplay.set_rng_state.html) ```python tensorplay.set_rng_state(new_state: tensorplay::Tensor) → None ``` [#](#api-tensorplay.sgn_) ### sgn_ function[Full reference ↗](/docs/generated/tensorplay.sgn_.html) ```python tensorplay.sgn_(input) ``` [#](#api-tensorplay.shifted_chebyshev_polynomial_t) ### shifted_chebyshev_polynomial_t function[Full reference ↗](/docs/generated/tensorplay.shifted_chebyshev_polynomial_t.html) ```python tensorplay.shifted_chebyshev_polynomial_t(x, n) ``` [#](#api-tensorplay.shifted_chebyshev_polynomial_u) ### shifted_chebyshev_polynomial_u function[Full reference ↗](/docs/generated/tensorplay.shifted_chebyshev_polynomial_u.html) ```python tensorplay.shifted_chebyshev_polynomial_u(x, n) ``` [#](#api-tensorplay.shifted_chebyshev_polynomial_v) ### shifted_chebyshev_polynomial_v function[Full reference ↗](/docs/generated/tensorplay.shifted_chebyshev_polynomial_v.html) ```python tensorplay.shifted_chebyshev_polynomial_v(x, n) ``` [#](#api-tensorplay.shifted_chebyshev_polynomial_w) ### shifted_chebyshev_polynomial_w function[Full reference ↗](/docs/generated/tensorplay.shifted_chebyshev_polynomial_w.html) ```python tensorplay.shifted_chebyshev_polynomial_w(x, n) ``` [#](#api-tensorplay.sign_) ### sign_ function[Full reference ↗](/docs/generated/tensorplay.sign_.html) ```python tensorplay.sign_(input) ``` [#](#api-tensorplay.silu_) ### silu_ function[Full reference ↗](/docs/generated/tensorplay.silu_.html) ```python tensorplay.silu_(input) ``` [#](#api-tensorplay.silu_and_mul) ### silu_and_mul function[Full reference ↗](/docs/generated/tensorplay.silu_and_mul.html) ```python tensorplay.silu_and_mul(input) ``` [#](#api-tensorplay.silu_mul) ### silu_mul function[Full reference ↗](/docs/generated/tensorplay.silu_mul.html) ```python tensorplay.silu_mul(gate, up) ``` [#](#api-tensorplay.silu) ### silu function[Full reference ↗](/docs/generated/tensorplay.silu.html) ```python tensorplay.silu(input, *, out=None) ``` [#](#api-tensorplay.size) ### size function[Full reference ↗](/docs/generated/tensorplay.size.html) ```python tensorplay.size(input) ``` [#](#api-tensorplay.slice) ### slice function[Full reference ↗](/docs/generated/tensorplay.slice.html) ```python tensorplay.slice(input, dim=0, start=None, end=None, step=1) ``` [#](#api-tensorplay.slow_conv_dilated2d) ### slow_conv_dilated2d function[Full reference ↗](/docs/generated/tensorplay.slow_conv_dilated2d.html) ```python tensorplay.slow_conv_dilated2d(input, weight, kernel_size, bias=None, stride=1, padding=0, dilation=1) ``` [#](#api-tensorplay.slow_conv_dilated3d) ### slow_conv_dilated3d function[Full reference ↗](/docs/generated/tensorplay.slow_conv_dilated3d.html) ```python tensorplay.slow_conv_dilated3d(input, weight, kernel_size, bias=None, stride=1, padding=0, dilation=1) ``` [#](#api-tensorplay.slow_conv_transpose2d) ### slow_conv_transpose2d function[Full reference ↗](/docs/generated/tensorplay.slow_conv_transpose2d.html) ```python tensorplay.slow_conv_transpose2d(input, weight, kernel_size, bias=None, stride=1, padding=0, output_padding=0, dilation=1, *, out=None) ``` [#](#api-tensorplay.slow_conv_transpose3d) ### slow_conv_transpose3d function[Full reference ↗](/docs/generated/tensorplay.slow_conv_transpose3d.html) ```python tensorplay.slow_conv_transpose3d(input, weight, kernel_size, bias=None, stride=1, padding=0, output_padding=0, dilation=1, *, out=None) ``` [#](#api-tensorplay.slow_conv3d_forward) ### slow_conv3d_forward function[Full reference ↗](/docs/generated/tensorplay.slow_conv3d_forward.html) ```python tensorplay.slow_conv3d_forward(input, weight, kernel_size, bias, stride, padding, *, out=None) ``` [#](#api-tensorplay.slow_conv3d) ### slow_conv3d function[Full reference ↗](/docs/generated/tensorplay.slow_conv3d.html) ```python tensorplay.slow_conv3d(input, weight, kernel_size, bias=None, stride=1, padding=0, *, out=None) ``` [#](#api-tensorplay.smm) ### smm function[Full reference ↗](/docs/generated/tensorplay.smm.html) ```python tensorplay.smm(input, mat) → Tensor ``` Performs a matrix multiplication of the sparse matrix input with the dense matrix mat. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – a sparse matrix to be matrix multiplied - mat ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – a dense matrix to be matrix multiplied [#](#api-tensorplay.smooth_l1_loss) ### smooth_l1_loss function[Full reference ↗](/docs/generated/tensorplay.smooth_l1_loss.html) ```python tensorplay.smooth_l1_loss(input, target, reduction=1, beta=1.0, *, out=None) ``` [#](#api-tensorplay.soft_margin_loss) ### soft_margin_loss function[Full reference ↗](/docs/generated/tensorplay.soft_margin_loss.html) ```python tensorplay.soft_margin_loss(input, target, *, out=None) ``` [#](#api-tensorplay.softplus) ### softplus function[Full reference ↗](/docs/generated/tensorplay.softplus.html) ```python tensorplay.softplus(input, beta=1, threshold=20, *, out=None) ``` [#](#api-tensorplay.softshrink) ### softshrink function[Full reference ↗](/docs/generated/tensorplay.softshrink.html) ```python tensorplay.softshrink(input, lambd=0.5, *, out=None) ``` [#](#api-tensorplay.sparse_add) ### sparse_add function[Full reference ↗](/docs/generated/tensorplay.sparse_add.html) ```python tensorplay.sparse_add(input, other) ``` [#](#api-tensorplay.sparse_compressed_tensor) ### sparse_compressed_tensor function[Full reference ↗](/docs/generated/tensorplay.sparse_compressed_tensor.html) ```python tensorplay.sparse_compressed_tensor(compressed_indices, plain_indices, values, size=None, *, dtype=None, layout=None, device=None, pin_memory=False, requires_grad=False, check_invariants=None) → Tensor ``` Constructs a [sparse tensor in Compressed Sparse format - CSR, CSC, BSR, or BSC -](/docs/sparse.html#sparse-compressed-docs) with specified values at the given compressed_indices and plain_indices. Sparse matrix multiplication operations in Compressed Sparse format are typically faster than that for sparse tensors in COO format. Make you have a look at [the note on the data type of the indices](/docs/sparse.html#sparse-compressed-docs). > **Note** > > If the device argument is not specified the device of the given values and indices tensor(s) must match. If, however, the argument is specified the input Tensors will be converted to the given device and in turn determine the device of the constructed sparse tensor. Parameters: - compressed_indices (array_like) – (B+1)-dimensional array of size (*batchsize, compressed_dim_size + 1). The last element of each batch is the number of non-zero elements or blocks. This tensor encodes the index in values and plain_indices depending on where the given compressed dimension (row or column) starts. Each successive number in the tensor subtracted by the number before it denotes the number of elements or blocks in a given compressed dimension. - plain_indices (array_like) – Plain dimension (column or row) coordinates of each element or block in values. (B+1)-dimensional tensor with the same length as values. - values (array_list) – Initial values for the tensor. Can be a list, tuple, NumPy ndarray, scalar, and other types. that represents a (1+K)-dimensional (for CSR and CSC layouts) or (1+2+K)-dimensional tensor (for BSR and BSC layouts) where K is the number of dense dimensions. - size (list, tuple, [tensorplay.Size](/docs/generated/tensorplay.Size.html#tensorplay.Size), optional) – Size of the sparse tensor: (*batchsize, nrows * blocksize[0], ncols * blocksize[1], *densesize) where blocksize[0] == blocksize[1] == 1 for CSR and CSC formats. If not provided, the size will be inferred as the minimum size big enough to hold all non-zero elements or blocks. Keyword Arguments: - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, infers data type from [values](/docs/generated/tensorplay.values.html#tensorplay.values). - layout (tensorplay.layout, required) – the desired layout of returned tensor: tensorplay.sparse_csr, tensorplay.sparse_csc, tensorplay.sparse_bsr, or tensorplay.sparse_bsc. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - pin_memory ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. - check_invariants ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If sparse tensor invariants are checked. Default: as returned by tensorplay.sparse.check_sparse_tensor_invariants.is_enabled(), initially False. Example: ``` >>> compressed_indices = [0, 2, 4] >>> plain_indices = [0, 1, 0, 1] >>> values = [1, 2, 3, 4] >>> tensorplay.sparse_compressed_tensor(tensorplay.tensor(compressed_indices, dtype=tensorplay.int64), ... tensorplay.tensor(plain_indices, dtype=tensorplay.int64), ... tensorplay.tensor(values), dtype=tensorplay.double, layout=tensorplay.sparse_csr) tensor(crow_indices=tensor([0, 2, 4]), col_indices=tensor([0, 1, 0, 1]), values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, dtype=tensorplay.float64, layout=tensorplay.sparse_csr) ``` [#](#api-tensorplay.sparse_dim) ### sparse_dim function[Full reference ↗](/docs/generated/tensorplay.sparse_dim.html) ```python tensorplay.sparse_dim(input) ``` [#](#api-tensorplay.sparse_mask) ### sparse_mask function[Full reference ↗](/docs/generated/tensorplay.sparse_mask.html) ```python tensorplay.sparse_mask(input, mask) ``` [#](#api-tensorplay.sparse_mm) ### sparse_mm function[Full reference ↗](/docs/generated/tensorplay.sparse_mm.html) ```python tensorplay.sparse_mm(input, dense) ``` [#](#api-tensorplay.sparse_mul) ### sparse_mul function[Full reference ↗](/docs/generated/tensorplay.sparse_mul.html) ```python tensorplay.sparse_mul(input, other) ``` [#](#api-tensorplay.sparse_resize_) ### sparse_resize_ function[Full reference ↗](/docs/generated/tensorplay.sparse_resize_.html) ```python tensorplay.sparse_resize_(input, size, sparse_dim, dense_dim) ``` [#](#api-tensorplay.sparse_resize_and_clear_) ### sparse_resize_and_clear_ function[Full reference ↗](/docs/generated/tensorplay.sparse_resize_and_clear_.html) ```python tensorplay.sparse_resize_and_clear_(input, size, sparse_dim, dense_dim) ``` [#](#api-tensorplay.sparse_sampled_addmm) ### sparse_sampled_addmm function[Full reference ↗](/docs/generated/tensorplay.sparse_sampled_addmm.html) ```python tensorplay.sparse_sampled_addmm(input, mat1, mat2, *, beta=1, alpha=1, out=None) ``` [#](#api-tensorplay.sparse_sum) ### sparse_sum function[Full reference ↗](/docs/generated/tensorplay.sparse_sum.html) ```python tensorplay.sparse_sum(input, dim=None, dtype=None) ``` [#](#api-tensorplay.spdiags) ### spdiags function[Full reference ↗](/docs/generated/tensorplay.spdiags.html) ```python tensorplay.spdiags(diagonals, offsets, shape, layout=None) ``` [#](#api-tensorplay.special_airy_ai) ### special_airy_ai function[Full reference ↗](/docs/generated/tensorplay.special_airy_ai.html) ```python tensorplay.special_airy_ai(x, *, out=None) ``` [#](#api-tensorplay.special_bessel_j0) ### special_bessel_j0 function[Full reference ↗](/docs/generated/tensorplay.special_bessel_j0.html) ```python tensorplay.special_bessel_j0(input, *, out=None) ``` [#](#api-tensorplay.special_bessel_j1) ### special_bessel_j1 function[Full reference ↗](/docs/generated/tensorplay.special_bessel_j1.html) ```python tensorplay.special_bessel_j1(input, *, out=None) ``` [#](#api-tensorplay.special_bessel_y0) ### special_bessel_y0 function[Full reference ↗](/docs/generated/tensorplay.special_bessel_y0.html) ```python tensorplay.special_bessel_y0(input, *, out=None) ``` [#](#api-tensorplay.special_bessel_y1) ### special_bessel_y1 function[Full reference ↗](/docs/generated/tensorplay.special_bessel_y1.html) ```python tensorplay.special_bessel_y1(input, *, out=None) ``` [#](#api-tensorplay.special_chebyshev_polynomial_t) ### special_chebyshev_polynomial_t function[Full reference ↗](/docs/generated/tensorplay.special_chebyshev_polynomial_t.html) ```python tensorplay.special_chebyshev_polynomial_t(x, n, *, out=None) ``` [#](#api-tensorplay.special_chebyshev_polynomial_u) ### special_chebyshev_polynomial_u function[Full reference ↗](/docs/generated/tensorplay.special_chebyshev_polynomial_u.html) ```python tensorplay.special_chebyshev_polynomial_u(x, n, *, out=None) ``` [#](#api-tensorplay.special_chebyshev_polynomial_v) ### special_chebyshev_polynomial_v function[Full reference ↗](/docs/generated/tensorplay.special_chebyshev_polynomial_v.html) ```python tensorplay.special_chebyshev_polynomial_v(x, n, *, out=None) ``` [#](#api-tensorplay.special_chebyshev_polynomial_w) ### special_chebyshev_polynomial_w function[Full reference ↗](/docs/generated/tensorplay.special_chebyshev_polynomial_w.html) ```python tensorplay.special_chebyshev_polynomial_w(x, n, *, out=None) ``` [#](#api-tensorplay.special_digamma) ### special_digamma function[Full reference ↗](/docs/generated/tensorplay.special_digamma.html) ```python tensorplay.special_digamma(input, *, out=None) ``` [#](#api-tensorplay.special_entr) ### special_entr function[Full reference ↗](/docs/generated/tensorplay.special_entr.html) ```python tensorplay.special_entr(input, *, out=None) ``` [#](#api-tensorplay.special_erf) ### special_erf function[Full reference ↗](/docs/generated/tensorplay.special_erf.html) ```python tensorplay.special_erf(input, *, out=None) ``` [#](#api-tensorplay.special_erfc) ### special_erfc function[Full reference ↗](/docs/generated/tensorplay.special_erfc.html) ```python tensorplay.special_erfc(input, *, out=None) ``` [#](#api-tensorplay.special_erfcx) ### special_erfcx function[Full reference ↗](/docs/generated/tensorplay.special_erfcx.html) ```python tensorplay.special_erfcx(input, *, out=None) ``` [#](#api-tensorplay.special_erfinv) ### special_erfinv function[Full reference ↗](/docs/generated/tensorplay.special_erfinv.html) ```python tensorplay.special_erfinv(input, *, out=None) ``` [#](#api-tensorplay.special_exp2) ### special_exp2 function[Full reference ↗](/docs/generated/tensorplay.special_exp2.html) ```python tensorplay.special_exp2(input, *, out=None) ``` [#](#api-tensorplay.special_expit) ### special_expit function[Full reference ↗](/docs/generated/tensorplay.special_expit.html) ```python tensorplay.special_expit(input, *, out=None) ``` [#](#api-tensorplay.special_expm1) ### special_expm1 function[Full reference ↗](/docs/generated/tensorplay.special_expm1.html) ```python tensorplay.special_expm1(input, *, out=None) ``` [#](#api-tensorplay.special_gammainc) ### special_gammainc function[Full reference ↗](/docs/generated/tensorplay.special_gammainc.html) ```python tensorplay.special_gammainc(input, other, *, out=None) ``` [#](#api-tensorplay.special_gammaincc) ### special_gammaincc function[Full reference ↗](/docs/generated/tensorplay.special_gammaincc.html) ```python tensorplay.special_gammaincc(input, other, *, out=None) ``` [#](#api-tensorplay.special_gammaln) ### special_gammaln function[Full reference ↗](/docs/generated/tensorplay.special_gammaln.html) ```python tensorplay.special_gammaln(input, *, out=None) ``` [#](#api-tensorplay.special_hermite_polynomial_h) ### special_hermite_polynomial_h function[Full reference ↗](/docs/generated/tensorplay.special_hermite_polynomial_h.html) ```python tensorplay.special_hermite_polynomial_h(x, n, *, out=None) ``` [#](#api-tensorplay.special_hermite_polynomial_he) ### special_hermite_polynomial_he function[Full reference ↗](/docs/generated/tensorplay.special_hermite_polynomial_he.html) ```python tensorplay.special_hermite_polynomial_he(x, n, *, out=None) ``` [#](#api-tensorplay.special_i0) ### special_i0 function[Full reference ↗](/docs/generated/tensorplay.special_i0.html) ```python tensorplay.special_i0(input, *, out=None) ``` [#](#api-tensorplay.special_i0e) ### special_i0e function[Full reference ↗](/docs/generated/tensorplay.special_i0e.html) ```python tensorplay.special_i0e(input, *, out=None) ``` [#](#api-tensorplay.special_i1) ### special_i1 function[Full reference ↗](/docs/generated/tensorplay.special_i1.html) ```python tensorplay.special_i1(input, *, out=None) ``` [#](#api-tensorplay.special_i1e) ### special_i1e function[Full reference ↗](/docs/generated/tensorplay.special_i1e.html) ```python tensorplay.special_i1e(input, *, out=None) ``` [#](#api-tensorplay.special_laguerre_polynomial_l) ### special_laguerre_polynomial_l function[Full reference ↗](/docs/generated/tensorplay.special_laguerre_polynomial_l.html) ```python tensorplay.special_laguerre_polynomial_l(x, n, *, out=None) ``` [#](#api-tensorplay.special_legendre_polynomial_p) ### special_legendre_polynomial_p function[Full reference ↗](/docs/generated/tensorplay.special_legendre_polynomial_p.html) ```python tensorplay.special_legendre_polynomial_p(x, n, *, out=None) ``` [#](#api-tensorplay.special_log_ndtr) ### special_log_ndtr function[Full reference ↗](/docs/generated/tensorplay.special_log_ndtr.html) ```python tensorplay.special_log_ndtr(input, *, out=None) ``` [#](#api-tensorplay.special_log_softmax) ### special_log_softmax function[Full reference ↗](/docs/generated/tensorplay.special_log_softmax.html) ```python tensorplay.special_log_softmax(input, dim, dtype=None) ``` [#](#api-tensorplay.special_log1p) ### special_log1p function[Full reference ↗](/docs/generated/tensorplay.special_log1p.html) ```python tensorplay.special_log1p(input, *, out=None) ``` [#](#api-tensorplay.special_logit) ### special_logit function[Full reference ↗](/docs/generated/tensorplay.special_logit.html) ```python tensorplay.special_logit(input, eps=None, *, out=None) ``` [#](#api-tensorplay.special_logsumexp) ### special_logsumexp function[Full reference ↗](/docs/generated/tensorplay.special_logsumexp.html) ```python tensorplay.special_logsumexp(input, dim, keepdim=False, *, out=None) ``` [#](#api-tensorplay.special_modified_bessel_i0) ### special_modified_bessel_i0 function[Full reference ↗](/docs/generated/tensorplay.special_modified_bessel_i0.html) ```python tensorplay.special_modified_bessel_i0(input, *, out=None) ``` [#](#api-tensorplay.special_modified_bessel_i1) ### special_modified_bessel_i1 function[Full reference ↗](/docs/generated/tensorplay.special_modified_bessel_i1.html) ```python tensorplay.special_modified_bessel_i1(input, *, out=None) ``` [#](#api-tensorplay.special_modified_bessel_k0) ### special_modified_bessel_k0 function[Full reference ↗](/docs/generated/tensorplay.special_modified_bessel_k0.html) ```python tensorplay.special_modified_bessel_k0(input, *, out=None) ``` [#](#api-tensorplay.special_modified_bessel_k1) ### special_modified_bessel_k1 function[Full reference ↗](/docs/generated/tensorplay.special_modified_bessel_k1.html) ```python tensorplay.special_modified_bessel_k1(input, *, out=None) ``` [#](#api-tensorplay.special_multigammaln) ### special_multigammaln function[Full reference ↗](/docs/generated/tensorplay.special_multigammaln.html) ```python tensorplay.special_multigammaln(input, p, *, out=None) ``` [#](#api-tensorplay.special_ndtr) ### special_ndtr function[Full reference ↗](/docs/generated/tensorplay.special_ndtr.html) ```python tensorplay.special_ndtr(input, *, out=None) ``` [#](#api-tensorplay.special_ndtri) ### special_ndtri function[Full reference ↗](/docs/generated/tensorplay.special_ndtri.html) ```python tensorplay.special_ndtri(input, *, out=None) ``` [#](#api-tensorplay.special_polygamma) ### special_polygamma function[Full reference ↗](/docs/generated/tensorplay.special_polygamma.html) ```python tensorplay.special_polygamma(n, input, *, out=None) ``` [#](#api-tensorplay.special_psi) ### special_psi function[Full reference ↗](/docs/generated/tensorplay.special_psi.html) ```python tensorplay.special_psi(input, *, out=None) ``` [#](#api-tensorplay.special_round) ### special_round function[Full reference ↗](/docs/generated/tensorplay.special_round.html) ```python tensorplay.special_round(input, *, decimals=0, out=None) ``` [#](#api-tensorplay.special_scaled_modified_bessel_k0) ### special_scaled_modified_bessel_k0 function[Full reference ↗](/docs/generated/tensorplay.special_scaled_modified_bessel_k0.html) ```python tensorplay.special_scaled_modified_bessel_k0(x, *, out=None) ``` [#](#api-tensorplay.special_scaled_modified_bessel_k1) ### special_scaled_modified_bessel_k1 function[Full reference ↗](/docs/generated/tensorplay.special_scaled_modified_bessel_k1.html) ```python tensorplay.special_scaled_modified_bessel_k1(x, *, out=None) ``` [#](#api-tensorplay.special_shifted_chebyshev_polynomial_t) ### special_shifted_chebyshev_polynomial_t function[Full reference ↗](/docs/generated/tensorplay.special_shifted_chebyshev_polynomial_t.html) ```python tensorplay.special_shifted_chebyshev_polynomial_t(x, n, *, out=None) ``` [#](#api-tensorplay.special_shifted_chebyshev_polynomial_u) ### special_shifted_chebyshev_polynomial_u function[Full reference ↗](/docs/generated/tensorplay.special_shifted_chebyshev_polynomial_u.html) ```python tensorplay.special_shifted_chebyshev_polynomial_u(x, n, *, out=None) ``` [#](#api-tensorplay.special_shifted_chebyshev_polynomial_v) ### special_shifted_chebyshev_polynomial_v function[Full reference ↗](/docs/generated/tensorplay.special_shifted_chebyshev_polynomial_v.html) ```python tensorplay.special_shifted_chebyshev_polynomial_v(x, n, *, out=None) ``` [#](#api-tensorplay.special_shifted_chebyshev_polynomial_w) ### special_shifted_chebyshev_polynomial_w function[Full reference ↗](/docs/generated/tensorplay.special_shifted_chebyshev_polynomial_w.html) ```python tensorplay.special_shifted_chebyshev_polynomial_w(x, n, *, out=None) ``` [#](#api-tensorplay.special_sinc) ### special_sinc function[Full reference ↗](/docs/generated/tensorplay.special_sinc.html) ```python tensorplay.special_sinc(input, *, out=None) ``` [#](#api-tensorplay.special_softmax) ### special_softmax function[Full reference ↗](/docs/generated/tensorplay.special_softmax.html) ```python tensorplay.special_softmax(input, dim, dtype=None) ``` [#](#api-tensorplay.special_spherical_bessel_j0) ### special_spherical_bessel_j0 function[Full reference ↗](/docs/generated/tensorplay.special_spherical_bessel_j0.html) ```python tensorplay.special_spherical_bessel_j0(x, *, out=None) ``` [#](#api-tensorplay.special_xlog1py) ### special_xlog1py function[Full reference ↗](/docs/generated/tensorplay.special_xlog1py.html) ```python tensorplay.special_xlog1py(input, other, *, out=None) ``` [#](#api-tensorplay.special_xlogy) ### special_xlogy function[Full reference ↗](/docs/generated/tensorplay.special_xlogy.html) ```python tensorplay.special_xlogy(input, other, *, out=None) ``` [#](#api-tensorplay.special_zeta) ### special_zeta function[Full reference ↗](/docs/generated/tensorplay.special_zeta.html) ```python tensorplay.special_zeta(input, other, *, out=None) ``` [#](#api-tensorplay.spherical_bessel_j0) ### spherical_bessel_j0 function[Full reference ↗](/docs/generated/tensorplay.spherical_bessel_j0.html) ```python tensorplay.spherical_bessel_j0(input) ``` [#](#api-tensorplay.split_with_sizes) ### split_with_sizes function[Full reference ↗](/docs/generated/tensorplay.split_with_sizes.html) ```python tensorplay.split_with_sizes(input, split_sizes, dim=0) ``` [#](#api-tensorplay.squeeze_) ### squeeze_ function[Full reference ↗](/docs/generated/tensorplay.squeeze_.html) ```python tensorplay.squeeze_(input) ``` [#](#api-tensorplay.sspaddmm) ### sspaddmm function[Full reference ↗](/docs/generated/tensorplay.sspaddmm.html) ```python tensorplay.sspaddmm(input, mat1, mat2, *, beta=1, alpha=1, out=None) → Tensor ``` Matrix multiplies a sparse tensor mat1 with a dense tensor mat2, then adds the sparse tensor input to the result. Note: This function is equivalent to tensorplay.addmm(), except input and mat1 are sparse. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – a sparse matrix to be added - mat1 ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – a sparse matrix to be matrix multiplied - mat2 ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – a dense matrix to be matrix multiplied Keyword Arguments: - beta (Number, optional) – multiplier for mat ($\beta$) - alpha (Number, optional) – multiplier for $mat1 @ mat2$ ($\alpha$) - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. [#](#api-tensorplay.storage_offset) ### storage_offset function[Full reference ↗](/docs/generated/tensorplay.storage_offset.html) ```python tensorplay.storage_offset(input) ``` [#](#api-tensorplay.stride) ### stride function[Full reference ↗](/docs/generated/tensorplay.stride.html) ```python tensorplay.stride(input) ``` [#](#api-tensorplay.sub_) ### sub_ function[Full reference ↗](/docs/generated/tensorplay.sub_.html) ```python tensorplay.sub_(input, other, alpha=1) ``` [#](#api-tensorplay.subtract_) ### subtract_ function[Full reference ↗](/docs/generated/tensorplay.subtract_.html) ```python tensorplay.subtract_(input, other, alpha=1) ``` [#](#api-tensorplay.sum_to_size) ### sum_to_size function[Full reference ↗](/docs/generated/tensorplay.sum_to_size.html) ```python tensorplay.sum_to_size(input, size) ``` [#](#api-tensorplay.swapaxes_) ### swapaxes_ function[Full reference ↗](/docs/generated/tensorplay.swapaxes_.html) ```python tensorplay.swapaxes_(input, axis0, axis1) ``` [#](#api-tensorplay.swapdims_) ### swapdims_ function[Full reference ↗](/docs/generated/tensorplay.swapdims_.html) ```python tensorplay.swapdims_(input, dim0, dim1) ``` [#](#api-tensorplay.sym_float) ### sym_float function[Full reference ↗](/docs/generated/tensorplay.sym_float.html) ```python tensorplay.sym_float(arg0: object) → object ``` [#](#api-tensorplay.sym_int) ### sym_int function[Full reference ↗](/docs/generated/tensorplay.sym_int.html) ```python tensorplay.sym_int(arg0: object) → object ``` [#](#api-tensorplay.sym_is_contiguous) ### sym_is_contiguous function[Full reference ↗](/docs/generated/tensorplay.sym_is_contiguous.html) ```python tensorplay.sym_is_contiguous(input, memory_format=tensorplay.contiguous_format) ``` [#](#api-tensorplay.sym_ite) ### sym_ite function[Full reference ↗](/docs/generated/tensorplay.sym_ite.html) ```python tensorplay.sym_ite(arg0: object, arg1: object, arg2: object) → object ``` [#](#api-tensorplay.sym_max) ### sym_max function[Full reference ↗](/docs/generated/tensorplay.sym_max.html) ```python tensorplay.sym_max(arg0: object, arg1: object) → object ``` [#](#api-tensorplay.sym_min) ### sym_min function[Full reference ↗](/docs/generated/tensorplay.sym_min.html) ```python tensorplay.sym_min(arg0: object, arg1: object) → object ``` [#](#api-tensorplay.sym_not) ### sym_not function[Full reference ↗](/docs/generated/tensorplay.sym_not.html) ```python tensorplay.sym_not(arg0: object) → object ``` [#](#api-tensorplay.sym_numel) ### sym_numel function[Full reference ↗](/docs/generated/tensorplay.sym_numel.html) ```python tensorplay.sym_numel(input) ``` [#](#api-tensorplay.sym_size) ### sym_size function[Full reference ↗](/docs/generated/tensorplay.sym_size.html) ```python tensorplay.sym_size(input, dim) ``` [#](#api-tensorplay.sym_sqrt) ### sym_sqrt function[Full reference ↗](/docs/generated/tensorplay.sym_sqrt.html) ```python tensorplay.sym_sqrt(arg0: object) → object ``` [#](#api-tensorplay.sym_storage_offset) ### sym_storage_offset function[Full reference ↗](/docs/generated/tensorplay.sym_storage_offset.html) ```python tensorplay.sym_storage_offset(input) ``` [#](#api-tensorplay.sym_stride) ### sym_stride function[Full reference ↗](/docs/generated/tensorplay.sym_stride.html) ```python tensorplay.sym_stride(input, dim) ``` [#](#api-tensorplay.sym_sum) ### sym_sum function[Full reference ↗](/docs/generated/tensorplay.sym_sum.html) ```python tensorplay.sym_sum(*args) → object ``` [#](#api-tensorplay.t_) ### t_ function[Full reference ↗](/docs/generated/tensorplay.t_.html) ```python tensorplay.t_(input) ``` [#](#api-tensorplay.tensor) ### tensor function[Full reference ↗](/docs/generated/tensorplay.tensor.html) ```python tensorplay.tensor(data, *, dtype=None, device=None, requires_grad=False, pin_memory=False) → Tensor ``` Constructs a tensor with no autograd history (also known as a “leaf tensor”, see [Autograd mechanics](/docs/notes/autograd.html)) by copying [data](/docs/generated/tensorplay.data.html#tensorplay.data). > **Warning** > > When working with tensors prefer using tensorplay.Tensor.clone(), tensorplay.Tensor.detach(), and tensorplay.Tensor.requires_grad_() for readability. Letting t be a tensor, tensorplay.tensor(t) is equivalent to t.detach().clone(), and tensorplay.tensor(t, requires_grad=True) is equivalent to t.detach().clone().requires_grad_(True). > **See also** > > tensorplay.as_tensor() preserves autograd history and avoids copies where possible. tensorplay.from_numpy() creates a tensor that shares storage with a NumPy array. Parameters: data (array_like) – Initial data for the tensor. Can be a list, tuple, NumPy ndarray, scalar, and other types. Keyword Arguments: - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, infers data type from [data](/docs/generated/tensorplay.data.html#tensorplay.data). - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the device of the constructed tensor. If None and data is a tensor then the device of data is used. If None and data is not a tensor then the result tensor is constructed on the current device. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. - pin_memory ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False. Example: ``` >>> tensorplay.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]]) tensor([[ 0.1000, 1.2000], [ 2.2000, 3.1000], [ 4.9000, 5.2000]]) >>> tensorplay.tensor([0, 1]) # Type inference on data tensor([ 0, 1]) >>> tensorplay.tensor([[0.11111, 0.222222, 0.3333333]], ... dtype=tensorplay.float64, ... device=tensorplay.device('cuda:0')) # creates a double tensor on a CUDA device tensor([[ 0.1111, 0.2222, 0.3333]], dtype=tensorplay.float64, device='cuda:0') >>> tensorplay.tensor(3.14159) # Create a zero-dimensional (scalar) tensor tensor(3.1416) >>> tensorplay.tensor([]) # Create an empty tensor (of size (0,)) tensor([]) ``` [#](#api-tensorplay.thnn_conv2d) ### thnn_conv2d function[Full reference ↗](/docs/generated/tensorplay.thnn_conv2d.html) ```python tensorplay.thnn_conv2d(input, weight, kernel_size, bias=None, stride=1, padding=0, *, out=None) ``` [#](#api-tensorplay.to_dense) ### to_dense function[Full reference ↗](/docs/generated/tensorplay.to_dense.html) ```python tensorplay.to_dense(input) ``` [#](#api-tensorplay.to_mkldnn) ### to_mkldnn function[Full reference ↗](/docs/generated/tensorplay.to_mkldnn.html) ```python tensorplay.to_mkldnn(input, dtype=None) ``` [#](#api-tensorplay.to_padded_tensor) ### to_padded_tensor function[Full reference ↗](/docs/generated/tensorplay.to_padded_tensor.html) ```python tensorplay.to_padded_tensor(input, padding, output_size=None) ``` [#](#api-tensorplay.to_sparse_bsc) ### to_sparse_bsc function[Full reference ↗](/docs/generated/tensorplay.to_sparse_bsc.html) ```python tensorplay.to_sparse_bsc(input, blocksize, dense_dim=None) ``` [#](#api-tensorplay.to_sparse_bsr) ### to_sparse_bsr function[Full reference ↗](/docs/generated/tensorplay.to_sparse_bsr.html) ```python tensorplay.to_sparse_bsr(input, blocksize, dense_dim=None) ``` [#](#api-tensorplay.to_sparse_csc) ### to_sparse_csc function[Full reference ↗](/docs/generated/tensorplay.to_sparse_csc.html) ```python tensorplay.to_sparse_csc(input, dense_dim=None) ``` [#](#api-tensorplay.to_sparse_csr) ### to_sparse_csr function[Full reference ↗](/docs/generated/tensorplay.to_sparse_csr.html) ```python tensorplay.to_sparse_csr(input) ``` [#](#api-tensorplay.to_sparse) ### to_sparse function[Full reference ↗](/docs/generated/tensorplay.to_sparse.html) ```python tensorplay.to_sparse(input, sparse_dim=None) ``` [#](#api-tensorplay.to) ### to function[Full reference ↗](/docs/generated/tensorplay.to.html) ```python tensorplay.to(input, dtype=None, layout=None, device=None, pin_memory=None, non_blocking=False, copy=False, memory_format=None) ``` [#](#api-tensorplay.tp_cosine_embedding_loss) ### tp_cosine_embedding_loss function[Full reference ↗](/docs/generated/tensorplay.tp_cosine_embedding_loss.html) ```python tensorplay.tp_cosine_embedding_loss(input1, input2, target, margin=0.0, reduction=1) ``` [#](#api-tensorplay.tp_hinge_embedding_loss) ### tp_hinge_embedding_loss function[Full reference ↗](/docs/generated/tensorplay.tp_hinge_embedding_loss.html) ```python tensorplay.tp_hinge_embedding_loss(input, target, margin=1.0, reduction=1) ``` [#](#api-tensorplay.tp_kl_div) ### tp_kl_div function[Full reference ↗](/docs/generated/tensorplay.tp_kl_div.html) ```python tensorplay.tp_kl_div(input, target, reduction=1, log_target=False) ``` [#](#api-tensorplay.tp_l1_loss) ### tp_l1_loss function[Full reference ↗](/docs/generated/tensorplay.tp_l1_loss.html) ```python tensorplay.tp_l1_loss(input, target, reduction=1) ``` [#](#api-tensorplay.tp_margin_ranking_loss) ### tp_margin_ranking_loss function[Full reference ↗](/docs/generated/tensorplay.tp_margin_ranking_loss.html) ```python tensorplay.tp_margin_ranking_loss(input1, input2, target, margin=0.0, reduction=1) ``` [#](#api-tensorplay.tp_poisson_nll_loss) ### tp_poisson_nll_loss function[Full reference ↗](/docs/generated/tensorplay.tp_poisson_nll_loss.html) ```python tensorplay.tp_poisson_nll_loss(input, target, log_input=True, full=False, eps=1e-08, reduction=1) ``` [#](#api-tensorplay.tp_soft_margin_loss) ### tp_soft_margin_loss function[Full reference ↗](/docs/generated/tensorplay.tp_soft_margin_loss.html) ```python tensorplay.tp_soft_margin_loss(input, target, reduction=1) ``` [#](#api-tensorplay.transpose_) ### transpose_ function[Full reference ↗](/docs/generated/tensorplay.transpose_.html) ```python tensorplay.transpose_(input, dim0, dim1) ``` [#](#api-tensorplay.tril_) ### tril_ function[Full reference ↗](/docs/generated/tensorplay.tril_.html) ```python tensorplay.tril_(input, diagonal=0) ``` [#](#api-tensorplay.triu_) ### triu_ function[Full reference ↗](/docs/generated/tensorplay.triu_.html) ```python tensorplay.triu_(input, diagonal=0) ``` [#](#api-tensorplay.true_divide_) ### true_divide_ function[Full reference ↗](/docs/generated/tensorplay.true_divide_.html) ```python tensorplay.true_divide_(input, other) ``` [#](#api-tensorplay.type_as) ### type_as function[Full reference ↗](/docs/generated/tensorplay.type_as.html) ```python tensorplay.type_as(input, other) ``` [#](#api-tensorplay.typename) ### typename function[Full reference ↗](/docs/generated/tensorplay.typename.html) ```python tensorplay.typename(obj: Any, /) → str ``` String representation of the type of an object. This function returns a fully qualified string representation of an object’s type. :param obj: The object whose type to represent :type obj: object Returns: the type of the object o Return type: [str](https://docs.python.org/3/builtins/stdtypes.html#str) Example ``` >>> x = tensorplay.tensor([1, 2, 3]) >>> tensorplay.typename(x) 'tensorplay.LongTensor' >>> tensorplay.typename(tensorplay.nn.Parameter) 'tensorplay.nn.parameter.Parameter' ``` [#](#api-tensorplay.unflatten_dense_tensors) ### unflatten_dense_tensors function[Full reference ↗](/docs/generated/tensorplay.unflatten_dense_tensors.html) ```python tensorplay.unflatten_dense_tensors(flat, tensors) ``` [#](#api-tensorplay.unfold) ### unfold function[Full reference ↗](/docs/generated/tensorplay.unfold.html) ```python tensorplay.unfold(input, dimension, size, step) ``` [#](#api-tensorplay.uniform_) ### uniform_ function[Full reference ↗](/docs/generated/tensorplay.uniform_.html) ```python tensorplay.uniform_(input, from_=0.0, to=1.0, generator=None) ``` [#](#api-tensorplay.unique_dim_consecutive) ### unique_dim_consecutive function[Full reference ↗](/docs/generated/tensorplay.unique_dim_consecutive.html) ```python tensorplay.unique_dim_consecutive(input, dim, return_inverse=False, return_counts=False) ``` [#](#api-tensorplay.unique_dim) ### unique_dim function[Full reference ↗](/docs/generated/tensorplay.unique_dim.html) ```python tensorplay.unique_dim(input, dim, sorted=True, return_inverse=False, return_counts=False) ``` [#](#api-tensorplay.unsafe_chunk) ### unsafe_chunk function[Full reference ↗](/docs/generated/tensorplay.unsafe_chunk.html) ```python tensorplay.unsafe_chunk(input, chunks, dim=0) → List of Tensors ``` Works like tensorplay.chunk() but without enforcing the autograd restrictions on inplace modification of the outputs. > **Warning** > > This function is safe to use as long as only the input, or only the outputs are modified inplace after calling this function. It is user’s responsibility to ensure that is the case. If both the input and one or more of the outputs are modified inplace, gradients computed by autograd will be silently incorrect. [#](#api-tensorplay.unsafe_split_with_sizes) ### unsafe_split_with_sizes function[Full reference ↗](/docs/generated/tensorplay.unsafe_split_with_sizes.html) ```python tensorplay.unsafe_split_with_sizes(input, split_sizes, dim=0) ``` [#](#api-tensorplay.unsafe_split) ### unsafe_split function[Full reference ↗](/docs/generated/tensorplay.unsafe_split.html) ```python tensorplay.unsafe_split(tensor, split_size_or_sections, dim=0) → List of Tensors ``` Works like tensorplay.split() but without enforcing the autograd restrictions on inplace modification of the outputs. > **Warning** > > This function is safe to use as long as only the input, or only the outputs are modified inplace after calling this function. It is user’s responsibility to ensure that is the case. If both the input and one or more of the outputs are modified inplace, gradients computed by autograd will be silently incorrect. [#](#api-tensorplay.unsqueeze_) ### unsqueeze_ function[Full reference ↗](/docs/generated/tensorplay.unsqueeze_.html) ```python tensorplay.unsqueeze_(input, dim) ``` [#](#api-tensorplay.upsample_bicubic2d) ### upsample_bicubic2d function[Full reference ↗](/docs/generated/tensorplay.upsample_bicubic2d.html) ```python tensorplay.upsample_bicubic2d(input, output_size, align_corners, scales_h=None, scales_w=None, *, out=None) ``` [#](#api-tensorplay.upsample_bilinear2d) ### upsample_bilinear2d function[Full reference ↗](/docs/generated/tensorplay.upsample_bilinear2d.html) ```python tensorplay.upsample_bilinear2d(input, output_size, align_corners, scales_h=None, scales_w=None, *, out=None) ``` [#](#api-tensorplay.upsample_linear1d) ### upsample_linear1d function[Full reference ↗](/docs/generated/tensorplay.upsample_linear1d.html) ```python tensorplay.upsample_linear1d(input, output_size, align_corners, scales=None, *, out=None) ``` [#](#api-tensorplay.upsample_nearest1d) ### upsample_nearest1d function[Full reference ↗](/docs/generated/tensorplay.upsample_nearest1d.html) ```python tensorplay.upsample_nearest1d(input, output_size, scales=None, *, out=None) ``` [#](#api-tensorplay.upsample_nearest2d) ### upsample_nearest2d function[Full reference ↗](/docs/generated/tensorplay.upsample_nearest2d.html) ```python tensorplay.upsample_nearest2d(input, output_size, scales_h=None, scales_w=None, *, out=None) ``` [#](#api-tensorplay.upsample_nearest3d) ### upsample_nearest3d function[Full reference ↗](/docs/generated/tensorplay.upsample_nearest3d.html) ```python tensorplay.upsample_nearest3d(input, output_size, scales_d=None, scales_h=None, scales_w=None, *, out=None) ``` [#](#api-tensorplay.upsample_trilinear3d) ### upsample_trilinear3d function[Full reference ↗](/docs/generated/tensorplay.upsample_trilinear3d.html) ```python tensorplay.upsample_trilinear3d(input, output_size, align_corners, scales_d=None, scales_h=None, scales_w=None, *, out=None) ``` [#](#api-tensorplay.use_deterministic_algorithms) ### use_deterministic_algorithms function[Full reference ↗](/docs/generated/tensorplay.use_deterministic_algorithms.html) ```python tensorplay.use_deterministic_algorithms(mode: bool, *, warn_only: bool = False) → None ``` Sets whether TensorPlay operations must use “deterministic” algorithms. That is, algorithms which, given the same input, and when run on the same software and hardware, always produce the same output. When enabled, operations will use deterministic algorithms when available, and if only nondeterministic algorithms are available they will throw a [RuntimeError](https://docs.python.org/3/builtins/exceptions.html#RuntimeError) when called. > **Note** > > This setting alone is not always enough to make an application reproducible. Refer to Reproducibility for more information. > **Note** > > tensorplay.set_deterministic_debug_mode() offers an alternative interface for this feature. Note that deterministic operations tend to have worse performance than nondeterministic operations. > **Note** > > This flag does not detect or prevent nondeterministic behavior caused by calling an inplace operation on a tensor with an internal memory overlap or by giving such a tensor as the out argument for an operation. In these cases, multiple writes of different data may target a single memory location, and the order of writes is not guaranteed. Parameters: mode ([bool](https://docs.python.org/3/builtins/functions.html#bool)) – If True, makes potentially nondeterministic operations switch to a deterministic algorithm or throw a runtime error. If False, allows nondeterministic operations. Keyword Arguments: warn_only ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If True, operations that do not have a deterministic implementation will throw a warning instead of an error. Default: False Example: ``` >>> # xdoctest: +SKIP >>> tensorplay.use_deterministic_algorithms(True) ``` [#](#api-tensorplay.values) ### values function[Full reference ↗](/docs/generated/tensorplay.values.html) ```python tensorplay.values(input) ``` [#](#api-tensorplay.view_as) ### view_as function[Full reference ↗](/docs/generated/tensorplay.view_as.html) ```python tensorplay.view_as(input, other) ``` [#](#api-tensorplay.view) ### view function[Full reference ↗](/docs/generated/tensorplay.view.html) ```python tensorplay.view(input, size) ``` [#](#api-tensorplay.xlog1py_) ### xlog1py_ function[Full reference ↗](/docs/generated/tensorplay.xlog1py_.html) ```python tensorplay.xlog1py_(input, other) ``` [#](#api-tensorplay.xlog1py) ### xlog1py function[Full reference ↗](/docs/generated/tensorplay.xlog1py.html) ```python tensorplay.xlog1py(input, other) ``` [#](#api-tensorplay.zeros) ### zeros function[Full reference ↗](/docs/generated/tensorplay.zeros.html) ```python tensorplay.zeros(\*size, \*, out=None, dtype=None, layout=tensorplay.strided, device=None, requires_grad=False) → Tensor ``` Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument [size](/docs/generated/tensorplay.size.html#tensorplay.size). Parameters: size ([int](https://docs.python.org/3/builtins/functions.html#int)...) – a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple. Keyword Arguments: - out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – the desired data type of returned tensor. Default: if None, uses a global default (see [tensorplay.set_default_dtype()](/docs/generated/tensorplay.set_default_dtype.html#tensorplay.set_default_dtype)). - layout (tensorplay.layout, optional) – the desired layout of returned Tensor. Default: tensorplay.strided. - device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see [tensorplay.set_default_device()](/docs/generated/tensorplay.set_default_device.html#tensorplay.set_default_device)). [device](/docs/generated/tensorplay.Device.html#tensorplay.Device) will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. - requires_grad ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If autograd should record operations on the returned tensor. Default: False. Example: ``` >>> tensorplay.zeros(2, 3) tensor([[ 0., 0., 0.], [ 0., 0., 0.]]) >>> tensorplay.zeros(5) tensor([ 0., 0., 0., 0., 0.]) ``` [#](#api-tensorplay.zeta) ### zeta function[Full reference ↗](/docs/generated/tensorplay.zeta.html) ```python tensorplay.zeta(input, other) ``` ## Classes 21 [#](#api-tensorplay.autocast) ### autocast class[Full reference ↗](/docs/generated/tensorplay.autocast.html) ```python class tensorplay.autocast(device_type: str, dtype: Any | None = None, enabled: bool = True, cache_enabled: bool | None = None) ``` Instances of [autocast](#tensorplay.autocast) serve as context managers or decorators that allow regions of your script to run in mixed precision. In these regions, ops run in an op-specific dtype chosen by autocast to improve performance while maintaining accuracy. When entering an autocast-enabled region, Tensors may be any type. You should not call half() or bfloat16() on your model(s) or inputs when using autocasting. [autocast](#tensorplay.autocast) should wrap only the forward pass(es) of your network, including the loss computation(s). Backward passes under autocast are not recommended. Backward ops run in the same type that autocast used for corresponding forward ops. Example for CUDA Devices: ``` # Creates model and optimizer in default precision model = Net().cuda() optimizer = optim.SGD(model.parameters(), ...) for input, target in data: optimizer.zero_grad() # Enables autocasting for the forward pass (model + loss) with tensorplay.autocast(device_type="cuda"): output = model(input) loss = loss_fn(output, target) # Exits the context manager before backward() loss.backward() optimizer.step() ``` [autocast](#tensorplay.autocast) can also be used as a decorator, e.g., on the forward method of your model: ``` class AutocastModel(nn.Module): ... @tensorplay.autocast(device_type="cuda") def forward(self, input): ... ``` Floating-point Tensors produced in an autocast-enabled region may be float16. After returning to an autocast-disabled region, using them with floating-point Tensors of different dtypes may cause type mismatch errors. If so, cast the Tensor(s) produced in the autocast region back to float32 (or other dtype if desired). autocast(enabled=False) subregions can be nested in autocast-enabled regions. Locally disabling autocast can be useful, for example, if you want to force a subregion to run in a particular dtype. The autocast state is thread-local. If you want it enabled in a new thread, the context manager or decorator must be invoked in that thread. Parameters: - device_type ([str](https://docs.python.org/3/builtins/stdtypes.html#str), required) – Device type to use. Possible values are: ‘cuda’ and ‘cpu’. The type is the same as the type attribute of a [tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device). Thus, you may obtain the device type of a tensor using Tensor.device.type. - enabled ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether autocasting should be enabled in the region. Default: True - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType), optional) – Data type for ops run in autocast. It uses the default value (tensorplay.float16 for CUDA and tensorplay.bfloat16 for CPU), given by [get_autocast_dtype()](/docs/generated/tensorplay.get_autocast_dtype.html#tensorplay.get_autocast_dtype), if [dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType) is None. Default: None - cache_enabled ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – Whether the weight cache inside autocast should be enabled. Default: True [#](#api-tensorplay.Device) ### Device class[Full reference ↗](/docs/generated/tensorplay.Device.html) ```python class tensorplay.Device ``` ```python is_cpu(self: tensorplay._C.Device) → bool ``` ```python is_cuda(self: tensorplay._C.Device) → bool ``` ```python is_meta(self: tensorplay._C.Device) → bool ``` ```python is_vulkan(self: tensorplay._C.Device) → bool ``` [#](#api-tensorplay.DeviceType) ### DeviceType class[Full reference ↗](/docs/generated/tensorplay.DeviceType.html) ```python class tensorplay.DeviceType ``` Members: CPU CUDA Vulkan META Unknown ```python DeviceType.name -> str ``` [#](#api-tensorplay.DispatchKey) ### DispatchKey class[Full reference ↗](/docs/generated/tensorplay.DispatchKey.html) ```python class tensorplay.DispatchKey ``` Dispatch keys of the runtime, in dispatch-priority order: autocast keys outrank autograd keys, which outrank backend keys. Members: CPU CUDA Vulkan SparseCPU SparseCUDA Sparse AutogradCPU AutogradCUDA AutogradVulkan AutogradSparseCPU AutogradSparseCUDA AutogradSparse AutocastCPU AutocastCUDA AutocastVulkan AutocastSparseCPU AutocastSparseCUDA AutocastSparse VmapCPU VmapCUDA VmapVulkan VmapSparseCPU VmapSparseCUDA VmapSparse Composite VmapMode DynamicLayerFrontMode DynamicLayerBackMode Python ```python DispatchKey.name -> str ``` [#](#api-tensorplay.DType) ### DType class[Full reference ↗](/docs/generated/tensorplay.DType.html) ```python class tensorplay.DType ``` Members: uint8 int8 int16 int32 int64 uint16 uint32 uint64 float16 bfloat16 float32 float64 complex32 complex64 complex128 bcomplex32 float8_e4m3fn float8_e4m3fnuz float8_e5m2 float8_e5m2fnuz float8_e8m0fnu qint8 quint8 qint32 quint2x4 quint4x2 quint1x8 bool undefined ```python DType.name -> str ``` [#](#api-tensorplay.FileCheck) ### FileCheck class[Full reference ↗](/docs/generated/tensorplay.FileCheck.html) ```python class tensorplay.FileCheck ``` ```python check(self: tensorplay._C.FileCheck, test_string: str) → tensorplay._C.FileCheck ``` ```python check_count(self: tensorplay._C.FileCheck, test_string: str, count: SupportsInt | SupportsIndex, exactly: bool = False) → tensorplay._C.FileCheck ``` ```python check_dag(self: tensorplay._C.FileCheck, test_string: str) → tensorplay._C.FileCheck ``` ```python check_next(self: tensorplay._C.FileCheck, test_string: str) → tensorplay._C.FileCheck ``` ```python check_not(self: tensorplay._C.FileCheck, test_string: str) → tensorplay._C.FileCheck ``` ```python check_regex(self: tensorplay._C.FileCheck, test_string: str) → tensorplay._C.FileCheck ``` ```python check_same(self: tensorplay._C.FileCheck, test_string: str) → tensorplay._C.FileCheck ``` ```python check_source_highlighted(self: tensorplay._C.FileCheck, test_string: str) → tensorplay._C.FileCheck ``` ```python run(self: tensorplay._C.FileCheck, test_string: str) → None ``` [#](#api-tensorplay.finfo) ### finfo class[Full reference ↗](/docs/generated/tensorplay.finfo.html) ```python class tensorplay.finfo(dtype) ``` [#](#api-tensorplay.Future) ### Future class[Full reference ↗](/docs/generated/tensorplay.Future.html) ```python class tensorplay.Future ``` ```python add_done_callback(self: object, callback: collections.abc.Callable) → None ``` ```python done(self: tensorplay._C.Future) → bool ``` ```python is_done(self: tensorplay._C.Future) → bool ``` ```python set_exception(self: tensorplay._C.Future, result: object) → None ``` ```python set_result(self: tensorplay._C.Future, result: object) → None ``` ```python then(self: object, callback: collections.abc.Callable) → tensorplay._C.Future ``` ```python value(self: tensorplay._C.Future) → object ``` ```python wait(self: tensorplay._C.Future) → object ``` [#](#api-tensorplay.Generator) ### Generator class[Full reference ↗](/docs/generated/tensorplay.Generator.html) ```python class tensorplay.Generator(device='cpu') → Generator ``` Creates and returns a generator object that manages the state of the algorithm which produces pseudo random numbers. Used as a keyword argument in many in-place random sampling functions. Parameters: device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device for the generator. Returns: An tensorplay.Generator object. Return type: [Generator](#tensorplay.Generator) Example: ``` >>> g_cpu = tensorplay.Generator() >>> g_cuda = tensorplay.Generator(device='cuda') ``` ```python property device ``` Generator.device -> device Gets the current device of the generator. Example: ``` >>> g_cpu = tensorplay.Generator() >>> g_cpu.device device(type='cpu') ``` ```python get_state(self: tensorplay._C.Generator) → tensorplay::Tensor ``` ```python initial_seed(self: tensorplay._C.Generator) → int ``` ```python manual_seed(self: tensorplay._C.Generator, seed: SupportsInt | SupportsIndex) → int ``` ```python seed(self: tensorplay._C.Generator) → int ``` ```python set_state(self: tensorplay._C.Generator, new_state: tensorplay::Tensor) → None ``` [#](#api-tensorplay.GradScaler) ### GradScaler class[Full reference ↗](/docs/generated/tensorplay.GradScaler.html) ```python class tensorplay.GradScaler(device: str = 'cuda', init_scale: float = 65536.0, growth_factor: float = 2.0, backoff_factor: float = 0.5, growth_interval: int = 2000, enabled: bool = True) ``` An instance scaler of [GradScaler](#tensorplay.GradScaler). Helps perform the steps of gradient scaling conveniently. - scaler.scale(loss) multiplies a given loss by scaler’s current scale factor. - scaler.step(optimizer) safely unscales gradients and calls optimizer.step(). - scaler.update() updates scaler’s scale factor. Example: ``` # Creates a GradScaler once at the beginning of training. scaler = GradScaler() for epoch in epochs: for input, target in data: optimizer.zero_grad() output = model(input) loss = loss_fn(output, target) # Scales loss. Calls backward() on scaled loss to create scaled gradients. scaler.scale(loss).backward() # scaler.step() first unscales gradients of the optimizer's params. # If gradients don't contain infs/NaNs, optimizer.step() is then called, # otherwise, optimizer.step() is skipped. scaler.step(optimizer) # Updates the scale for next iteration. scaler.update() ``` scaler dynamically estimates the scale factor each iteration. To minimize gradient underflow, a large scale factor should be used. However, float16 values can “overflow” (become inf or NaN) if the scale factor is too large. Therefore, the optimal scale factor is the largest factor that can be used without incurring inf or NaN gradient values. scaler approximates the optimal scale factor over time by checking the gradients for infs and NaNs during every scaler.step(optimizer) (or optional separate scaler.unscale_(optimizer), see [unscale_()](#tensorplay.GradScaler.unscale_)). - If infs/NaNs are found, scaler.step(optimizer) skips the underlying optimizer.step() (so the params themselves remain uncorrupted) and update() multiplies the scale by backoff_factor. - If no infs/NaNs are found, scaler.step(optimizer) runs the underlying optimizer.step() as usual. If growth_interval unskipped iterations occur consecutively, update() multiplies the scale by growth_factor. Parameters: - device ([str](https://docs.python.org/3/builtins/stdtypes.html#str), optional, default="cuda") – Device type to use. Possible values are: ‘cuda’ and ‘cpu’. The type is the same as the type attribute of a [tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device). Thus, you may obtain the device type of a tensor using Tensor.device.type. - init_scale ([float](https://docs.python.org/3/builtins/functions.html#float), optional, default=2.**16) – Initial scale factor. - growth_factor ([float](https://docs.python.org/3/builtins/functions.html#float), optional, default=2.0) – Factor by which the scale is multiplied during [update()](#tensorplay.GradScaler.update) if no inf/NaN gradients occur for growth_interval consecutive iterations. - backoff_factor ([float](https://docs.python.org/3/builtins/functions.html#float), optional, default=0.5) – Factor by which the scale is multiplied during [update()](#tensorplay.GradScaler.update) if inf/NaN gradients occur in an iteration. - growth_interval ([int](https://docs.python.org/3/builtins/functions.html#int), optional, default=2000) – Number of consecutive iterations without inf/NaN gradients that must occur for the scale to be multiplied by growth_factor. - enabled ([bool](https://docs.python.org/3/builtins/functions.html#bool), optional) – If False, disables gradient scaling. [step()](#tensorplay.GradScaler.step) simply invokes the underlying optimizer.step(), and other methods become no-ops. Default: True ```python get_backoff_factor() → float ``` Return a Python float containing the scale backoff factor. ```python get_growth_factor() → float ``` Return a Python float containing the scale growth factor. ```python get_growth_interval() → int ``` Return a Python int containing the growth interval. ```python get_scale() → float ``` Return a Python float containing the current scale, or 1.0 if scaling is disabled. ```python is_enabled() → bool ``` Return a bool indicating whether this instance is enabled. ```python load_state_dict(state_dict: dict[str, Any]) → None ``` Load the scaler state. If this instance is disabled, [load_state_dict()](#tensorplay.GradScaler.load_state_dict) is a no-op. Parameters: state_dict ([dict](https://docs.python.org/3/builtins/stdtypes.html#dict)) – scaler state. Should be an object returned from a call to [state_dict()](#tensorplay.GradScaler.state_dict). ```python scale(outputs: Tensor) → Tensor ``` ```python scale(outputs: list[Tensor]) → list[Tensor] ``` ```python scale(outputs: tuple[Tensor, ...]) → tuple[Tensor, ...] ``` ```python scale(outputs: Iterable[tensorplay.Tensor]) → Iterable[tensorplay.Tensor] ``` Multiplies (‘scales’) a tensor or list of tensors by the scale factor. Returns scaled outputs. If this instance of [GradScaler](#tensorplay.GradScaler) is not enabled, outputs are returned unmodified. Parameters: outputs ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) or iterable of Tensors) – Outputs to scale. ```python set_backoff_factor(new_factor: float) → None ``` Set a new scale backoff factor. Parameters: new_scale ([float](https://docs.python.org/3/builtins/functions.html#float)) – Value to use as the new scale backoff factor. ```python set_growth_factor(new_factor: float) → None ``` Set a new scale growth factor. Parameters: new_scale ([float](https://docs.python.org/3/builtins/functions.html#float)) – Value to use as the new scale growth factor. ```python set_growth_interval(new_interval: int) → None ``` Set a new growth interval. Parameters: new_interval ([int](https://docs.python.org/3/builtins/functions.html#int)) – Value to use as the new growth interval. ```python state_dict() → dict[str, Any] ``` Return the state of the scaler as a [dict](https://docs.python.org/3/builtins/stdtypes.html#dict). It contains five entries: - "scale" - a Python float containing the current scale - "growth_factor" - a Python float containing the current growth factor - "backoff_factor" - a Python float containing the current backoff factor - "growth_interval" - a Python int containing the current growth interval - "_growth_tracker" - a Python int containing the number of recent consecutive unskipped steps. If this instance is not enabled, returns an empty dict. > **Note** > > If you wish to checkpoint the scaler’s state after a particular iteration, state_dict() should be called after update(). ```python step(optimizer: Optimizer, *args: Any, **kwargs: Any) → Any ``` Invoke unscale_(optimizer) followed by parameter update, if gradients are not infs/NaN. [step()](#tensorplay.GradScaler.step) carries out the following two operations: - Internally invokes unscale_(optimizer) (unless [unscale_()](#tensorplay.GradScaler.unscale_) was explicitly called for optimizer earlier in the iteration). As part of the [unscale_()](#tensorplay.GradScaler.unscale_), gradients are checked for infs/NaNs. - If no inf/NaN gradients are found, invokes optimizer.step() using the unscaled gradients. Otherwise, optimizer.step() is skipped to avoid corrupting the params. *args and **kwargs are forwarded to optimizer.step(). Returns the return value of optimizer.step(*args, **kwargs). Parameters: - optimizer (tensorplay.optim.Optimizer) – Optimizer that applies the gradients. - args – Any arguments. - kwargs – Any keyword arguments. > **Warning** > > Closure use is not currently supported. ```python unscale_(optimizer: Optimizer) → None ``` Divides (“unscales”) the optimizer’s gradient tensors by the scale factor. [unscale_()](#tensorplay.GradScaler.unscale_) is optional, serving cases where you need to modify or inspect gradients between the backward pass(es) and [step()](#tensorplay.GradScaler.step). If [unscale_()](#tensorplay.GradScaler.unscale_) is not called explicitly, gradients will be unscaled automatically during [step()](#tensorplay.GradScaler.step). Simple example, using [unscale_()](#tensorplay.GradScaler.unscale_) to enable clipping of unscaled gradients: ``` ... scaler.scale(loss).backward() scaler.unscale_(optimizer) tensorplay.nn.utils.clip_grad_norm_(model.parameters(), max_norm) scaler.step(optimizer) scaler.update() ``` Parameters: optimizer (tensorplay.optim.Optimizer) – Optimizer that owns the gradients to be unscaled. > **Warning** > > unscale_() should only be called once per optimizer per step() call, and only after all gradients for that optimizer’s assigned parameters have been accumulated. Calling unscale_() twice for a given optimizer between each step() triggers a RuntimeError. ```python update(new_scale: float | Tensor | None = None) → None ``` Update the scale factor. If any optimizer steps were skipped the scale is multiplied by backoff_factor to reduce it. If growth_interval unskipped iterations occurred consecutively, the scale is multiplied by growth_factor to increase it. Passing new_scale sets the new scale value manually. (new_scale is not used directly, it’s used to fill GradScaler’s internal scale tensor. So if new_scale was a tensor, later in-place changes to that tensor will not further affect the scale GradScaler uses internally.) Parameters: new_scale (float or [tensorplay.Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional, default=None) – New scale factor. > **Warning** > > update() should only be called at the end of the iteration, after scaler.step(optimizer) has been invoked for all optimizers used this iteration. [#](#api-tensorplay.iinfo) ### iinfo class[Full reference ↗](/docs/generated/tensorplay.iinfo.html) ```python class tensorplay.iinfo(dtype) ``` [#](#api-tensorplay.Layout) ### Layout class[Full reference ↗](/docs/generated/tensorplay.Layout.html) ```python class tensorplay.Layout(*values) ``` tensor.layout returns one of these values; dense tensors report STRIDED. ```python as_integer_ratio() ``` Return a pair of integers, whose ratio is equal to the original int. The ratio is in lowest terms and has a positive denominator. ``` >>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1) ``` ```python bit_count() ``` Number of ones in the binary representation of the absolute value of self. Also known as the population count. ``` >>> bin(13) '0b1101' >>> (13).bit_count() 3 ``` ```python bit_length() ``` Number of bits necessary to represent self in binary. ``` >>> bin(37) '0b100101' >>> (37).bit_length() 6 ``` ```python conjugate() ``` Returns self, the complex conjugate of any int. ```python denominator ``` the denominator of a rational number in lowest terms ```python classmethod from_bytes(bytes, byteorder='big', *, signed=False) ``` ```python imag ``` the imaginary part of a complex number ```python is_integer() ``` Returns True. Exists for duck type compatibility with float.is_integer. ```python numerator ``` the numerator of a rational number in lowest terms ```python real ``` the real part of a complex number ```python to_bytes(length=1, byteorder='big', *, signed=False) ``` [#](#api-tensorplay.MemoryFormat) ### MemoryFormat class[Full reference ↗](/docs/generated/tensorplay.MemoryFormat.html) ```python class tensorplay.MemoryFormat(*values) ``` ```python as_integer_ratio() ``` Return a pair of integers, whose ratio is equal to the original int. The ratio is in lowest terms and has a positive denominator. ``` >>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1) ``` ```python bit_count() ``` Number of ones in the binary representation of the absolute value of self. Also known as the population count. ``` >>> bin(13) '0b1101' >>> (13).bit_count() 3 ``` ```python bit_length() ``` Number of bits necessary to represent self in binary. ``` >>> bin(37) '0b100101' >>> (37).bit_length() 6 ``` ```python conjugate() ``` Returns self, the complex conjugate of any int. ```python denominator ``` the denominator of a rational number in lowest terms ```python classmethod from_bytes(bytes, byteorder='big', *, signed=False) ``` ```python imag ``` the imaginary part of a complex number ```python is_integer() ``` Returns True. Exists for duck type compatibility with float.is_integer. ```python numerator ``` the numerator of a rational number in lowest terms ```python real ``` the real part of a complex number ```python to_bytes(length=1, byteorder='big', *, signed=False) ``` [#](#api-tensorplay.Node) ### Node class[Full reference ↗](/docs/generated/tensorplay.Node.html) ```python class tensorplay.Node ``` ```python add_post_hook(self: tensorplay._C.Node, hook: collections.abc.Callable[[list[tensorplay._C.TensorBase], list[tensorplay._C.TensorBase]], collections.abc.Sequence[tensorplay._C.TensorBase]]) → None ``` ```python add_pre_hook(self: tensorplay._C.Node, hook: collections.abc.Callable[[list[tensorplay._C.TensorBase]], collections.abc.Sequence[tensorplay._C.TensorBase]]) → None ``` ```python name(self: tensorplay._C.Node) → str ``` [#](#api-tensorplay.QScheme) ### QScheme class[Full reference ↗](/docs/generated/tensorplay.QScheme.html) ```python class tensorplay.QScheme(*values) ``` Quantization scheme attached to a quantized tensor’s quantizer. ```python as_integer_ratio() ``` Return a pair of integers, whose ratio is equal to the original int. The ratio is in lowest terms and has a positive denominator. ``` >>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1) ``` ```python bit_count() ``` Number of ones in the binary representation of the absolute value of self. Also known as the population count. ``` >>> bin(13) '0b1101' >>> (13).bit_count() 3 ``` ```python bit_length() ``` Number of bits necessary to represent self in binary. ``` >>> bin(37) '0b100101' >>> (37).bit_length() 6 ``` ```python conjugate() ``` Returns self, the complex conjugate of any int. ```python denominator ``` the denominator of a rational number in lowest terms ```python classmethod from_bytes(bytes, byteorder='big', *, signed=False) ``` ```python imag ``` the imaginary part of a complex number ```python is_integer() ``` Returns True. Exists for duck type compatibility with float.is_integer. ```python numerator ``` the numerator of a rational number in lowest terms ```python real ``` the real part of a complex number ```python to_bytes(length=1, byteorder='big', *, signed=False) ``` [#](#api-tensorplay.Scalar) ### Scalar class[Full reference ↗](/docs/generated/tensorplay.Scalar.html) ```python class tensorplay.Scalar ``` ```python is_complex(self: tensorplay._C.Scalar) → bool ``` [#](#api-tensorplay.Size) ### Size class[Full reference ↗](/docs/generated/tensorplay.Size.html) ```python class tensorplay.Size(iterable=(), /) ``` Sequence of tensor dimension sizes (tuple subclass). ```python count(value, /) ``` Return number of occurrences of value. ```python index(value, start=0, stop=9223372036854775807, /) ``` Return first index of value. Raises ValueError if the value is not present. ```python numel() ``` Product of the dimensions. [#](#api-tensorplay.SymBool) ### SymBool class[Full reference ↗](/docs/generated/tensorplay.SymBool.html) ```python class tensorplay.SymBool ``` ```python expect_bool(self: tensorplay._C.SymBool) → bool ``` ```python guard_bool(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) → bool ``` ```python guard_or_false(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) → bool ``` ```python guard_or_true(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) → bool ``` ```python guard_size_oblivious(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) → bool ``` ```python has_hint(self: tensorplay._C.SymBool) → bool ``` ```python is_symbolic(self: tensorplay._C.SymBool) → bool ``` ```python maybe_as_bool(self: tensorplay._C.SymBool) → bool | None ``` ```python statically_known_true(self: tensorplay._C.SymBool, file: str = '', line: SupportsInt | SupportsIndex = 0) → bool ``` ```python sym_and(self: tensorplay._C.SymBool, arg0: tensorplay._C.SymBool) → tensorplay._C.SymBool ``` ```python sym_not(self: tensorplay._C.SymBool) → tensorplay._C.SymBool ``` ```python sym_or(self: tensorplay._C.SymBool, arg0: tensorplay._C.SymBool) → tensorplay._C.SymBool ``` ```python sym_xor(self: tensorplay._C.SymBool, arg0: tensorplay._C.SymBool) → tensorplay._C.SymBool ``` ```python static symbolic(name: str, hint: bool | None = None) → tensorplay._C.SymBool ``` ```python to_sym_float(self: tensorplay._C.SymBool) → tensorplay._C.SymFloat ``` ```python to_sym_int(self: tensorplay._C.SymBool) → tensorplay._C.SymInt ``` [#](#api-tensorplay.SymFloat) ### SymFloat class[Full reference ↗](/docs/generated/tensorplay.SymFloat.html) ```python class tensorplay.SymFloat ``` ```python acos(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python as_integer_ratio(self: tensorplay._C.SymFloat) → object ``` ```python asin(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python atan(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python ceil(self: tensorplay._C.SymFloat) → tensorplay._C.SymInt ``` ```python conjugate(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python cos(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python cosh(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python expect_float(self: tensorplay._C.SymFloat) → float ``` ```python floor(self: tensorplay._C.SymFloat) → tensorplay._C.SymInt ``` ```python guard_float(self: tensorplay._C.SymFloat, file: str = '', line: SupportsInt | SupportsIndex = 0) → float ``` ```python has_hint(self: tensorplay._C.SymFloat) → bool ``` ```python hex(self: tensorplay._C.SymFloat) → object ``` ```python is_integer(self: tensorplay._C.SymFloat) → tensorplay._C.SymBool ``` ```python is_symbolic(self: tensorplay._C.SymFloat) → bool ``` ```python log2(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python max(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python maybe_as_float(self: tensorplay._C.SymFloat) → float | None ``` ```python min(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python round(self: tensorplay._C.SymFloat, ndigits: object = None) → object ``` ```python sin(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python sinh(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python sqrt(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python sym_eq(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymBool ``` ```python sym_float(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python sym_ge(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymBool ``` ```python sym_gt(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymBool ``` ```python sym_int(self: tensorplay._C.SymFloat) → tensorplay._C.SymInt ``` ```python sym_le(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymBool ``` ```python sym_lt(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymBool ``` ```python sym_ne(self: tensorplay._C.SymFloat, arg0: tensorplay._C.SymFloat) → tensorplay._C.SymBool ``` ```python static symbolic(name: str, hint: SupportsFloat | SupportsIndex | None = None) → tensorplay._C.SymFloat ``` ```python tan(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python tanh(self: tensorplay._C.SymFloat) → tensorplay._C.SymFloat ``` ```python trunc(self: tensorplay._C.SymFloat) → tensorplay._C.SymInt ``` [#](#api-tensorplay.SymInt) ### SymInt class[Full reference ↗](/docs/generated/tensorplay.SymInt.html) ```python class tensorplay.SymInt ``` ```python as_integer_ratio(self: tensorplay._C.SymInt) → tuple[tensorplay._C.SymInt, int] ``` ```python bit_length(self: tensorplay._C.SymInt) → int ``` ```python ceil(self: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python clone(self: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python conjugate(self: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python expect_int(self: tensorplay._C.SymInt) → int ``` ```python floor(self: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python guard_int(self: tensorplay._C.SymInt, file: str = '', line: SupportsInt | SupportsIndex = 0) → int ``` ```python has_hint(self: tensorplay._C.SymInt) → bool ``` ```python is_heap_allocated(self: tensorplay._C.SymInt) → bool ``` ```python is_same(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → bool ``` ```python is_symbolic(self: tensorplay._C.SymInt) → bool ``` ```python max(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python maybe_as_int(self: tensorplay._C.SymInt) → int | None ``` ```python min(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python pow_by_natural(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python round(self: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` ```python sym_eq(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymBool ``` ```python sym_float(self: tensorplay._C.SymInt) → tensorplay._C.SymFloat ``` ```python sym_ge(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymBool ``` ```python sym_gt(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymBool ``` ```python sym_le(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymBool ``` ```python sym_lt(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymBool ``` ```python sym_ne(self: tensorplay._C.SymInt, arg0: tensorplay._C.SymInt) → tensorplay._C.SymBool ``` ```python static symbolic(name: str, hint: SupportsInt | SupportsIndex | None = None) → tensorplay._C.SymInt ``` ```python to_sym_float(self: tensorplay._C.SymInt) → tensorplay._C.SymFloat ``` ```python trunc(self: tensorplay._C.SymInt) → tensorplay._C.SymInt ``` [#](#api-tensorplay.UntypedStorage) ### UntypedStorage class[Full reference ↗](/docs/generated/tensorplay.UntypedStorage.html) ```python class tensorplay.UntypedStorage ``` ```python data_ptr(self: tensorplay._C.UntypedStorage) → int ``` ```python nbytes(self: tensorplay._C.UntypedStorage) → int ``` ```python resizable(self: tensorplay._C.UntypedStorage) → bool ``` ```python resize_(self: tensorplay._C.UntypedStorage, nbytes: SupportsInt | SupportsIndex) → tensorplay._C.UntypedStorage ``` ```python size(self: tensorplay._C.UntypedStorage) → int ``` ## Attributes 1 [#](#api-tensorplay.Tensor) ### Tensor attribute[Full reference ↗](/docs/generated/tensorplay.Tensor.html) ```python tensorplay.Tensor ``` alias of [Tensor](#tensorplay.Tensor) ## Exceptions 1 [#](#api-tensorplay.DeviceMismatchError) ### DeviceMismatchError exception[Full reference ↗](/docs/generated/tensorplay.DeviceMismatchError.html) ```python exception tensorplay.DeviceMismatchError ```