Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
0a172a9
[RUNTIME] Add libbacktrace for backtraces with line numbers
tkonolige Dec 16, 2020
27b9d39
Fix _Pragma issue on windows build
rkimball Jan 22, 2021
3db736f
allow libbacktrace patch
tkonolige Jan 22, 2021
e546407
add apache headers
tkonolige Jan 22, 2021
9e39bb5
lint fix
tkonolige Jan 22, 2021
926b9b7
handle early cmake versions
tkonolige Jan 22, 2021
c69df46
Move logging into runtime namespace. Add detail namespace for logging…
tkonolige Jan 25, 2021
ef74ccd
push CHECK_OP comparisons into functions to handle early versions of …
tkonolige Jan 25, 2021
6f8505e
make object files depend on libbacktrace
tkonolige Jan 25, 2021
a79c364
Make tvm::Error a subclass of dmlc::Error
tkonolige Jan 25, 2021
939a3d9
allow custom logging for non-standard backends
tkonolige Jan 25, 2021
6cd5457
forgot a not... whoops
tkonolige Jan 25, 2021
0b54636
allow user to override logging with TVM_LOG_CUSTOMIZE
tkonolige Jan 25, 2021
8d6b00c
ios_rpc builds
tkonolige Jan 25, 2021
3896ed5
formatting
tkonolige Jan 25, 2021
05c2984
fix android build
tkonolige Jan 25, 2021
c80610c
fix emcc
tkonolige Jan 26, 2021
4abe902
fix cmake
tkonolige Jan 26, 2021
5aa2e85
fix vitis_ai
tkonolige Jan 26, 2021
d4dd7d8
fix error message format. fix clang warnings
tkonolige Jan 27, 2021
2105e3f
fixes for older cmake
tkonolige Jan 28, 2021
0a83a2f
apply patch after update
tkonolige Jan 29, 2021
7d9e3b5
missing logging header
tkonolige Jan 29, 2021
34eed0b
set defines for cython
tkonolige Feb 1, 2021
ce3942a
specify debug build for testing
tkonolige Feb 1, 2021
c51ebfa
disable builtin patch step
tkonolige Feb 1, 2021
0323a73
more robust patching
tkonolige Feb 1, 2021
36640ea
more dmlc logging defines
tkonolige Feb 2, 2021
56584b9
address comments
tkonolige Feb 8, 2021
e7fb965
move backtrace definition to source file
tkonolige Feb 9, 2021
cc9f6c1
namespace windows backtrace correctly?
tkonolige Feb 9, 2021
cd04cb9
fix warnings on windows
tkonolige Feb 9, 2021
b53137f
Fix building on windows
rkimball Feb 10, 2021
d63e6bb
Fix unresolved symbol for function Backtrace on Windows. Apply style.
rkimball Feb 11, 2021
59fd4c3
pass dmlc flag to standalone crt
tkonolige Feb 11, 2021
b408ed4
forgot private
tkonolige Feb 11, 2021
5255c3d
switch to TVM_DLL
tkonolige Feb 11, 2021
a5589a4
more dll stuff
tkonolige Feb 11, 2021
76b0165
revert to windows-only approach
tkonolige Feb 11, 2021
6155a11
fix vta_fsim defines
tkonolige Feb 12, 2021
ef2c9f8
adding more -D...
tkonolige Feb 12, 2021
3a63b2c
vta flags
tkonolige Feb 15, 2021
b52f8f2
clean up added includes
tkonolige Feb 15, 2021
a5f9f49
bad rebase
tkonolige Feb 15, 2021
614a4e3
apparently include directories is needed on all targets
tkonolige Feb 15, 2021
8b2e098
fix flag for standalone crt
tkonolige Feb 16, 2021
935d941
remove unnessesary flags?
tkonolige Feb 16, 2021
ad0cf23
correctly depend on libbacktrace
tkonolige Feb 16, 2021
54ecb7a
fix overcommit in test
tkonolige Feb 19, 2021
54e69d2
revert layer change
tkonolige Feb 19, 2021
3e6edf8
use float16 for vgg test
tkonolige Feb 19, 2021
9634240
delete vgg ir printing test. it takes too much memory
tkonolige Feb 19, 2021
8ab5d59
only add flags for CXX
tkonolige Feb 22, 2021
a734de3
bump stack size on CI
tkonolige Feb 23, 2021
4c9f849
remove bad todo
tkonolige Feb 23, 2021
1799137
switch relay test to tvm so it stops running out of memory
tkonolige Feb 24, 2021
c5b9b12
fix workload
tkonolige Feb 24, 2021
7c68da1
Accidentally droped dmlc dep
tkonolige Feb 24, 2021
ccbe212
different ulimit change
tkonolige Feb 25, 2021
481461b
finally fix stack overflow
tkonolige Feb 26, 2021
f73b7e7
one global backtrace object
tkonolige Mar 5, 2021
2bc5dd1
rename
tkonolige Mar 8, 2021
3ef265f
formatting
tkonolige Mar 8, 2021
70e8d61
formatting
tkonolige Mar 9, 2021
1cd3306
move defines into header for jni
tkonolige Mar 16, 2021
0999ce1
switch to submodule
tkonolige Mar 16, 2021
4711201
Trigger CI
tkonolige Mar 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
62 changes: 60 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ 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)
set(_LIBBACKTRACE_DEFAULT OFF)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "Linux")
set(_LIBBACKTRACE_DEFAULT ON)
endif()
tvm_option(USE_LIBBACKTRACE "Build libbacktrace to supply linenumbers on stack traces" ${_LIBBACKTRACE_DEFAULT})

