Hzfengsy opened a new pull request #7716:
URL: https://github.com/apache/tvm/pull/7716


   Currently, there are three printers for TIR: 
   1. ReprPrinter: Text printer for stmt node. (e.g. `print(for_loop)`)
   2. TIRTextPrinter: Text printer for function or module. (e.g. 
`print(prim_func)`)
   3. TVMScriptPrinter: Python syntax printer for function or module.
   
   Note that TIRTextPrinter and TVMScriptPrinter are designed for round-trip 
printing and parsing, which may contain necessary info for reconstructing the 
AST (TIRTextPrinter is designed for it but has not supported now). In this PR, 
I add TIRTextPrinter support for Block and BlockRealize. Then all three 
printers and one parser (TVMScriptParser) support TensorIR.
   
   Example
   ```
   #[version = "0.0.5"]
   primfn() -> () {
     block([16, tir.reduce_axis(0, 16)], "block") as [vx, vy] {
       bind(vx, x)
       bind(vy, y)
       tir.reads([buffer[vx, vy]])
       tir.writes([buffer_2[vx]])
       tir.attrs({"attr_key": "attr_value"})
       buffer_4 = alloc_buffer(float32[16, 16])
       buffer_5 = match_buffer_region(buffer[0:16, 0:16])
       with init() {
         buffer_2[vx] = 0f32
       }
       buffer_2[vx] = (buffer_2[vx] + buffer[vx, vy])
   }
   ```
   
   cc @tqchen @junrushao1994 


-- 
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.

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


Reply via email to