masahi commented on code in PR #13384:
URL: https://github.com/apache/tvm/pull/13384#discussion_r1023180356


##########
src/te/operation/create_primfunc.cc:
##########
@@ -110,13 +110,20 @@ class LayoutFreePlaceholdersNormalizer : public 
StmtMutator {
     Block block = Downcast<Block>(StmtMutator::VisitStmt_(_block));
     BlockNode* n = block.CopyOnWrite();
     if (Optional<ObjectRef> ann = n->annotations.Get(topi_attr)) {
+      Array<Buffer> new_buffers;
       for (Buffer buffer : Downcast<Array<Buffer>>(ann)) {
         auto it = buffer2index_.find(buffer);
         if (it != buffer2index_.end()) {
           layout_free_buffer_indices_.insert(it->second);
+        } else {
+          new_buffers.push_back(buffer);
         }
       }
-      n->annotations.erase(topi_attr);
+      if (new_buffers.empty()) {
+        n->annotations.erase(topi_attr);
+      } else {
+        n->annotations.Set(topi_attr, new_buffers);
+      }

Review Comment:
   This `else` branch is only hit when there is a layout-free buffer that's not 
passed as a parameter to the prim func. Currently that can only happen when 
`link-params = True`. So isn't having another flag redundant? 



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