def test_ios17_invalid_mixed_precision(self, compute_unit, backend):
        """When x and y are both const or both non-const, mixed precision is not allowed."""
        x_val = np.random.rand(2, 5).astype(np.float32)
        y_val = np.random.randint(low=0, high=10, size=(5, 10)).astype(np.int32)

        def build_both_const():
            return mb.matmul(x=x_val, y=y_val, transpose_x=False, transpose_y=False)

        def build_both_not_const(x, y):
            return mb.matmul(x=x, y=y, transpose_x=False, transpose_y=False)

        with pytest.raises(
            ValueError, match="when x and y are both const, their dtype need to match"
        ):
            run_compare_builder(
                build_both_const,
                input_placeholders={},
                input_values={},
                compute_unit=compute_unit,
                backend=backend,
            )

        with pytest.raises(
            ValueError, match="when x and y are both non-const, their dtype need to match"
        ):
            run_compare_builder(
                build_both_not_const,
                input_placeholders={
                    "x": mb.placeholder(shape=x_val.shape, dtype=types.fp32),
                    "y": mb.placeholder(shape=y_val.shape, dtype=types.int32),
                },
                input_values={"x": x_val, "y": y_val},
                compute_unit=compute_unit,
                backend=backend,
            )
When x and y are both const or both non-const, mixed precision is not allowed.
coremltools/converters/mil/mil/ops/tests/iOS17/test_linear.py