Rate this Page

Function torch ::stable::pad#

Function Documentation#

inline torch::stable::Tensor torch::stable::pad(const torch::stable::Tensor &self, torch::headeronly::IntHeaderOnlyArrayRef pad, const std::string &mode = "constant", double value = 0.0)#

Stable version of the pad.default op.

Pads the input tensor according to the specified padding sizes. The padding is applied symmetrically to each dimension, with the padding sizes specified in reverse order (last dimension first).

Minimum compatible version: PyTorch 2.9.

Note

The pad parameter is typed not yet header-only.

Parameters:
  • self – The input tensor to pad.

  • pad – The padding sizes for each dimension (in pairs, starting from the last dimension).

  • mode – The padding mode: “constant”, “reflect”, “replicate”, or “circular”. Defaults to “constant”.

  • value – The fill value for constant padding. Defaults to 0.0.

Returns:

A new padded tensor.