Currently, the dataflow pattern matching will fail if an inner node is used outside or is already used in a previously matched group. For example, considering we have the following graph:
a = Var()
b = Var()
c = Var()
d = Constant()
e = Var()
f = multiply(c, d)
g = add(f, nn.dense(a, b))
h = add(f, e)
If I want to match with the pattern:
pattern = is_op(“add”, is_op(“multiply”)(wildcard(), Constant()), is_op(“nn.dense”)(wildcard(), wildcard()))
This will fail as f is also used to calculate h.
I am wondering the reason behind the constraint. As I see, this match can success with the following outputs:
a = Var()
b = Var()
c = Var()
d = Constant()
e = Var()
f = multiply(c, d)
g = matched_pattern(a, b, c, d)
h = add(f, e)