shingjan opened a new pull request #9306:
URL: https://github.com/apache/tvm/pull/9306


   This PR intends to improve the error rendering by annotating regions of 
interest in TIR like synr following PR #8121.
   Previously when there is an error:
   ```
   The IR is:
   @tvm.script.ir_module
   class Module:
       @tir.prim_func
       def main(a: tir.handle, b: tir.handle) -> None:
           A = tir.match_buffer(a, [128, 128, 128, 128], dtype="float32")
           B = tir.match_buffer(b, [128, 128, 128, 128], dtype="float32")
           # body
           # with tir.block("root")
           for i, j, k, l in tir.grid(128, 128, 128, 8):
               with tir.block([128, 128, 128, 128], "B") as [vi, vj, vk, vl]:
                   tir.bind(vi, i)
                   tir.bind(vj, j)
                   tir.bind(vk, k)
                   tir.bind(vl, l * 16)
                   tir.reads([A[vi, vj, vk, vl]])
                   tir.writes([B[vi, vj, vk, vl]])
                   B[vi, vj, vk, vl] = A[vi, vj, vk, vl] * tir.float32(2)
       
   Regions of interest:
   tir.Block#0
   block B(iter_var(vi, range(min=0, ext=128)), iter_var(vj, range(min=0, 
ext=128)), iter_var(vk, range(min=0, ext=128)), iter_var(vl, range(min=0, 
ext=128))) {
     reads([A[vi, vj, vk, vl]])
     writes([B[vi, vj, vk, vl]])
     B[vi, vj, vk, vl] = (A[vi, vj, vk, vl]*2f)
   }
   ```
   
   With this PR, the error will be rendered like below:
   
   ```
   The IR with diagnostic is:
   @tvm.script.ir_module
   class Module:
       @tir.prim_func
       def main(a: tir.handle, b: tir.handle) -> None:
           A = tir.match_buffer(a, [128, 128, 128, 128], dtype="float32")
           B = tir.match_buffer(b, [128, 128, 128, 128], dtype="float32")
           # body
           # with tir.block("root")
           for i, j, k, l in tir.grid(128, 128, 128, 8):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
               with tir.block([128, 128, 128, 128], "B") as [vi, vj, vk, vl]:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   tir.bind(vi, i)
                   tir.bind(vj, j)
                   tir.bind(vk, k)
                   tir.bind(vl, l * 16)
                   tir.reads([A[vi, vj, vk, vl]])
                   tir.writes([B[vi, vj, vk, vl]])
                   B[vi, vj, vk, vl] = A[vi, vj, vk, vl] * tir.float32(2)
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to