def test_builder_to_backend_corner_case(self, compute_unit, backend):
        """
        This test case uses the real data from a conv model.

        It's for testing the scale/offset is correctly repeated and the joint ops
        materialized_val_inference work as expected.
        """

        def build_weight():
            data_mask = np.array(
                [
                    [[[0, 1], [1, 1]], [[1, 1], [1, 1]], [[1, 1], [1, 1]], [[1, 0], [1, 1]]],
                    [[[1, 1], [1, 1]], [[1, 1], [0, 0]], [[1, 1], [1, 1]], [[1, 0], [0, 0]]],
                ]
            ).astype(types.np_uint1_dtype)
            data_mask, nonzero_data = mb.constexpr_sparse_blockwise_shift_scale(
                data_mask=data_mask,
                nonzero_data=np.array(
                    [
                        -8,
                        -2,
                        7,
                        -4,
                        -7,
                        -6,
                        -5,
                        2,
                        -6,
                        7,
                        -5,
                        2,
                        -8,
                        -6,
                        -7,
                        -8,
                        -5,
                        -8,
                        6,
                        7,
                        6,
                        -7,
                        7,
                        2,
                        -8,
                    ]
                ).astype(np.int8),
                scale=np.array([[[[0.01955]], [[0.02809]]], [[[0.02898]], [[0.02487]]]]),
                offset=np.array([[[[3]], [[-1]]], [[[-2]], [[-3]]]]).astype(np.int8),
            )
            return mb.constexpr_sparse_to_dense(nonzero_data=nonzero_data, mask=data_mask)

        def build(x):
            return mb.add(x=x, y=build_weight())

        # Get the const expected weight by decompressing val inference from the joint constexpr ops.
        weight_prog = mb.program(input_specs=[], opset_version=_IOS18_TARGET)(build_weight)
        result_op = weight_prog.functions["main"].find_ops(op_type="constexpr_sparse_to_dense")[0]
        expected_weight = result_op.outputs[0].op.materialized_val_inference()

        x_val = np.ones(2 * 4 * 2 * 2).reshape((2, 4, 2, 2)).astype(np.float32)
        expected_output = expected_weight + 1
        input_placeholders = {"x": mb.placeholder(shape=x_val.shape)}
        # With joint quant + sparse ops, the backend prediction should match the expected_weight.
        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,
        )

        # Test conv using joint constexpr ops weight matches using the decompressed const weight.
        def build_conv_with_joint_constexpr_weight(x):
            return mb.conv(x=x, weight=build_weight())

        def build_conv_with_const_weight(x):
            return mb.conv(x=x, weight=expected_weight)

        x_val = np.random.rand(1, 4, 10, 10).astype(np.float32)
        input_placeholders = {"x": mb.placeholder(shape=x_val.shape)}
        mlmodel_conv_with_joint_constexpr_weight = run_compare_builder(
            build_conv_with_joint_constexpr_weight,
            input_placeholders,
            input_values={"x": x_val},
            expected_output_types=(1, 2, 9, 9) + (types.fp32,),
            frontend_only=True,
            compute_unit=compute_unit,
            backend=backend,
        )
        mlmodel_conv_with_const_weight = run_compare_builder(
            build_conv_with_const_weight,
            input_placeholders,
            input_values={"x": x_val},
            expected_output_types=(1, 2, 9, 9) + (types.fp32,),
            frontend_only=True,
            compute_unit=compute_unit,
            backend=backend,
        )
        result_1 = mlmodel_conv_with_joint_constexpr_weight.predict({"x": x_val})
        result_2 = mlmodel_conv_with_const_weight.predict({"x": x_val})

        np.testing.assert_allclose(result_1["conv_0"], result_2["conv_0"], rtol=3e-3, atol=3e-4)

        This test case uses the real data from a conv model.

        It's for testing the scale/offset is correctly repeated and the joint ops
        materialized_val_inference work as expected.
        
coremltools/converters/mil/mil/ops/tests/iOS18/test_compression.py