Skip to main content

ClikaRT::ops::constant_pad

function

constant_pad()

Tensor constant_pad(
    Tensor x,
    ClikaRT::Span<const ScalarOrTensor> pad,
    std::optional<ScalarOrTensor> value = std::nullopt
)

pad with a constant fill.

Pads each axis by interleaved (lo, hi) pairs in layout order: pair i pads axis i; fewer pairs than the rank pads only the leading axes; a negative width crops that side. Widths are literals or 0-D integer Tensors. Copies.

Parameters

  • value: the fill; absent = 0. Default: absent.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when the pair list exceeds the rank or a crop exceeds the extent (code_name() carries the reason).

Returns: a new tensor with each padded axis grown by lo + hi.

auto padded = ClikaRT::ops::constant_pad(img, {0,0, 1,1, 1,1}); // H and W by 1

Declared in ClikaRT/compute/ops.h, line 3253