TensorPlay
Reference guides
Copy
View MarkdownDownload .md

tensorplay.nn.functional

Convolution functions

tensorplay.nn.functional.conv1d

Applies a 1D convolution over an input signal composed of several input planes.

tensorplay.nn.functional.conv2d

Applies a 2D convolution over an input image composed of several input planes.

tensorplay.nn.functional.conv3d

Applies a 3D convolution over an input image composed of several input planes.

tensorplay.nn.functional.conv_transpose1d

tensorplay.nn.functional.conv_transpose2d

tensorplay.nn.functional.conv_transpose3d

tensorplay.nn.functional.unfold

Extract sliding local blocks from a batched input tensor (torch F.unfold, i.e. aten::im2col).

tensorplay.nn.functional.fold

Combine an array of sliding local blocks into a tensor containing them all (torch F.fold, i.e. aten::col2im).

Pooling functions

tensorplay.nn.functional.avg_pool1d

avg_pool1d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) -> Tensor

tensorplay.nn.functional.avg_pool2d

tensorplay.nn.functional.avg_pool3d

avg_pool3d(input, kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None) -> Tensor

tensorplay.nn.functional.max_pool1d

max_pool1d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False) -> Tensor

tensorplay.nn.functional.max_pool2d

tensorplay.nn.functional.max_pool3d

max_pool3d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False) -> Tensor

tensorplay.nn.functional.max_unpool1d

Compute a partial inverse of MaxPool1d.

tensorplay.nn.functional.max_unpool2d

Compute a partial inverse of MaxPool2d.

tensorplay.nn.functional.max_unpool3d

Compute a partial inverse of MaxPool3d.

tensorplay.nn.functional.lp_pool1d

Apply a 1D power-average pooling over an input signal.

tensorplay.nn.functional.lp_pool2d

Apply a 2D power-average pooling over an input signal.

tensorplay.nn.functional.lp_pool3d

Apply a 3D power-average pooling over an input signal.

tensorplay.nn.functional.adaptive_max_pool1d

tensorplay.nn.functional.adaptive_max_pool2d

tensorplay.nn.functional.adaptive_avg_pool1d

tensorplay.nn.functional.adaptive_avg_pool2d

tensorplay.nn.functional.adaptive_avg_pool3d

Apply a 3D adaptive average pooling over an input signal.

tensorplay.nn.functional.fractional_max_pool2d

Applies 2D fractional max pooling over an input signal.

tensorplay.nn.functional.fractional_max_pool3d

Applies 3D fractional max pooling over an input signal.

Attention Mechanisms

tensorplay.nn.functional.scaled_dot_product_attention

scaled_dot_product_attention(query, key, value, attn_mask=None, dropout_p=0.0, is_causal=False, scale=None, backend=None) -> Tensor

Non-linear activation functions

tensorplay.nn.functional.threshold

Apply a threshold to each element of the input Tensor.

tensorplay.nn.functional.relu

tensorplay.nn.functional.hardtanh

tensorplay.nn.functional.hardswish

tensorplay.nn.functional.relu6

ReLU6: \(\min(\max(0, x), 6)\) — torch.nn.functional.relu6.

tensorplay.nn.functional.elu

tensorplay.nn.functional.selu

tensorplay.nn.functional.celu

tensorplay.nn.functional.leaky_relu

tensorplay.nn.functional.prelu

tensorplay.nn.functional.rrelu

Randomized leaky ReLU.

tensorplay.nn.functional.glu

Gated Linear Unit: \(a * \sigma(b)\) where the input is split in half along dim.

tensorplay.nn.functional.gelu

When approximate is 'none', applies \(\text{GELU}(x) = x * \Phi(x)\); 'tanh' uses the tanh estimation.

tensorplay.nn.functional.logsigmoid

Applies element-wise \(\text{LogSigmoid}(x_i) = \log \left(\frac{1}{1 + \exp(-x_i)}\right)\)

tensorplay.nn.functional.hardshrink

