[GitHub] [incubator-tvm] liangfu commented on a change in pull request #5124: [uTVM][Runtime] Introduce Virtual Memory Allocator to CRT
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_r402927166 ## File path: include/tvm/runtime/crt/logging.h ## @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * \file tvm/runtime/crt/loggin.h + * \brief A replacement of the dmlc logging system that avoids + * the usage of GLOG and C++ headers + */ + +#ifndef TVM_RUNTIME_CRT_LOGGING_H_ +#define TVM_RUNTIME_CRT_LOGGING_H_ + +#ifndef CHECK +#define CHECK(x)\ + do { \ +if (!(x)) { \ Review comment: moved to src. 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
[GitHub] [incubator-tvm] liangfu commented on a change in pull request #5124: [uTVM][Runtime] Introduce Virtual Memory Allocator to CRT
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_r398452200 ## File path: src/runtime/crt/crt_runtime_api.c ## @@ -79,7 +79,7 @@ int TVMModGetFunction(TVMModuleHandle mod, if (!strcmp(func_name, "load_params")) { *out = &TVMGraphRuntime_LoadParams; } else { -status -1; +status = -1; Review comment: I caught this with -Wall flag in gcc. 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
[GitHub] [incubator-tvm] liangfu commented on a change in pull request #5124: [uTVM][Runtime] Introduce Virtual Memory Allocator to CRT
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
[GitHub] [incubator-tvm] liangfu commented on a change in pull request #5124: [uTVM][Runtime] Introduce Virtual Memory Allocator to CRT
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_r398426202 ## File path: apps/bundle_deploy/Makefile ## @@ -37,6 +37,9 @@ demo: $(build_dir)/demo $(build_dir)/bundle.so $(build_dir)/bundle_c.so $(build_ TVM_NUM_THREADS=1 $(build_dir)/demo $(build_dir)/bundle.so $(build_dir)/cat.bin TVM_NUM_THREADS=1 $(build_dir)/demo $(build_dir)/bundle_c.so $(build_dir)/cat.bin +test_crt: $(build_dir)/test $(build_dir)/test_bundle_c.so $(build_dir)/test_data.bin $(build_dir)/test_output.bin + TVM_NUM_THREADS=1 $(build_dir)/test $(build_dir)/test_bundle_c.so $(build_dir)/test_data.bin $(build_dir)/test_output.bin $(build_dir)/test_graph.json $(build_dir)/test_params.bin Review comment: test coverage has been extended in cpptest, see tests/cpp/crt_memory_test.cc 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
[GitHub] [incubator-tvm] liangfu commented on a change in pull request #5124: [uTVM][Runtime] Introduce Virtual Memory Allocator to CRT
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_r398378354 ## File path: src/runtime/crt/crt_runtime_api.c ## @@ -79,7 +79,7 @@ int TVMModGetFunction(TVMModuleHandle mod, if (!strcmp(func_name, "load_params")) { *out = &TVMGraphRuntime_LoadParams; } else { -status -1; +status = -1; Review comment: Actually we do have the CRT sources checked by the cpplint, but it failed to catch the case. As the CRT is growing, I think we might need cppcheck to ensure the compliance to MISRA-C rules, since it contains a very nice checker [misra.py](https://github.com/danmar/cppcheck/blob/master/addons/misra.py) . 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