def test_const_only_used_as_output_skip_compress():
        """
        If the const is only fed to the block output, we skip the compression,
        due to the bug rdar://108274019 ([Bug] constexpr ops cannot be directly fed to block output)
        """

        @mb.program(input_specs=[mb.TensorSpec(shape=(10, 20, 30))], opset_version=ct.target.iOS16)
        def prog(x):
            val = np.random.rand(10, 20, 30).astype(np.float32)
            const = mb.const(val=val)
            output = mb.add(x=x, y=1.0)
            return output, const

        op_config = cto.coreml.OpPalettizerConfig(
            nbits=2,
            mode="kmeans",
            weight_threshold=0,
        )
        config = cto.coreml.OptimizationConfig(global_config=op_config)
        compressor = quantization.palettize_weights(config=config)
        compressor.apply(prog)
        assert get_op_types_in_program(prog) == ["add"]

        If the const is only fed to the block output, we skip the compression,
        due to the bug rdar://108274019 ([Bug] constexpr ops cannot be directly fed to block output)
        
coremltools/test/optimize/coreml/test_passes.py