Applies the hard shrinkage function element-wise.

tensorplay.nn.functional.tanhshrink

Applies element-wise, \(\text{Tanhshrink}(x) = x - \text{Tanh}(x)\)

tensorplay.nn.functional.softsign

Applies element-wise, the function \(\text{SoftSign}(x) = \frac{x}{1 + |x|}\)

tensorplay.nn.functional.softplus

tensorplay.nn.functional.softmin

Apply a softmin function.

tensorplay.nn.functional.softmax

tensorplay.nn.functional.softshrink

Applies the soft shrinkage function element-wise.

tensorplay.nn.functional.gumbel_softmax

Sample from the Gumbel-Softmax distribution and optionally discretize.

tensorplay.nn.functional.log_softmax

tensorplay.nn.functional.tanh

Applies element-wise \(\text{Tanh}(x) = \frac{\exp(x) - \exp(-x)}{\exp(x) + \exp(-x)}\)

tensorplay.nn.functional.sigmoid

Applies the element-wise function \(\text{Sigmoid}(x) = \frac{1}{1 + \exp(-x)}\)

tensorplay.nn.functional.hardsigmoid

tensorplay.nn.functional.silu

Apply the Sigmoid Linear Unit (SiLU) function, element-wise.

tensorplay.nn.functional.mish

tensorplay.nn.functional.batch_norm

tensorplay.nn.functional.group_norm

tensorplay.nn.functional.instance_norm

tensorplay.nn.functional.layer_norm

tensorplay.nn.functional.local_response_norm

Apply local response normalization over an input signal.

tensorplay.nn.functional.rms_norm

Apply Root Mean Square Layer Normalization — composed per the ATen rms_norm composite (fp32 compute for reduced dtypes).

tensorplay.nn.functional.normalize

Performs \(L_p\) normalization over the specified dimension — torch.nn.functional.normalize divides by clamp_min(norm, eps).

Linear functions

tensorplay.nn.functional.linear

Applies a linear transformation to the incoming data: \(y = xA^T + b\).

tensorplay.nn.functional.bilinear

Dropout functions

tensorplay.nn.functional.dropout

tensorplay.nn.functional.alpha_dropout

tensorplay.nn.functional.feature_alpha_dropout

Randomly masks out entire channels, setting activations to the negative saturation value of the SELU activation function.

tensorplay.nn.functional.dropout1d

Randomly zero out entire channels (a channel is a 1D feature map).

tensorplay.nn.functional.dropout2d

tensorplay.nn.functional.dropout3d

Sparse functions

tensorplay.nn.functional.embedding

tensorplay.nn.functional.embedding_bag

Compute sums, means or maxes of bags of embeddings.

tensorplay.nn.functional.one_hot

Returns long tensor shaped tensor.shape + (num_classes,) with a 1 at each label position — port of ATen one_hot.

Distance functions

tensorplay.nn.functional.pairwise_distance

Computes the pairwise distance between input vectors.

tensorplay.nn.functional.cosine_similarity

Returns cosine similarity between x1 and x2, computed along dim.

tensorplay.nn.functional.pdist

Computes the pairwise distance between rows of input.

Loss functions

tensorplay.nn.functional.binary_cross_entropy

Compute Binary Cross Entropy between the target and input probabilities.

tensorplay.nn.functional.binary_cross_entropy_with_logits

Compute Binary Cross Entropy between target and input logits.

tensorplay.nn.functional.poisson_nll_loss

Compute the Poisson negative log likelihood loss.

tensorplay.nn.functional.cosine_embedding_loss

Compute the cosine embedding loss.

tensorplay.nn.functional.cross_entropy

Compute the cross entropy loss between input logits and target.

tensorplay.nn.functional.ctc_loss

Compute the Connectionist Temporal Classification loss.

tensorplay.nn.functional.gaussian_nll_loss

Compute the Gaussian negative log likelihood loss.

tensorplay.nn.functional.hinge_embedding_loss

