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


##########
src/te/operation/create_primfunc.cc:
##########
@@ -107,24 +108,30 @@ class LayoutFreePlaceholdersNormalizer : public 
StmtMutator {
 
   Stmt VisitStmt_(const BlockNode* _block) final {
     Block block = Downcast<Block>(StmtMutator::VisitStmt_(_block));
-    if (Optional<ObjectRef> ann = block->annotations.Get(topi_attr)) {
-      Array<Buffer> new_buffers;
+    BlockNode* n = block.CopyOnWrite();
+    if (Optional<ObjectRef> ann = n->annotations.Get(topi_attr)) {
       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);
         }
       }
-      block.CopyOnWrite()->annotations.Set(topi_attr, new_buffers);

Review Comment:
   I see, for now I reverted this change in 
https://github.com/apache/tvm/pull/13384 to unblock tuning with `link params`. 
I don't have a good solution for now, other than enforcing transformation 
passes to take buffers in `layout_free_placeholders` into account.
   
   I'd say the same problem applies to the current approach which specifies the 
layout free buffers by their indices in the parameter list, since it is also 
technically possible (although unlikely) that some transformation may change 
the signature of the prim func, which invalidates the parameter indices.  



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