    def test_dont_fuse_non_duplicates(self):
        """Fused-elementwise ops that have different inputs or different
        elementwise-ops aren't fused together.
        """
        x = gen_input_tensor(shape=self.SHAPE, name="input_x")
        z = gen_input_tensor(shape=self.SHAPE, name="input_z")
        relu_x = ops.elementwise(FuncEnum.RELU)(x)
        gelu_x = ops.elementwise(FuncEnum.GELU)(x)
        gelu_z = ops.elementwise(FuncEnum.GELU)(z)
        softmax1 = ops.softmax()(relu_x, dim=0)
        softmax2 = ops.softmax()(gelu_x, dim=0)
        softmax3 = ops.softmax()(gelu_z, dim=0)
        model_output = softmax1 + softmax2 + softmax3
        model_output._attrs["is_output"] = True
        model_output._attrs["name"] = "output"

        x_pt = get_random_torch_tensor(self.SHAPE)
        z_pt = get_random_torch_tensor(self.SHAPE)
        relu_x_pt = torch.nn.functional.relu(x_pt)
        gelu_x_pt = torch.nn.functional.gelu(x_pt)
        gelu_z_pt = torch.nn.functional.gelu(z_pt)
        softmax1_pt = torch.nn.functional.softmax(relu_x_pt, dim=0)
        softmax2_pt = torch.nn.functional.softmax(gelu_x_pt, dim=0)
        softmax3_pt = torch.nn.functional.softmax(gelu_z_pt, dim=0)

        y_pt = softmax1_pt + softmax2_pt + softmax3_pt
        y_ait = torch.empty_like(y_pt)

        with compile_model(
            model_output,
            detect_target(),
            "/tmp",
            "fuse_duplicate_fused_elementwise_non_dups",
        ) as module:
            module.run_with_tensors(
                {"input_x": x_pt, "input_z": z_pt}, {"output": y_ait}
            )
            graph = module.debug_sorted_graph
            nrelu = self._count_fused_elementwise_ops(graph, [FuncEnum.RELU])
            ngelu = self._count_fused_elementwise_ops(graph, [FuncEnum.GELU])
            self.assertEqual(nrelu, 1)
            self.assertEqual(ngelu, 2)
            self.assertTrue(torch.allclose(y_pt, y_ait, atol=1e-2, rtol=1e-2))
Fused-elementwise ops that have different inputs or different
elementwise-ops aren't fused together.
tests/unittest/compiler/test_fuse_duplicate_fused_elementwise.py