Make kernel wrappers independent of the number of layers.