Unify some of the packing kernels between backends.