patschmidt2 commented on issue #16889:
URL: https://github.com/apache/tvm/issues/16889#issuecomment-2074426456

   I think you are supposed to call `decompose_reduction `before `blockize`:
   
   ```
   import tvm
   
   from tvm.script import ir as I
   from tvm.script import tir as T
   
   @I.ir_module
   class Module:
       @T.prim_func
       def main():
           # with T.block("root"):
           A_sum = T.alloc_buffer((1,), "float32")
           A = T.alloc_buffer((1, 16), "float32")
           for nn, ff in T.grid(1, 16):
               with T.block("A"):
                   v_nn, v_ff = T.axis.remap("SR", [nn, ff])
                   T.reads(A[v_nn, v_ff])
                   T.writes(A_sum[v_nn])
                   with T.init():
                       A_sum[v_nn] = T.float32(0)
                   A_sum[v_nn] = A_sum[v_nn] + A[v_nn, v_ff]
   
   sch = tvm.tir.Schedule(Module)
   
   a = sch.get_block("A")
   
   loop_n, loop_f = sch.get_loops(a)
   
   sch.decompose_reduction("A", loop_n)
   sch.blockize(loop_f)
   
   init_block = sch.get_block("A_init")
   
   print(sch.mod) # <-- A_init exists
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to