Compute the hinge embedding loss.

tensorplay.nn.functional.kl_div

Compute the KL Divergence loss.

tensorplay.nn.functional.l1_loss

Compute the L1 loss, with optional weighting.

tensorplay.nn.functional.linear_cross_entropy

Compute cross entropy between input, transformed linearly, and target.

tensorplay.nn.functional.mse_loss

tensorplay.nn.functional.margin_ranking_loss

Compute the margin ranking loss.

tensorplay.nn.functional.multilabel_margin_loss

Compute the multilabel margin loss.

tensorplay.nn.functional.multilabel_soft_margin_loss

Compute the multilabel soft margin loss.

tensorplay.nn.functional.multi_margin_loss

Compute the multi margin loss, with optional weighting.

tensorplay.nn.functional.nll_loss

The negative log likelihood loss.

tensorplay.nn.functional.huber_loss

Compute the Huber loss, with optional weighting.

tensorplay.nn.functional.smooth_l1_loss

Compute the Smooth L1 loss.

tensorplay.nn.functional.soft_margin_loss

Compute the soft margin loss.

tensorplay.nn.functional.triplet_margin_loss

Compute the triplet loss between given input tensors and a margin greater than 0.

tensorplay.nn.functional.triplet_margin_with_distance_loss

Compute the triplet margin loss using a custom distance function.

Vision functions

tensorplay.nn.functional.pixel_shuffle

Rearranges elements in a tensor of shape (*, C x r^2, H, W) to a tensor of shape (*, C, H x r, W x r).

tensorplay.nn.functional.pixel_unshuffle

Reverses the pixel_shuffle() transformation: (*, C, H x r, W x r) -> (*, C x r^2, H, W).

tensorplay.nn.functional.pad

Pads tensor.

tensorplay.nn.functional.interpolate

interpolate(input, size=None, scale_factor=None, mode='nearest', align_corners=None) -> Tensor

tensorplay.nn.functional.upsample

Upsamples the input to the given size or scale_factor.

tensorplay.nn.functional.upsample_nearest

Upsamples the input using nearest neighbours.

tensorplay.nn.functional.upsample_bilinear

Upsamples the input using bilinear upsampling.

tensorplay.nn.functional.grid_sample

Compute grid sample.

tensorplay.nn.functional.affine_grid

Generate 2D or 3D flow field (sampling grid), given a batch of affine matrices theta.

data_parallel

Low-Precision functions

TensorPlay-specific additions

DType

Members:

Tensor

alias of TensorBase

adaptive_max_pool1d_with_indices

Applies a 1D adaptive max pooling over an input signal, returning (output, indices).

adaptive_max_pool2d_with_indices

Applies a 2D adaptive max pooling over an input signal composed of several input planes, returning (output, indices).

adaptive_max_pool3d_with_indices

Applies a 3D adaptive max pooling over an input signal, returning (output, indices).

channel_shuffle

Divide the channels in a tensor into g groups and rearrange them as in ShuffleNet: (*, C, H, W) -> (*, C, H, W) with channels interleaved across groups.

conv_tbc

Applies a 1D convolution over an input of shape (T, B, C) along the time dimension (torch.conv_tbc).

flatten

fractional_max_pool2d_with_indices

Applies 2D fractional max pooling over an input signal composed of several input planes, returning (output, indices).

fractional_max_pool3d_with_indices

Applies 3D fractional max pooling over an input signal composed of several input planes, returning (output, indices).

max_pool1d_with_indices

Applies a 1D max pooling over an input signal, returning (output, indices).

max_pool2d_with_indices

Applies a 2D max pooling over an input composed of several input planes, returning (output, indices).

max_pool3d_with_indices

Applies a 3D max pooling over an input signal, returning (output, indices).

multi_head_attention_forward

torch-compatible multi_head_attention_forward.

native_channel_shuffle

Native channel shuffle primitive (torch.native_channel_shuffle).

Ask DeepWiki