You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/03/22 05:14:25 UTC

[GitHub] [tvm] Hzfengsy opened a new pull request #7716: [TensorIR] add TIRTextPrinter support for Block and BlockRealize

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:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on pull request #7716: [TensorIR] add TIRTextPrinter support for Block and BlockRealize

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on pull request #7716:
URL: https://github.com/apache/tvm/pull/7716#issuecomment-803768274


   Would you like to add some unittests for the printer? Currently we only check if some words exists, then could we assert on the string printed?


-- 
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:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on a change in pull request #7716: [TensorIR] add TIRTextPrinter support for Block and BlockRealize

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on a change in pull request #7716:
URL: https://github.com/apache/tvm/pull/7716#discussion_r598432573



##########
File path: src/printer/tir_text_printer.cc
##########
@@ -217,6 +219,22 @@ Doc TIRTextPrinter::BufferNode2Doc(const BufferNode* buf, Doc doc) {
   return doc << ")";
 }
 
+Doc TIRTextPrinter::PrintBufferRegion(const BufferRegionNode* op) {
+  Doc doc;
+  doc << Print(op->buffer) << "[";
+  for (size_t i = 0; i < op->region.size(); ++i) {
+    if (i != 0) doc << ", ";

Review comment:
       just a nitpick
   
   ```suggestion
       if (i != 0) {
         doc << ", ";
       }
   ```




-- 
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:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 removed a comment on pull request #7716: [TensorIR] add TIRTextPrinter support for Block and BlockRealize

Posted by GitBox <gi...@apache.org>.
junrushao1994 removed a comment on pull request #7716:
URL: https://github.com/apache/tvm/pull/7716#issuecomment-803768274


   Would you like to add some unittests for the printer? Currently we only check if some words exists, then could we assert on the string printed?


-- 
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:
users@infra.apache.org



[GitHub] [tvm] tqchen merged pull request #7716: [TensorIR] add TIRTextPrinter support for Block and BlockRealize

Posted by GitBox <gi...@apache.org>.
tqchen merged pull request #7716:
URL: https://github.com/apache/tvm/pull/7716


   


-- 
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:
users@infra.apache.org