def test_builder_to_backend_stress(
        self, compute_unit, backend, nbits, block_sizes, vector_size, vector_axis, lut_dtype
    ):
        """Use constexpr_lut_to_dense op's value inference to check backends outputs."""
        indices_shape = (4, 8, 16, 8)
        builtin_dtype = types.string_to_builtin(f"uint{nbits}")
        np_dtype = types.nptype_from_builtin(builtin_dtype)
        indices = np.random.randint(low=0, high=2**nbits, size=indices_shape).astype(np_dtype)

        lut_np_dtype = types.nptype_from_builtin(types.string_to_builtin(lut_dtype))
        lut_shape = _infer_lut_shape(indices_shape, block_sizes, nbits, vector_size)
        lut = np.random.rand(*lut_shape).astype(lut_np_dtype)

        def build(x):
            return mb.constexpr_lut_to_dense(
                indices=indices,
                lut=lut,
                vector_axis=vector_axis,
            )

        output_shape = list(indices.shape)
        if vector_size > 1:
            output_shape[vector_axis] *= vector_size
        x_val = np.ones(output_shape).astype(np.float32)
        input_placeholders = {"x": mb.placeholder(shape=x_val.shape)}
        expected_output = constexpr_lut_to_dense.decompress(indices, lut, vector_axis=vector_axis)

        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_lut_to_dense op's value inference to check backends outputs.
coremltools/converters/mil/mil/ops/tests/iOS18/test_compression.py