Added masked kernel to enable use of different kernels along different dimensions.