Skip to content

Commit

Permalink
Merge branch 'init_files' of github.com:CircleSpin/tvm into init_files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocelyn committed Mar 21, 2021
2 parents 5d8d303 + 8fb022e commit 5201391
Show file tree
Hide file tree
Showing 490 changed files with 20,950 additions and 5,221 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "3rdparty/vta-hw"]
path = 3rdparty/vta-hw
url = https://github.com/apache/incubator-tvm-vta
[submodule "3rdparty/libbacktrace"]
path = 3rdparty/libbacktrace
url = https://github.com/tlc-pack/libbacktrace.git
1 change: 1 addition & 0 deletions 3rdparty/libbacktrace
Submodule libbacktrace added at 08f7c7
2 changes: 1 addition & 1 deletion 3rdparty/vta-hw
84 changes: 65 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ tvm_option(USE_THREADS "Build with thread support" ON)
tvm_option(USE_LLVM "Build with LLVM, can be set to specific llvm-config path" OFF)
tvm_option(USE_STACKVM_RUNTIME "Include stackvm into the runtime" OFF)
tvm_option(USE_GRAPH_RUNTIME "Build with tiny graph runtime" ON)
tvm_option(USE_GRAPH_RUNTIME_DEBUG "Build with tiny graph runtime debug mode" OFF)
tvm_option(USE_GRAPH_RUNTIME_CUDA_GRAPH "Build with tiny graph runtime with CUDA Graph for GPUs" OFF)
tvm_option(USE_PROFILER "Build profiler for the VM and graph runtime" ON)
tvm_option(USE_OPENMP "Build with OpenMP thread pool implementation" OFF)
tvm_option(USE_RELAY_DEBUG "Building Relay in debug mode..." OFF)
tvm_option(USE_RTTI "Build with RTTI" ON)
Expand All @@ -47,6 +48,7 @@ tvm_option(USE_TF_TVMDSOOP "Build with TensorFlow TVMDSOOp" OFF)
tvm_option(USE_FALLBACK_STL_MAP "Use TVM's POD compatible Map" OFF)
tvm_option(USE_ETHOSN "Build with Arm Ethos-N" OFF)
tvm_option(INDEX_DEFAULT_I64 "Defaults the index datatype to int64" ON)
tvm_option(USE_LIBBACKTRACE "Build libbacktrace to supply linenumbers on stack traces" AUTO)

# 3rdparty libraries
tvm_option(DLPACK_PATH "Path to DLPACK" "3rdparty/dlpack/include")
Expand Down Expand Up @@ -74,6 +76,7 @@ tvm_option(USE_CPP_RPC "Build CPP RPC" OFF)
tvm_option(USE_TFLITE "Build with tflite support" OFF)
tvm_option(USE_TENSORFLOW_PATH "TensorFlow root path when use TFLite" none)
tvm_option(USE_COREML "Build with coreml support" OFF)
tvm_option(USE_BNNS "Build with BNNS support" OFF)
tvm_option(USE_TARGET_ONNX "Build with ONNX Codegen support" OFF)
tvm_option(USE_ARM_COMPUTE_LIB "Build with Arm Compute Library" OFF)
tvm_option(USE_ARM_COMPUTE_LIB_GRAPH_RUNTIME "Build with Arm Compute Library graph runtime" OFF)
Expand Down Expand Up @@ -136,6 +139,8 @@ if(MSVC)
add_compile_options(/wd4146)
# 'inline': used more than once
add_compile_options(/wd4141)
# unknown pragma
add_compile_options(/wd4068)
else(MSVC)
set(WARNING_FLAG -Wall)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
Expand Down Expand Up @@ -261,13 +266,6 @@ list(APPEND COMPILER_SRCS ${RELAY_BACKEND_SRCS})
list(APPEND COMPILER_SRCS ${RELAY_IR_SRCS})
list(APPEND COMPILER_SRCS ${RELAY_QNN_SRCS})


