µTVM CRT modifications for on-device RPC server (#5921)
authorAndrew Reusch <areusch@octoml.ai>
Sun, 12 Jul 2020 09:28:31 +0000 (02:28 -0700)
committerGitHub <noreply@github.com>
Sun, 12 Jul 2020 09:28:31 +0000 (17:28 +0800)
commitd6ceba044b2427d493575c26749164aef2efaf30
tree99a2a8000cf01e3d01bf214f5a35eace4366dba6
parentc9c77c6b76f7cff3bc6afbf9d3ef2200e3fdbb91
µTVM CRT modifications for on-device RPC server (#5921)

* Reorganize CRT into parts, public API, and add standalone build.

 * Create a make-based build in src/runtime/crt. This is intended to
   be built in build/standalone_crt (generated by running ninja
   standalone_crt in build/). Its job is to build CRT without
   depending on headers not explicitly allowed in CRT.
 * Create a "public-facing" CRT API targeted to firmware running
   alongside CRT in include/tvm/runtime/crt. Developers who are
   integrating the CRT are the target of this API.
 * Reorganize CRT internally into common/ and graph_runtime/
   pieces. Build each pieces as a separate statically-linked library.
 * Slim down TVMGraphRuntime public-facing API to just the functions
   that are used externally.
 * Updates to apps/bundle_deploy to make this work.

* Add TVMFuncRegistry, CRT test infrastructure, and tests.

 * Also add error_codes.h, a file containing error codes returned by CRT.

* Add TVMErrorf()

* [API_CHANGE] Integrate func registry into CRT.

 * NOTE: This changes the default API for functions exposed under the
   CRT by the TVMFuncCall API. `resource_handle` is now always given
   as a new 6th parameter.
 * `resource_handle` is NULL when invoked on a global function and a
   pointer to the module owning the function otherwise.

* Generalize arena-based memory manager.

* lint

* Fix git-clang-format arg parsing

* add apache header

* add mutable func registry tests

* git-clang-format

* fix more lint

* Move memory_test to crttests.

* fix tests

* checkpoint

* checkpoint

* bundle_deploy demo_static works

* rm debug printf

* git-clang-format

* fix lint

* add asf header

* pylint

* update build configs for jenkins

* make regression compiler happy

* fix build errors in regression GCC

* address comments

* git-clang-format

* fix for 32-bit cpp regression

* fix incorrect use of memcpy and tests for 32-bit

* clang-format
50 files changed:
CMakeLists.txt
Makefile
apps/bundle_deploy/Makefile
apps/bundle_deploy/build_model.py
apps/bundle_deploy/bundle.c
apps/bundle_deploy/bundle_static.c
apps/bundle_deploy/crt_config/crt_config.h [moved from apps/bundle_deploy/runtime.c with 80% similarity]
cmake/config.cmake
cmake/modules/StandaloneCrt.cmake [new file with mode: 0644]
include/tvm/runtime/c_backend_api.h
include/tvm/runtime/crt/crt.h [moved from apps/bundle_deploy/runtime.cc with 53% similarity]
include/tvm/runtime/crt/error_codes.h [new file with mode: 0644]
include/tvm/runtime/crt/func_registry.h [new file with mode: 0644]
include/tvm/runtime/crt/graph_runtime.h [new file with mode: 0644]
include/tvm/runtime/crt/memory.h
include/tvm/runtime/crt/module.h [moved from src/runtime/crt/module.h with 70% similarity]
include/tvm/runtime/crt/packed_func.h [new file with mode: 0644]
include/tvm/runtime/crt/platform.h [moved from tests/cpp/crt_memory_test.cc with 51% similarity]
python/tvm/micro/func_registry.py [new file with mode: 0644]
src/runtime/crt/.gitignore [new file with mode: 0644]
src/runtime/crt/Makefile [new file with mode: 0644]
src/runtime/crt/common/crt_backend_api.c [moved from src/runtime/crt/crt_backend_api.c with 85% similarity]
src/runtime/crt/common/crt_runtime_api.c [new file with mode: 0644]
src/runtime/crt/common/func_registry.c [new file with mode: 0644]
src/runtime/crt/common/memory.c [moved from src/runtime/crt/memory.c with 52% similarity]
src/runtime/crt/common/ndarray.c [moved from src/runtime/crt/ndarray.c with 97% similarity]
src/runtime/crt/common/packed_func.c [moved from src/runtime/crt/packed_func.h with 52% similarity]
src/runtime/crt/crt_runtime_api.c [deleted file]
src/runtime/crt/graph_runtime.h [deleted file]
src/runtime/crt/graph_runtime/graph_runtime.c [moved from src/runtime/crt/graph_runtime.c with 93% similarity]
src/runtime/crt/graph_runtime/load_json.c [moved from src/runtime/crt/load_json.c with 98% similarity]
src/runtime/crt/host/crt_config.h [new file with mode: 0644]
src/runtime/crt/include/tvm/runtime/crt/internal/common/func_registry.h [new file with mode: 0644]
src/runtime/crt/include/tvm/runtime/crt/internal/common/logging.h [moved from src/runtime/crt/logging.h with 89% similarity]
src/runtime/crt/include/tvm/runtime/crt/internal/common/memory.h [new file with mode: 0644]
src/runtime/crt/include/tvm/runtime/crt/internal/common/ndarray.h [moved from src/runtime/crt/ndarray.h with 85% similarity]
src/runtime/crt/include/tvm/runtime/crt/internal/graph_runtime/graph_runtime.h [new file with mode: 0644]
src/runtime/crt/include/tvm/runtime/crt/internal/graph_runtime/load_json.h [moved from src/runtime/crt/load_json.h with 88% similarity]
src/runtime/library_module.cc
src/tir/transforms/make_packed_api.cc
tests/crt/func_registry_test.cc [new file with mode: 0644]
tests/crt/memory_test.cc [new file with mode: 0644]
tests/lint/git-clang-format.sh
tests/python/unittest/test_tir_transform_make_packed_api.py
tests/scripts/task_config_build_cpu.sh
tests/scripts/task_config_build_gpu.sh
tests/scripts/task_config_build_gpu_vulkan.sh
tests/scripts/task_config_build_i386.sh
tests/scripts/task_config_build_wasm.sh
tests/scripts/task_cpp_unittest.sh