# 3rdparty libraries
tvm_option(DLPACK_PATH "Path to DLPACK" "3rdparty/dlpack/include")
Expand Down Expand Up @@ -137,6 +142,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 @@ -388,6 +395,26 @@ 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>)
Comment on lines +398 to +401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to define these on the external project for libbacktrace and then when you target_link_libraries to it you will get all of the PUBLIC compile definitions and include directories.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logging libraries are part of TVM, so I think the define should go there.

if(USE_LIBBACKTRACE)
message(STATUS "Building with libbacktrace...")
include(cmake/modules/Libbacktrace.cmake)
target_link_libraries(tvm PRIVATE libbacktrace)
target_link_libraries(tvm_runtime PRIVATE libbacktrace)
add_dependencies(tvm_runtime_objs libbacktrace)
# pre 3.12 versions of cmake cannot propagate include directories from imported targets so we set them manually
target_include_directories(tvm PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
target_include_directories(tvm_objs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
target_include_directories(tvm_runtime PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
target_include_directories(tvm_runtime_objs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libbacktrace/include")
else()
target_compile_definitions(tvm_objs PRIVATE TVM_BACKTRACE_DISABLED)
target_compile_definitions(tvm_runtime_objs PRIVATE TVM_BACKTRACE_DISABLED)
endif()

if(USE_MICRO)
# NOTE: cmake doesn't track dependencies at the file level across subdirectories. For the
# Unix Makefiles generator, need to add these explicit target-level dependency)
Expand All @@ -402,9 +429,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 @@ -475,6 +502,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 @@ -543,3 +571,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()
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @yzhliu for the android part


#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_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
36 changes: 22 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 Down Expand Up @@ -81,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
3 changes: 2 additions & 1 deletion apps/dso_plugin_module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ TVM_ROOT=$(shell cd ../..; pwd)
PKG_CFLAGS = -std=c++14 -O2 -fPIC\
-I${TVM_ROOT}/include\
-I${TVM_ROOT}/3rdparty/dmlc-core/include\
-I${TVM_ROOT}/3rdparty/dlpack/include
-I${TVM_ROOT}/3rdparty/dlpack/include\
-DDMLC_USE_LOGGING_LIBRARY=\<tvm/runtime/logging.h\>

PKG_LDFLAGS =-L${TVM_ROOT}/build
UNAME_S := $(shell uname -s)
Expand Down
3 changes: 2 additions & 1 deletion apps/extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ TVM_ROOT=$(shell cd ../..; pwd)
PKG_CFLAGS = -std=c++14 -O2 -fPIC\
-I${TVM_ROOT}/include\
-I${TVM_ROOT}/3rdparty/dmlc-core/include\
-I${TVM_ROOT}/3rdparty/dlpack/include
-I${TVM_ROOT}/3rdparty/dlpack/include\
-DDMLC_USE_LOGGING_LIBRARY=\<tvm/runtime/logging.h\>


PKG_LDFLAGS =-L${TVM_ROOT}/build
Expand Down
6 changes: 6 additions & 0 deletions apps/ios_rpc/tvmrpc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
"DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>",
"TVM_BACKTRACE_DISABLED=1",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
Expand Down Expand Up @@ -393,6 +395,10 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DMLC_USE_LOGGING_LIBRARY=<tvm/runtime/logging.h>",
"TVM_BACKTRACE_DISABLED=1",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand Down
2 changes: 1 addition & 1 deletion apps/ios_rpc/tvmrpc/TVMRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
#import <Foundation/Foundation.h>
// Customize logging mechanism, redirect to NSLOG
#define DMLC_LOG_CUSTOMIZE 1
#define TVM_LOG_CUSTOMIZE 1
#define TVM_METAL_RUNTIME 1

#include <tvm/runtime/packed_func.h>
Expand Down
16 changes: 13 additions & 3 deletions apps/ios_rpc/tvmrpc/TVMRuntime.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@
// CoreML
#include "../../../src/runtime/contrib/coreml/coreml_runtime.mm"

namespace dmlc {
namespace tvm {
namespace runtime {
namespace detail {
// Override logging mechanism
void CustomLogMessage::Log(const std::string& msg) { NSLog(@"%s", msg.c_str()); }
void LogFatalImpl(const std::string& file, int lineno, const std::string& message) {
throw tvm::runtime::InternalError(file, lineno, message);
}

void LogMessageImpl(const std::string& file, int lineno, const std::string& message) {
NSLog(@"%s:%d: %s", file.c_str(), lineno, message.c_str());
}
}
}
} // namespace dmlc

namespace tvm {
Expand All @@ -69,7 +79,7 @@ size_t Send(const void* data, size_t size) final {
ssize_t nbytes = [stream_ write:reinterpret_cast<const uint8_t*>(data) maxLength:size];
if (nbytes < 0) {
NSLog(@"%@", [stream_ streamError].localizedDescription);
throw dmlc::Error("Stream error");
throw tvm::Error("Stream error");
}
return nbytes;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/ios_rpc/tvmrpc/ViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ - (void)onReadAvailable {
if (flag == 2) {
[self onShutdownReceived];
}
} catch (const dmlc::Error& e) {
} catch (const tvm::Error& e) {
[self close];
}
}
Expand All @@ -123,7 +123,7 @@ - (void)onWriteAvailable {
if (flag == 2) {
[self onShutdownReceived];
}
} catch (const dmlc::Error& e) {
} catch (const tvm::Error& e) {
[self close];
}
}
Expand Down
5 changes: 5 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,8 @@ set(USE_TARGET_ONNX OFF)

# Whether enable BNNS runtime
set(USE_BNNS OFF)

# Whether to use libbacktrace
# Libbacktrace provides line and column information on stack traces from errors. It is only
# supported on linux and macOS.
# set(USE_LIBBACKTRACE OFF)
Loading