A failed example of using compute_at based on TVMScript

I see. I feel like your intention is to move block “C” under certain loops above block “B”. Is that correct. If so, you may use reverse_compute_at in your particular case.

try this:

def test_compute_at2():
    sch = tir.Schedule(compute_at_call_extern, debug_mask="all")
    print(sch.mod.script())
    block_b = sch.get_block("B")
    block_c = sch.get_block("C")
    loop_i, = sch.get_loops(block_b)
    sch.reverse_compute_at(block_c, loop_i, preserve_unit_loops=True)  # failed here
    print(sch.mod.script())