tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] junrushao1994 commented on a change in pull request #5585: [Runtime] Introduce runtime::Array
Date Fri, 15 May 2020 18:25:01 GMT

junrushao1994 commented on a change in pull request #5585:
URL: https://github.com/apache/incubator-tvm/pull/5585#discussion_r425974393



##########
File path: src/node/serialization.cc
##########
@@ -414,29 +415,39 @@ std::string SaveJSON(const ObjectRef& n) {
 }
 
 ObjectRef LoadJSON(std::string json_str) {
-  std::istringstream is(json_str);
-  dmlc::JSONReader reader(&is);
   JSONGraph jgraph;
-  // load in json graph.
-  jgraph.Load(&reader);
-  std::vector<ObjectPtr<Object> > nodes;
+  std::vector<ObjectPtr<Object>> nodes;
   std::vector<runtime::NDArray> tensors;
-  // load in tensors
-  for (const std::string& blob : jgraph.b64ndarrays) {
-    dmlc::MemoryStringStream mstrm(const_cast<std::string*>(&blob));
-    support::Base64InStream b64strm(&mstrm);
-    b64strm.InitPosition();
-    runtime::NDArray temp;
-    CHECK(temp.Load(&b64strm));
-    tensors.emplace_back(temp);
+  {
+    // load in json graph.
+    std::istringstream is(json_str);
+    dmlc::JSONReader reader(&is);
+    jgraph.Load(&reader);
+    // load in tensors
+    for (const std::string& blob : jgraph.b64ndarrays) {
+      dmlc::MemoryStringStream mstrm(const_cast<std::string*>(&blob));
+      support::Base64InStream b64strm(&mstrm);
+      b64strm.InitPosition();
+      runtime::NDArray temp;
+      CHECK(temp.Load(&b64strm));
+      tensors.emplace_back(temp);
+    }
   }
   ReflectionVTable* reflection = ReflectionVTable::Global();
 
   // node 0 is always null
   nodes.reserve(jgraph.nodes.size());
 
   for (const JSONNode& jnode : jgraph.nodes) {
-    if (jnode.type_key.length() != 0) {
+    if (jnode.type_key == ArrayNode::_type_key) {
+      CHECK(jnode.repr_bytes.empty());
+      int64_t size = jnode.data.size();
+      ObjectPtr<ArrayNode> node = ArrayNode::make(size);
+      for (int64_t& i = node->size_ = 0; i < size; ++i) {
+        node->EmplaceInit(i, nullptr);

Review comment:
       Makes sense. Will do!




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



Mime
View raw message