Rate this Page

Function torch ::stable::flatten#

Function Documentation#

inline torch::stable::Tensor torch::stable::flatten(const torch::stable::Tensor &self, int64_t start_dim = 0, int64_t end_dim = -1)#

Stable version of the flatten.using_ints op.

Flattens the input tensor by reshaping it into a one-dimensional tensor. If start_dim or end_dim are specified, only dimensions starting from start_dim to end_dim are flattened.

Minimum compatible version: PyTorch 2.9.

Parameters:
  • self – The input tensor to flatten.

  • start_dim – The first dimension to flatten. Defaults to 0.

  • end_dim – The last dimension to flatten. Defaults to -1 (last dim).

Returns:

A flattened tensor.