def test_fused_elementwise_direct_input_dependency_split_subgraph(self, dtype):
        r"""
        X3[K,N]   X0[N]   X1[]
           |         \   /
           |     Add_1[N]  X2[M,N]
            \      /  |  \    /
             Add[K,N] |  Add_2[M, N]
                       \     /
                       Sub_1 [M,N]

           Add_1, Add_2, and Sub_1 should be fused together.
        """
        target = detect_target()
        if dtype == "float" and target.name == "rocm":
            self.skipTest("float tensors not supported by rocm")

        M = 10
        N = 4
        K = 15
        X0 = Tensor(
            shape=[N],
            dtype=dtype,
            name="X0",
            is_input=True,
        )
        X1 = Tensor(
            shape=[],
            dtype=dtype,
            name="X1",
            value=3.0,
        )
        X2 = Tensor(
            shape=[M, N],
            dtype=dtype,
            name="X2",
            is_input=True,
        )
        X3 = Tensor(
            shape=[K, N],
            dtype=dtype,
            name="X3",
            is_input=True,
        )

        R0 = ops.elementwise(FuncEnum.ADD)(X0, X1)
        R1 = ops.elementwise(FuncEnum.ADD)(R0, X2)
        R2 = ops.elementwise(FuncEnum.SUB)(R0, R1)
        R3 = ops.elementwise(FuncEnum.ADD)(R0, X3)
        R2._attrs["name"] = "R2"
        R2._attrs["is_output"] = True
        R3._attrs["name"] = "R3"
        R3._attrs["is_output"] = True

        module = compile_model(
            [R3, R2],
            target,
            "./tmp",
            f"fused_elementwise_direct_input_dependency_split_subgraph{dtype}",
        )
        debug_sorted_graph = module.debug_sorted_graph
        sorted_ops = graph_utils.get_sorted_ops(debug_sorted_graph)
        self.assertEqual(len(sorted_ops), 2)

        x0_pt = get_random_torch_tensor([N], dtype)  # N
        x2_pt = get_random_torch_tensor([M, N], dtype)
        x3_pt = get_random_torch_tensor([K, N], dtype)

        r0_pt = x0_pt + 3
        r3_pt = r0_pt + x3_pt
        r1_pt = r0_pt + x2_pt
        r2_pt = r0_pt - r1_pt

        r2 = get_torch_empty_tensor([M, N], dtype)
        r3 = get_torch_empty_tensor([K, N], dtype)  # N

        input_name_to_idx_mapping = module.get_input_name_to_index_map()
        inputs = [None] * len(input_name_to_idx_mapping)
        input_name_to_pt_mapping = {
            "X0": x0_pt,
            "X2": x2_pt,
            "X3": x3_pt,
        }
        for input_name, pt in input_name_to_pt_mapping.items():
            inputs[input_name_to_idx_mapping[input_name]] = pt
        module.run_with_tensors(inputs, [r3, r2])
        self.assertTrue(torch.allclose(r2, r2_pt, atol=1e-2, rtol=1e-2))
        self.assertTrue(torch.allclose(r3, r3_pt, atol=1e-2, rtol=1e-2))

        X3[K,N]   X0[N]   X1[]
           |         \   /
           |     Add_1[N]  X2[M,N]
            \      /  |  \    /
             Add[K,N] |  Add_2[M, N]
                       \     /
                       Sub_1 [M,N]

           Add_1, Add_2, and Sub_1 should be fused together.
        
tests/unittest/compiler/test_fused_elementwise_complex_dependency.py