How can I check blocks or loops are equal in TIR schedule?

I want check whether two blocks are equal, but I can only get blockRV by using sch.get_block(), and now I check them by:

def is_equal(A, B):
  block_a  = sch.get_block(A)
  block_b  = sch.get_block(B)
  return sch.get(block_a) == sch.get(block_b)

Does TVM have a function to do this?

I want to know whether block_a is a child block of loop_a. Does TVM have a function to get it directly?

I think you are largely correct. sch.get(block_rv/loop_rv) returns a TIR node, which could be used to check equality you are asking for :slight_smile:

In terms of checking if a block is a child of loop_a, you may get loop_a’s children by loop_a.body

1 Like