liangfu commented on a change in pull request #5124: [uTVM][Runtime] Introduce 
Virtual Memory Allocator to CRT
URL: https://github.com/apache/incubator-tvm/pull/5124#discussion_r398427277
 
 

 ##########
 File path: src/runtime/crt/graph_runtime.c
 ##########
 @@ -208,20 +218,24 @@ int 
TVMGraphRuntimeGraphAttr_Load(TVMGraphRuntimeGraphAttr * attr, JSONReader *r
       if (!(reader->NextArrayItem(reader))) { fprintf(stderr, "Invalid json 
format\n"); }
       reader->BeginArray(reader);
       while (reader->NextArrayItem(reader)) {
+        attr->shape =
+          vrealloc(attr->shape, 
sizeof(attr->shape[0])*(shape_count+1)*TVM_CRT_MAX_NDIM);
+        attr->ndim = vrealloc(attr->ndim, 
sizeof(attr->ndim[0])*(shape_count+1));
         reader->BeginArray(reader);
-        reader->ReadInteger(reader, &(attr->shape[shape_count][0]));
+        int64_t * attr_shape_ptr = attr->shape + shape_count*TVM_CRT_MAX_NDIM;
+        reader->ReadInteger(reader, attr_shape_ptr + 0);
         uint32_t ndim = 1;
         if (reader->NextArrayItem(reader)) {
           if (reader->NextArrayItem(reader)) {
-            reader->ReadInteger(reader, &(attr->shape[shape_count][1])); 
ndim++;
+            reader->ReadInteger(reader, attr_shape_ptr + 1); ndim++;
             if (reader->NextArrayItem(reader)) {
-              reader->ReadInteger(reader, &(attr->shape[shape_count][2])); 
ndim++;
+              reader->ReadInteger(reader, attr_shape_ptr + 2); ndim++;
               if (reader->NextArrayItem(reader)) {
-                reader->ReadInteger(reader, &(attr->shape[shape_count][3])); 
ndim++;
+                reader->ReadInteger(reader, attr_shape_ptr + 3); ndim++;
                 if (reader->NextArrayItem(reader)) {
-                  reader->ReadInteger(reader, &(attr->shape[shape_count][4])); 
ndim++;
+                  reader->ReadInteger(reader, attr_shape_ptr + 4); ndim++;
                   if (reader->NextArrayItem(reader)) {
-                    reader->ReadInteger(reader, 
&(attr->shape[shape_count][5])); ndim++;
+                    reader->ReadInteger(reader, attr_shape_ptr + 5); ndim++;
                     reader->NextArrayItem(reader);
 
 Review comment:
   Nice catch! I successfully converted this into a for loop.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to