if(USE_VM_PROFILER)
message(STATUS "Build compiler with Relay VM profiler support...")
file(GLOB BACKEND_VM_PROFILER_SRCS src/relay/backend/vm/profiler/*.cc)
list(APPEND COMPILER_SRCS ${BACKEND_VM_PROFILER_SRCS})
endif(USE_VM_PROFILER)

file(GLOB DATATYPE_SRCS src/target/datatype/*.cc)
list(APPEND COMPILER_SRCS ${DATATYPE_SRCS})
list(APPEND COMPILER_SRCS "src/target/datatype/myfloat/myfloat.cc")
Expand Down Expand Up @@ -314,20 +312,29 @@ if(USE_GRAPH_RUNTIME)
file(GLOB RUNTIME_GRAPH_SRCS src/runtime/graph/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_SRCS})

if(USE_GRAPH_RUNTIME_DEBUG)
message(STATUS "Build with Graph runtime debug support...")
file(GLOB RUNTIME_GRAPH_DEBUG_SRCS src/runtime/graph/debug/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_DEBUG_SRCS})
set_source_files_properties(${RUNTIME_GRAPH_SRCS}
PROPERTIES COMPILE_DEFINITIONS "TVM_GRAPH_RUNTIME_DEBUG")
endif(USE_GRAPH_RUNTIME_DEBUG)
endif(USE_GRAPH_RUNTIME)

# convert old options for profiler
if(USE_GRAPH_RUNTIME_DEBUG)
unset(USE_GRAPH_RUNTIME_DEBUG CACHE)
set(USE_PROFILER ON)
endif()
if(USE_VM_PROFILER)
message(STATUS "Build with Relay VM profiler support...")
unset(USE_VM_PROFILER CACHE)
set(USE_PROFILER ON)
endif()

if(USE_PROFILER)
message(STATUS "Build with profiler...")

file(GLOB RUNTIME_GRAPH_DEBUG_SRCS src/runtime/graph/debug/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_DEBUG_SRCS})
set_source_files_properties(${RUNTIME_GRAPH_SRCS}
PROPERTIES COMPILE_DEFINITIONS "TVM_GRAPH_RUNTIME_DEBUG")

file(GLOB RUNTIME_VM_PROFILER_SRCS src/runtime/vm/profiler/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_VM_PROFILER_SRCS})
endif(USE_VM_PROFILER)
endif(USE_PROFILER)

# Module rules
include(cmake/modules/VTA.cmake)
Expand All @@ -354,6 +361,7 @@ include(cmake/modules/contrib/HybridDump.cmake)
include(cmake/modules/contrib/TFLite.cmake)
include(cmake/modules/contrib/TF_TVMDSOOP.cmake)
include(cmake/modules/contrib/CoreML.cmake)
include(cmake/modules/contrib/BNNS.cmake)
include(cmake/modules/contrib/ONNX.cmake)
include(cmake/modules/contrib/ArmComputeLib.cmake)
include(cmake/modules/contrib/TensorRT.cmake)
Expand Down Expand Up @@ -383,6 +391,13 @@ add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs> $<TARGET_OBJECTS:tvm_runtime_o
set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
add_library(tvm_runtime SHARED $<TARGET_OBJECTS:tvm_runtime_objs>)
set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
target_compile_definitions(tvm_objs PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
target_compile_definitions(tvm_runtime_objs PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
target_compile_definitions(tvm PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
target_compile_definitions(tvm_runtime PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)

# logging option for libbacktrace
include(cmake/modules/Logging.cmake)

if(USE_MICRO)
# NOTE: cmake doesn't track dependencies at the file level across subdirectories. For the
Expand All @@ -398,9 +413,9 @@ endif()
if(USE_RELAY_DEBUG)
message(STATUS "Building Relay in debug mode...")
target_compile_definitions(tvm_objs PRIVATE "USE_RELAY_DEBUG")
target_compile_definitions(tvm_objs PRIVATE "DMLC_LOG_DEBUG")
target_compile_definitions(tvm_objs PRIVATE "TVM_LOG_DEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "USE_RELAY_DEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "DMLC_LOG_DEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "TVM_LOG_DEBUG")
else()
target_compile_definitions(tvm_objs PRIVATE "NDEBUG")
target_compile_definitions(tvm_runtime_objs PRIVATE "NDEBUG")
Expand Down Expand Up @@ -471,6 +486,7 @@ if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# once minimum CMake version is bumped up to 3.13 or above.
target_link_libraries(tvm PRIVATE ${HIDE_SYMBOLS_LINKER_FLAGS})
target_link_libraries(tvm_runtime PRIVATE ${HIDE_SYMBOLS_LINKER_FLAGS})
target_compile_definitions(tvm_allvisible PUBLIC DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>)
endif()

# Tests
Expand Down Expand Up @@ -539,3 +555,33 @@ if(MSVC)
target_compile_definitions(tvm_objs PRIVATE -DTVM_EXPORTS)
target_compile_definitions(tvm_runtime_objs PRIVATE -DTVM_EXPORTS)
endif()

set(TVM_IS_DEBUG_BUILD OFF)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_CXX_FLAGS MATCHES "-g")
set(TVM_IS_DEBUG_BUILD ON)
endif()

# Change relative paths in backtrace to absolute ones
if(TVM_IS_DEBUG_BUILD)
set(FILE_PREFIX_MAP_FLAG "-ffile-prefix-map=..=${CMAKE_CURRENT_SOURCE_DIR}")
target_compile_options(tvm PRIVATE "${FILE_PREFIX_MAP_FLAG}")
CHECK_CXX_COMPILER_FLAG("${FILE_PREFIX_MAP_FLAG}" FILE_PREFIX_MAP_SUPPORTED)
if(FILE_PREFIX_MAP_SUPPORTED)
target_compile_options(tvm PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${FILE_PREFIX_MAP_FLAG}>)
target_compile_options(tvm_objs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${FILE_PREFIX_MAP_FLAG}>)
target_compile_options(tvm_runtime PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${FILE_PREFIX_MAP_FLAG}>)
target_compile_options(tvm_runtime_objs PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${FILE_PREFIX_MAP_FLAG}>)
endif()
endif()

# Run dsymutil to generate debugging symbols for backtraces
if(APPLE AND TVM_IS_DEBUG_BUILD)
find_program(DSYMUTIL dsymutil)
mark_as_advanced(DSYMUTIL)
add_custom_command(TARGET tvm
POST_BUILD
COMMAND ${DSYMUTIL} ARGS $<TARGET_FILE:tvm>
COMMENT "Running dsymutil"
VERBATIM
)
endif()
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ We do encourage everyone to work anything they are interested in.
- [Thierry Moreau](https://github.com/tmoreau89) (PMC): @tmoreau89 - vta
- [Kazutaka Morita](https://github.com/kazum): @kazum - frontends, opencl
- [Krzysztof Parzyszek](https://github.com/kparzysz-quic): @kparzysz-quic - hexagon, llvm
- [Andrew Reusch](https://github.com/areusch): @areusch - runtime, µTVM
- [Jared Roesch](https://github.com/jroesch) (PMC): @jroesch - relay
- [Siju Samuel](https://github.com/siju-samuel): @siju-samuel - frontends
- [Siva](https://github.com/srkreddy1238): @srkreddy1238 - frontends, golang
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ci_cpu = "tlcpack/ci-cpu:v0.72-t0"
ci_wasm = "tlcpack/ci-wasm:v0.70"
ci_i386 = "tlcpack/ci-i386:v0.72-t0"
ci_qemu = "tlcpack/ci-qemu:v0.01"
ci_arm = "tlcpack/ci-arm:v0.01"
ci_arm = "tlcpack/ci-arm:v0.02"
// <--- End of regex-scanned config.

// tvm libraries
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ License
Contribute to TVM
-----------------
TVM adopts apache committer model, we aim to create an open source project that is maintained and owned by the community.
Checkout the [Contributor Guide](https://tvm.apache.org/docs/contribute/)
Check out the [Contributor Guide](https://tvm.apache.org/docs/contribute/).

Acknowledgement
---------------
Expand Down
4 changes: 2 additions & 2 deletions apps/android_camera/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include $(config)
APP_ABI ?= all
APP_STL := c++_shared

APP_CPPFLAGS += -DDMLC_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
APP_CPPFLAGS += -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
ifeq ($(USE_OPENCL), 1)
APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
endif
Expand All @@ -43,4 +43,4 @@ endif

ifeq ($(USE_SORT), 1)
APP_CPPFLAGS += -DUSE_SORT=1
endif
endif
38 changes: 23 additions & 15 deletions apps/android_camera/app/src/main/jni/tvm_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@

#include <fstream>

/* Enable custom logging - this will cause TVM to pass every log message
* through CustomLogMessage instead of LogMessage. By enabling this, we must
* implement dmlc::CustomLogMessage::Log. We use this to pass TVM log
* messages to Android logcat.
#define DMLC_USE_LOGGING_LIBRARY <tvm/runtime/logging.h>
#define TVM_BACKTRACE_DISABLED 1
/* Enable custom logging - this will cause TVM to use a custom implementation
* of tvm::runtime::detail::LogMessage. We use this to pass TVM log messages to
* Android logcat.
*/
#define DMLC_LOG_CUSTOMIZE 1

/* Ensure that fatal errors are passed to the logger before throwing
* in LogMessageFatal
*/
#define DMLC_LOG_BEFORE_THROW 1
#define TVM_LOG_CUSTOMIZE 1

#include "../src/runtime/c_runtime_api.cc"
#include "../src/runtime/cpu_device_api.cc"
Expand Down Expand Up @@ -72,8 +68,20 @@

#include <android/log.h>

void dmlc::CustomLogMessage::Log(const std::string& msg) {
// This is called for every message logged by TVM.
// We pass the message to logcat.
__android_log_write(ANDROID_LOG_DEBUG, "TVM_RUNTIME", msg.c_str());
}
namespace tvm {
namespace runtime {
namespace detail {
// Override logging mechanism
void LogFatalImpl(const std::string& file, int lineno, const std::string& message) {
std::string m = file + ":" + std::to_string(lineno) + ": " + message;
__android_log_write(ANDROID_LOG_DEBUG, "TVM_RUNTIME", m.c_str());
throw InternalError(file, lineno, message);
}
void LogMessageImpl(const std::string& file, int lineno, const std::string& message) {
std::string m = file + ":" + std::to_string(lineno) + ": " + message;
__android_log_write(ANDROID_LOG_DEBUG, "TVM_RUNTIME", m.c_str());
}

} // namespace detail
} // namespace runtime
} // namespace tvm
2 changes: 1 addition & 1 deletion apps/android_camera/models/prepare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main(model_str, output_path):
f.write(graph)
print("dumping params...")
with open(output_path_str + "/" + "deploy_param.params", "wb") as f:
f.write(relay.save_param_dict(params))
f.write(runtime.save_param_dict(params))
print("dumping labels...")
synset_url = "".join(
[
Expand Down
2 changes: 1 addition & 1 deletion apps/android_deploy/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include $(config)

APP_STL := c++_static

APP_CPPFLAGS += -DDMLC_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
APP_CPPFLAGS += -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
ifeq ($(USE_OPENCL), 1)
APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
endif
3 changes: 3 additions & 0 deletions apps/android_deploy/app/src/main/jni/tvm_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

#include <fstream>

#define DMLC_USE_LOGGING_LIBRARY <tvm/runtime/logging.h>
#define TVM_BACKTRACE_DISABLED 1

#include "../src/runtime/c_runtime_api.cc"
#include "../src/runtime/cpu_device_api.cc"
#include "../src/runtime/dso_library.cc"
Expand Down
2 changes: 1 addition & 1 deletion apps/android_rpc/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include $(config)
APP_ABI ?= armeabi-v7a arm64-v8a x86 x86_64 mips
APP_STL := c++_shared

APP_CPPFLAGS += -DDMLC_LOG_STACK_TRACE=0 -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
APP_CPPFLAGS += -DTVM4J_ANDROID=1 -std=c++14 -Oz -frtti
ifeq ($(USE_OPENCL), 1)
APP_CPPFLAGS += -DTVM_OPENCL_RUNTIME=1
endif
Expand Down
37 changes: 23 additions & 14 deletions apps/android_rpc/app/src/main/jni/tvm_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@

#include <fstream>

/* Enable custom logging - this will cause TVM to pass every log message
* through CustomLogMessage instead of LogMessage. By enabling this, we must
* implement dmlc::CustomLogMessage::Log. We use this to pass TVM log
* messages to Android logcat.
#define DMLC_USE_LOGGING_LIBRARY <tvm/runtime/logging.h>
#define TVM_BACKTRACE_DISABLED 1
/* Enable custom logging - this will cause TVM to use a custom implementation
* of tvm::runtime::detail::LogMessage. We use this to pass TVM log messages to
* Android logcat.
*/
#define DMLC_LOG_CUSTOMIZE 1

/* Ensure that fatal errors are passed to the logger before throwing
* in LogMessageFatal
*/
#define DMLC_LOG_BEFORE_THROW 1
#define TVM_LOG_CUSTOMIZE 1

#include "../src/runtime/c_runtime_api.cc"
#include "../src/runtime/cpu_device_api.cc"
Expand All @@ -47,6 +43,7 @@
#include "../src/runtime/module.cc"
#include "../src/runtime/ndarray.cc"
#include "../src/runtime/object.cc"
#include "../src/runtime/profiling.cc"
#include "../src/runtime/registry.cc"
#include "../src/runtime/rpc/rpc_channel.cc"
#include "../src/runtime/rpc/rpc_endpoint.cc"
Expand Down Expand Up @@ -80,8 +77,20 @@

#include <android/log.h>

void dmlc::CustomLogMessage::Log(const std::string& msg) {
// This is called for every message logged by TVM.
// We pass the message to logcat.
__android_log_write(ANDROID_LOG_DEBUG, "TVM_RUNTIME", msg.c_str());
namespace tvm {
namespace runtime {
namespace detail {
// Override logging mechanism
void LogFatalImpl(const std::string& file, int lineno, const std::string& message) {
std::string m = file + ":" + std::to_string(lineno) + ": " + message;
__android_log_write(ANDROID_LOG_DEBUG, "TVM_RUNTIME", m.c_str());
throw InternalError(file, lineno, message);
}
void LogMessageImpl(const std::string& file, int lineno, const std::string& message) {
std::string m = file + ":" + std::to_string(lineno) + ": " + message;
__android_log_write(ANDROID_LOG_DEBUG, "TVM_RUNTIME", m.c_str());
}

} // namespace detail
} // namespace runtime
} // namespace tvm
6 changes: 4 additions & 2 deletions apps/bundle_deploy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ PKG_CXXFLAGS = ${PKG_COMPILE_OPTS} -std=c++14 \
-I${TVM_ROOT}/include \
-I${DMLC_CORE}/include \
-I${TVM_ROOT}/3rdparty/dlpack/include \
-Icrt_config
-Icrt_config \
-DDMLC_USE_LOGGING_LIBRARY=\<tvm/runtime/logging.h\>
PKG_CFLAGS = ${PKG_COMPILE_OPTS} \
-I${TVM_ROOT}/include \
-I${DMLC_CORE}/include \
-I${TVM_ROOT}/3rdparty/dlpack/include \
-Icrt_config
-Icrt_config \
-DDMLC_USE_LOGGING_LIBRARY=\<tvm/runtime/logging.h\>

PKG_LDFLAGS = -pthread -lm

Expand Down
Loading

0 comments on commit 5201391

Please sign in to comment.