def test_fused_elementwise_find_fusable_graph(self, dtype):
        r"""
                     X0
                     |
                    Abs
                   /   \
            X1   Tanh  |
             \    /    |
              Gemm   Relu
                \      |
                 Exp   |
                   \  /
                   Sub

        Tanh, Abs, Relu should be fused together;  Sub, Exp should be fused together.
        """
        target = detect_target()
        if dtype == "float" and (int(target._arch) < 80 or target.name == "rocm"):
            self.skipTest("gemm with float tensors requires CUDA sm >= 80")

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

        R0 = ops.elementwise(FuncEnum.ABS)(X0)
        R1 = ops.elementwise(FuncEnum.TANH)(R0)
        R2 = ops.gemm_rcr()(R1, X1)
        R3 = ops.elementwise(FuncEnum.EXP)(R2)
        R4 = ops.elementwise(FuncEnum.RELU)(R0)
        R5 = ops.elementwise(FuncEnum.SUB)(R4, R3)
        R5._attrs["name"] = "R5"
        R5._attrs["is_output"] = True

        target = detect_target()
        module = compile_model(
            R5,
            target,
            "./tmp",
            "fused_elementwise_find_fusable_graph",
        )
        debug_sorted_graph = module.debug_sorted_graph
        sorted_ops = graph_utils.get_sorted_ops(debug_sorted_graph)
        self.assertEqual(len(sorted_ops), 3)

        x0_pt = get_random_torch_tensor([M, K], dtype)
        x1_pt = get_random_torch_tensor([K, N], dtype)
        relu = torch.nn.ReLU()
        r0_pt = torch.abs(x0_pt)
        r1_pt = torch.tanh(r0_pt)
        r2_pt = nn.functional.linear(r1_pt, x1_pt)
        r3_pt = torch.exp(r2_pt)
        r4_pt = relu(r0_pt)
        r5_pt = r4_pt - r3_pt

        r5 = get_torch_empty_tensor([M, N], dtype)

        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,
            "X1": x1_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, [r5])
        self.assertTrue(torch.allclose(r5, r5_pt, atol=1e-2, rtol=1e-2))

                     X0
                     |
                    Abs
                   /   \
            X1   Tanh  |
             \    /    |
              Gemm   Relu
                \      |
                 Exp   |
                   \  /
                   Sub

        Tanh, Abs, Relu should be fused together;  Sub, Exp should be fused together.
        
tests/unittest/compiler/test_fused_elementwise_complex_dependency.py