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 2022/11/15 18:33:19 UTC

[GitHub] [tvm] junrushao commented on a diff in pull request #13384: [MetaSchedule] Support schedules with cache read in RewriteLayout

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


##########
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:
   Continuing the discussion from [this thread](https://github.com/apache/tvm/pull/13195#discussion_r1022226540).
   
   I am convinced that we need to store buffers in block attributes for hexagon-specific usecases, and the only thing that I feel less natural is generally storing IR nodes in attributes. As an example, in `layout_free_placeholders`, we didn't store any IR nodes in the attribute, but instead use a list of integers which is simpler.
   
   In the meantime, I completely understand that we need to get around this quickly, so in this particular case, how about adding or reusing a pass config flag, e.g. the one we are using "link-params", and only add enable `topi_attr` to be set when the flag is on?
   
   ```c++
   else if (link_param is on) {
     n->annotations.Set(topi_attr, new_buffers);
   }
   ```
   
   



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org