Rate this Page

Function torch ::stable::unsqueeze#

Function Documentation#

inline torch::stable::Tensor torch::stable::unsqueeze(const torch::stable::Tensor &self, int64_t dim)#

Stable version of the unsqueeze op.

Returns a new tensor with a dimension of size one inserted at the specified position. The returned tensor shares the same underlying data with the input tensor.

Minimum compatible version: PyTorch 2.9.

Parameters:
  • self – The input tensor.

  • dim – The index at which to insert values are supported.

Returns:

A tensor with an additional dimension.