def test_builder_to_backend_stress(self, compute_unit, backend, sparse_ratio, data_dtype):
        """Use constexpr_sparse_to_dense op's value inference to check backends outputs."""
        dense_data_shape = (4, 8, 16, 8)
        mask = np.random.choice(
            [0, 1], size=dense_data_shape, p=[sparse_ratio, 1.0 - sparse_ratio]
        ).astype(types.np_uint1_dtype)
        non_zero_element_num = np.sum(mask)
        data_np_dtype = types.nptype_from_builtin(types.string_to_builtin(data_dtype))
        nonzero_data = np.random.rand(non_zero_element_num).astype(data_np_dtype)

        def build(x):
            output = mb.constexpr_sparse_to_dense(
                nonzero_data=nonzero_data,
                mask=mask,
            )
            x, output = promote_input_dtypes([x, output])
            return mb.add(x=x, y=output)

        x_val = np.ones_like(mask).astype(np.float32)
        input_placeholders = {"x": mb.placeholder(shape=x_val.shape)}
        expected_output = constexpr_sparse_to_dense.decompress(nonzero_data, mask) + 1

        run_compare_builder(
            build,
            input_placeholders,
            input_values={"x": x_val},
            expected_output_types=expected_output.shape + (types.fp32,),
            expected_outputs=expected_output,
            compute_unit=compute_unit,
            backend=backend,
        )
Use constexpr_sparse_to_dense op's value inference to check backends outputs.
coremltools/converters/mil/mil/ops/tests/iOS18/test_compression.py