def ios16_sparse_params_to_ios18(sparse_params: SparseParamsIos16) -> SparseParams:
    """
    The iOS18 constexpr_sparse_to_dense no longer accepts `shape` param. Instead, the `mask` param
    has shape info. So we need to convert the old bit-packed `mask` to new uint1 `mask`.
    """
    if not isinstance(sparse_params, SparseParamsIos16):
        raise ValueError("Invalid type of params")

    mask = (
        np.unpackbits(sparse_params.mask, count=np.prod(sparse_params.shape), bitorder="little")
        .reshape(sparse_params.shape)
        .astype(types.np_uint1_dtype)
    )

    return SparseParams(nonzero_data=sparse_params.nonzero_data, mask=mask)

    The iOS18 constexpr_sparse_to_dense no longer accepts `shape` param. Instead, the `mask` param
    has shape info. So we need to convert the old bit-packed `mask` to new uint1 `mask`.
    
coremltools/optimize/_utils.py