[Unity][Relax] Pattern matching a bunch of call_tir functions with similar names

Hello,

I am trying to import a quantized TFLite function (a single dense layer) in Relax via the relay_translator. This is the resulting Relax module I get:

@R.function
def main(serving_default_input_1_0: R.Tensor((1, 64), dtype="int8"), _param_1: R.Tensor((64, 64), dtype="int8"), _param_2: R.Tensor((64,), dtype="int32")) -> R.Tensor((1, 64), dtype="int8"):
    cls = Module
    with R.dataflow():
        lv = R.call_tir(cls.reshape, (serving_default_input_1_0,), out_sinfo=R.Tensor((1, 64), dtype="int8"))
        lv1 = R.call_tir(cls.cast, (lv,), out_sinfo=R.Tensor((1, 64), dtype="int16"))
        lv2 = R.call_tir(cls.subtract, (lv1, R.const(-1, "int16")), out_sinfo=R.Tensor((1, 64), dtype="int16"))
        lv3 = R.call_tir(cls.cast1, (_param_1,), out_sinfo=R.Tensor((64, 64), dtype="int16"))
        lv4 = R.call_tir(cls.dense, (lv2, lv3), out_sinfo=R.Tensor((1, 64), dtype="int32"))
        lv5 = R.call_tir(cls.expand_dims, (_param_2,), out_sinfo=R.Tensor((1, 64), dtype="int32"))
        lv6 = R.call_tir(cls.add, (lv4, lv5), out_sinfo=R.Tensor((1, 64), dtype="int32"))
        lv7 = R.call_tir(cls.fixed_point_multiply, (lv6,), out_sinfo=R.Tensor((1, 64), dtype="int32"))
        lv8 = R.call_tir(cls.add1, (R.const(2, "int32"), lv7), out_sinfo=R.Tensor((1, 64), dtype="int32"))
        lv9 = R.call_tir(cls.clip, (lv8,), out_sinfo=R.Tensor((1, 64), dtype="int32"))
        lv10 = R.call_tir(cls.cast2, (lv9,), out_sinfo=R.Tensor((1, 64), dtype="int8"))
        gv: R.Tensor((1, 64), dtype="int8") = lv10
        R.output(gv)
    return gv

The reshape, add etc. functions are omitted. How can I apply pattern matching for operator offloading here? If I use the provided is_call_tir I have to enter the exact string for every operation, so I need to write more pattern if I have a “cls.add2” function in the future because it would not be captures with is_call_tir(“add1”) as the names don’t match. Is there a way around this?

As a follow-up question: Is there a way to use something similar to register_pattern_table that was used on Relay?