When a stencil reads beyond an array’s edge, zero padding treats the missing value as 0—as if the data sat inside a black border. This boundary choice affects the result at the edges. section 9.8 section 9.6
Unlike skipping edge outputs, zero padding keeps those positions and supplies zero for missing neighbors. With stride 1, CNN “same padding” keeps the output dimensions equal to the input dimensions. section 9.8 section 9.6
A partial matrix tile
If a matrix dimension is not a multiple of the tile size, threads loading beyond the matrix bounds place 0.0 in the tile. These zeros do not change the dot product, so the tiled calculation remains correct. section 12.5
Figure 9.10 Zero padding in 2D. The highlighted rectangle marks the actual input grid. Every position outside it (top, bottom, left, right, and the four corner regions) reads as 0, as if the grid were embedded in a sea of zeros.

The diagram shows the 2D input grid surrounded by positions that read as zero, including its corners. section 9.8


