def test_vector_palettization_skip_conv(
        self, compute_unit, backend, mode, cluster_dim, op_type, caplog
    ):
        """Test grouped conv/conv_transpose where effective dim size is not divisible by cluster_dim."""
        inputs = [ct.TensorType(name="data", shape=(1, 32, 10, 10))]
        torch_input_values = [torch.rand(*i.shape.to_list()) for i in inputs]
        if op_type == "conv":
            model = torch.nn.Conv2d(in_channels=32, out_channels=32, kernel_size=1, groups=32)
        else:
            model = torch.nn.ConvTranspose2d(
                in_channels=32, out_channels=32, kernel_size=1, groups=32
            )
        model.eval()

        torchmodel = torch.jit.trace(model, torch_input_values)
        mlmodel = ct.convert(
            torchmodel,
            inputs=inputs,
            convert_to="mlprogram",
            minimum_deployment_target=backend.opset_version,
            compute_precision=ct.precision.FLOAT16
            if backend.precision == "fp16"
            else ct.precision.FLOAT32,
            compute_units=compute_unit,
        )

        vector_lut_config = cto.coreml.OptimizationConfig(
            global_config=cto.coreml.OpPalettizerConfig(
                mode=mode,
                nbits=4 if mode == "kmeans" else None,
                granularity="per_tensor",
                cluster_dim=cluster_dim,
                weight_threshold=30,  # The weight shape is [32, 1, 1, 1].
            )
        )

        if backend.opset_version < ct.target.iOS18:
            with pytest.raises(ValueError, match=self._ERR_MSG.format("vector")):
                cto.coreml.palettize_weights(mlmodel, vector_lut_config)
            return

        with caplog.at_level(logging.WARNING):
            mlmodel_palettized = cto.coreml.palettize_weights(mlmodel, vector_lut_config)

        # As the effective dim size (1) is not divisible by cluster_dim, the op won't be palettized.
        warning_msg = "The `cluster_dim` is invalid for .* Skipped this op."
        assert any(re.match(warning_msg, rec.message) for rec in caplog.records)
        assert get_op_types_in_program(mlmodel._mil_program) == get_op_types_in_program(
            mlmodel_palettized._mil_program
        )
Test grouped conv/conv_transpose where effective dim size is not divisible by cluster_dim.
coremltools/test/optimize/coreml/test_post_training_quantization.py