masahi commented on a change in pull request #8366:
URL: https://github.com/apache/tvm/pull/8366#discussion_r665188307



##########
File path: src/tir/ir/stmt.cc
##########
@@ -61,6 +61,16 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable)
 
 // AttrStmt
 AttrStmt::AttrStmt(ObjectRef node, String attr_key, PrimExpr value, Stmt body, 
Span span) {
+  if (attr_key == attr::storage_scope) {
+    const VarNode* buf = node.as<VarNode>();
+    ICHECK(buf);
+    const auto* ptr_type = buf->type_annotation.as<PointerTypeNode>();
+    ICHECK(ptr_type) << "The provided variable is not of pointer type";
+    auto attr_scope = value.as<StringImmNode>()->value;
+    ICHECK(attr_scope == ptr_type->storage_scope)
+        << "Storage scopes attached to AttrStmt and buffer var are different. 
" << attr_scope
+        << ", " << ptr_type->storage_scope;
+  }

Review comment:
       This is the invariant that enforces the same storage scope be attached 
to AttrStmt and buffer variables.
   Later I'll send a follow up PR to remove `attr::storage_scope` completely. 
   
   cc @tqchen @junrushao1994 @csullivan 




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