def test_invalid_if_not_canonical():
        """
        Since the inplace op is not in canonical pattern, there is nothing this graph pass can do
        """
        SHAPE = (2, 3, 5, 7)

        @mb.program(
            input_specs=[
                mb.TensorSpec(shape=SHAPE, dtype=types.fp16),
                mb.StateTensorSpec(shape=SHAPE, dtype=types.fp16),
            ],
            opset_version=AvailableTarget.iOS18,
        )
        def prog(x, state):
            read = mb.read_state(input=state)
            mul = mb.mul(x=x, y=read)
            add = mb.add(x=x, y=mul)
            update = mb.coreml_update_state(state=state, value=mul)
            return add

        mul_op = prog.find_ops(op_type="mul")[0]
        add_op = prog.find_ops(op_type="add")[0]
        assert add_op.y is mul_op.outputs[0]

        apply_pass_and_basic_check(prog, "common::prefer_state_in_downstream")
        mul_op = prog.find_ops(op_type="mul")[0]
        coreml_update_state_op = prog.find_ops(op_type="coreml_update_state")[0]
        add_op = prog.find_ops(op_type="add")[0]
        assert add_op.y is mul_op.outputs[0]
        assert add_op.y is not coreml_update_state_op.outputs[0]

        Since the inplace op is not in canonical pattern, there is nothing this graph pass can do
        
coremltools/converters/mil/mil/passes/tests/test_state_passes.py