def test_default_prune_pipeline_ios18(self, compute_unit, backend):
        """Make sure the new iOS18 op is used for DEFAULT_PRUNING pass pipeline."""
        # Make the weight size not divisible by 8, to make sure the internal conversion to ios18
        # sparse_to_dense op handles sub-byte masks correctly.
        model = torch.nn.Linear(21, 121)
        model.eval()
        weight_sparse = create_sparse_weight(model.weight, 0.7)
        with torch.no_grad():
            model.weight = torch.nn.Parameter(torch.Tensor(weight_sparse))

        inputs = [ct.TensorType(name="data", shape=(4, 21))]
        torch_input_values = [torch.rand(*i.shape.to_list()) for i in inputs]
        coreml_input_values = {
            i.name: val.detach().numpy() for i, val in zip(inputs, torch_input_values)
        }
        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,
        )
        mlmodel_pruned = 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,
            pass_pipeline=ct.PassPipeline.DEFAULT_PRUNING,
        )
        sparse_ops = mlmodel_pruned._mil_program.find_ops(op_type="constexpr_sparse_to_dense")
        assert len(sparse_ops) > 0
        for sparse_op in sparse_ops:
            assert types.builtin_to_string(sparse_op.nonzero_data.dtype) == backend.precision
            if backend.opset_version >= ct.target.iOS18:
                assert types.builtin_to_string(sparse_op.mask.dtype) == "uint1"
            else:
                assert types.builtin_to_string(sparse_op.mask.dtype) == "uint8"
                assert types.builtin_to_string(sparse_op.shape.dtype) == "uint32"

        if _macos_version() >= (15, 0):
            verify_model_outputs(mlmodel, mlmodel_pruned, coreml_input_values, rtol=3e-3, atol=2e-3)
Make sure the new iOS18 op is used for DEFAULT_PRUNING pass pipeline.
coremltools/test/optimize/coreml/test_post_training_quantization.py