There seems to be a bug somewhere.

Try repeating the filtering over and over on the same matrix for 20 iteration.  This work if the input has dimensions that are a multiple of 16 in both axis, so a 16x16 will produce correct results.

Next try a 32x16, now something is broken.