Output of affine grid

In spatial transformers, we multiply grid coordinates with matrix to get new co-ordinates. So for example if size of image is 28*28. Then grid co-ordinates would be (x,y) where 0 $0 \leq x \leq 27$ and $0 \leq y \leq 27$. Then after multiplication we would get different co-ordinates which could be fractional. But output of affine grid seems to be always in 0,1. Does any how to interpret the output of affine grid and how it is used in conjunction in grid sample.

affine_grid should mostly return grid locations ins [-1, 1], which represent the sampling pixel locations normalized by the image dimension. The value [-1, -1] represents the left-top pixel, while [1, 1] is the right-bottom one. Values out of this range will be using the padding mode in grid_sample.