def test_k_means_rounding_no_warnings():
    """
    Test to ensure that no overflow warnings are raised when using rounding.
    Since rounding will require some sort of multiplication by 10^d (e.g. d=4),
    it could lead to overflow warnings by numpy if proper up-casting of fp16 values
    is not handled. This test uses weight values that are "high" to test this scenario.
    """
    model = torch.nn.Linear(4, 1, dtype=torch.float16)
    weight = torch.tensor([[1000.1, 53.2, 23.4, 50000.12]], dtype=torch.float16)
    config = KMeansConfig(n_bits=2, enable_fast_kmeans_mode=True, rounding_precision=4)
    with torch.no_grad():
        model.weight.copy_(weight)
        SequentialKMeans.cluster_weights(model, config)

    Test to ensure that no overflow warnings are raised when using rounding.
    Since rounding will require some sort of multiplication by 10^d (e.g. d=4),
    it could lead to overflow warnings by numpy if proper up-casting of fp16 values
    is not handled. This test uses weight values that are "high" to test this scenario.
    
coremltools/test/optimize/torch/test_utils/test_k_means.py