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 2021/05/12 03:01:54 UTC

[GitHub] [tvm] Hzfengsy commented on a change in pull request #8017: [IR] Add storage scope to PointerType

Hzfengsy commented on a change in pull request #8017:
URL: https://github.com/apache/tvm/pull/8017#discussion_r630691285



##########
File path: src/ir/type.cc
##########
@@ -43,21 +43,26 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable)
       p->stream << node->dtype;
     });
 
-PointerType::PointerType(Type element_type) {
+PointerType::PointerType(Type element_type, String storage_scope) {
   ObjectPtr<PointerTypeNode> n = make_object<PointerTypeNode>();
   n->element_type = std::move(element_type);
+  n->storage_scope = std::move(storage_scope);
   data_ = std::move(n);
 }
 
 TVM_REGISTER_NODE_TYPE(PointerTypeNode);
 
-TVM_REGISTER_GLOBAL("ir.PointerType").set_body_typed([](Type element_type) {
-  return PointerType(element_type);
-});
+TVM_REGISTER_GLOBAL("ir.PointerType")
+    .set_body_typed([](Type element_type, String storage_scope = "") {
+      return PointerType(element_type, storage_scope);
+    });
 
 TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable)
     .set_dispatch<PointerTypeNode>([](const ObjectRef& ref, ReprPrinter* p) {
       auto* node = static_cast<const PointerTypeNode*>(ref.get());
+      if (node->storage_scope.size()) {

Review comment:
       ```suggestion
         if (!node->storage_scope.empty()) {
   ```

##########
File path: src/printer/tvmscript_printer.cc
##########
@@ -764,7 +764,11 @@ Doc TVMScriptPrinter::VisitType_(const PrimTypeNode* node) {
 
 Doc TVMScriptPrinter::VisitType_(const PointerTypeNode* node) {
   Doc doc;
-  doc << "ty.Ptr[" << Print(node->element_type) << "]";
+  doc << "ty.Ptr[";
+  if (node->storage_scope.size()) {

Review comment:
       ```suggestion
     if (!node->storage_scope.empty()) {
   ```

##########
File path: src/printer/tir_text_printer.cc
##########
@@ -620,7 +620,11 @@ Doc TIRTextPrinter::VisitType_(const PrimTypeNode* node) {
 
 Doc TIRTextPrinter::VisitType_(const PointerTypeNode* node) {
   Doc doc;
-  doc << "Pointer(" << Print(node->element_type) << ")";
+  doc << "Pointer(";
+  if (node->storage_scope.size()) {

Review comment:
       ```suggestion
     if (!node->storage_scope.empty()) {
   ```




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

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