Hi I am beginner to TVM pattern matching. I want to do pattern matching based on some fixed nodes , where there can be variable number of nodes with any types in between these fixed nodes. i.e CONV … op_1 … op_2 …op_n … Relu … op_1 … op_2 … op_m …Add . How should I identify these kind of pattern ?
Example:
def test1_wildcard():
x = relay.var("x")
w = relay.var("w")
n6 = relay.op.nn.conv2d(x, w) # matches P
n7 = relay.op.tanh(n6)
n7 = relay.op.nn.relu(n7)
n7 = relay.op.nn.leaky_relu(n7)
n8 = relay.op.add(n7, w)
patt = is_op("nn.conv2d")(wildcard(), wildcard())
patt = wildcard()(patt)
patt = is_op("add")(patt, wildcard())
assert patt.match(n8) # Not matched.
P = is_op("nn.conv2d")(wildcard(), wildcard())
I = wildcard()(P)
C = is_op("add")(wildcard(), wildcard())
patt = dominates(P, I, C)
return patt.match(n8) # Not matched
I am aware that i can use optional for op1 , op2 but in advance i might not know the count and types of these in between ops?