Layernorm was not designed for images, thus it works with “last dimension” tensors usual elsewhere. Technically, it will work with two permute() calls, how well it substitutes batchnorm is another matter…