Hello,
This question is regarding the pattern matching in Relay.
Information from the following page was used as a reference: https://tvm.apache.org/docs/langref/relay_pattern.html
For a pattern like this:
self.x = wildcard()
mean_op = is_op('mean')(self.x)
self.pattern = \
mean_op.has_attr({"axis": 3 }) | \
mean_op.has_attr({"axis": (1, 3)}) | \
mean_op.has_attr({"axis": (2, 3)}) | \
mean_op.has_attr({"axis": (1, 2, 3)})
self.pattern = self.pattern(self.x)
I was trying to match the following operator
relay.mean(data, axis=axis, keepdims=keepdims, exclude=exclude)
for the axis values outlined in the pattern above.
This didn’t work at first since the ‘axis’ attribute needed to be registered apparently.
The mean operator with the axis set to 3 could be matched by the pattern above after using
tvm.ir.register_op_attr("mean", "axis", value=axis)
but could not be matched for other values in the pattern, i.e. the tuple values for the axis.
The question would be: is the pattern written correctly and if it is, how can values that are tuples (in this case) be matched as the values for the axis attribute?
I noticed that the value type that register_op_attr
returns is tvm.ir.container.Array after
registering the axis attribute with a value that is a tuple, ex. (1, 2, 3); could that be a problem, since the
value that will be matched in the operator is a python tuple?
Thanks in advance.