Warning

IPaddingLayer is deprecated in TensorRT 8.2. Use ISliceLayer to pad the tensor, which supports new non-constant, reflects padding mode and clamp, and supports padding output with dynamic shape.

Pads with zeros (or trims) an input tensor along the two innermost dimensions and store the result in an output tensor.

## Attributes¶

pre_padding_nd the amount of pre-padding to use for each dimension. If positive, the tensor is pad with zeros, otherwise, it’s trimmed.

post_padding_nd the amount of post-padding to use for each dimension. If positive, the tensor is pad with zeros, otherwise, it’s trimmed.

## Inputs¶

input: tensor of type T.

## Outputs¶

output: tensor of type T.

## Data Types¶

T: int8, int32, float16, float32

## Shape Information¶

input is a tensor with a shape of $$[a_0,...,a_{n-1}], \, n \geq 4$$

output is a tensor with a shape of $$[b_0,...,b_{n-1}]$$, where:

$\begin{split}p_j^{pre} - \text{pre padding at spatial dimension j}\\ p_j^{post} - \text{post padding at spatial dimension j}\\\end{split}$
$\begin{split}b_i = \begin{cases} a_i, & 0 \leq i < n-2 \\ a_i + p_j^{pre} + p_j^{post}, & n-2 \leq i < n, & j=i-(n-2) \end{cases}\end{split}$

## Volume Limits¶

input and output can have up to $$2^{31}-1$$ elements.

## Examples¶

in1 = network.add_input("input1", dtype=trt.float32, shape=(1, 1, 3, 5))
network.mark_output(layer.get_output(0))

inputs[in1.name] = np.array(
[[[[-3.0, -2.0, -1.0, 10.0, -25.0], [-4.0, -9.0, -1.0, 10.0, -25.0], [0.0, 1.0, 2.0, -2.0, -1.0]]]]
)

outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = np.array(
[
[
[
[0.0, 0.0, 0.0, -4.0, -9.0, -1.0],
[0.0, 0.0, 0.0, 0.0, 1.0, 2.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
]
]
]
)