shingjan commented on a change in pull request #9680:
URL: https://github.com/apache/tvm/pull/9680#discussion_r765503503



##########
File path: src/printer/tvmscript_printer.cc
##########
@@ -471,6 +479,47 @@ Doc TVMScriptPrinter::PrintMatchBufferRegion(const 
MatchBufferRegionNode* op) {
   return doc;
 }
 
+// check if all arguments, except the first two, are specified for 
T.match_buffer
+// if not, then this match buffer is printed out as syntax sugar
+bool TVMScriptPrinter::IsMatchBufferSugarred(const Buffer& buf) {
+  if (memo_var_.find(buf->data) != memo_var_.end()) {
+    return false;
+  }
+  if (!buf->strides.empty()) {
+    return false;
+  }
+  if (buf->elem_offset->IsInstance<VarNode>()) {
+    Var elem_offset = Downcast<Var>(buf->elem_offset);
+    if (memo_var_.find(elem_offset) != memo_var_.end()) {
+      return false;
+    }
+  } else if (buf->elem_offset->IsInstance<IntImmNode>()) {
+    IntImm elem_offset = Downcast<IntImm>(buf->elem_offset);
+    if (elem_offset->value != 0) {
+      return false;
+    }
+  }
+  if (buf.scope() != "global") {
+    return false;
+  }
+  if (buf->data_alignment != runtime::kAllocAlignment) {
+    return false;
+  }
+  if (buf->offset_factor != 1) {
+    return false;
+  }
+  if (buf->buffer_type != 1) {

Review comment:
       Yes. `BufferType` is an enum in which 1 is for `kDefault` and 2 is for 
`kAutoBroadcast`. Details 
[here](https://github.com/apache/tvm/blob/0e0adf514c41dcab27ef60df60e84ce28a6effaf/include/tvm/tir/buffer.h#L42)




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