diff --git a/CMakeLists.txt b/CMakeLists.txt index 72ac58c0b67e..7293abb60f7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -477,7 +477,7 @@ add_library(tvm SHARED $ $) + add_library(tvm_runtime STATIC $ $) set(NOTICE_MULTILINE "You have build static version of the TVM runtime library. Make " "sure to use --whole-archive when linking it into your project.") @@ -485,7 +485,7 @@ if(BUILD_STATIC_RUNTIME) add_custom_command(TARGET tvm_runtime POST_BUILD COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --yellow --bold ${NOTICE}) else() - add_library(tvm_runtime SHARED $) + add_library(tvm_runtime SHARED $ $) set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS "${TVM_NO_UNDEFINED_SYMBOLS}") endif() set_property(TARGET tvm_runtime APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}") diff --git a/python/tvm/__init__.py b/python/tvm/__init__.py index 57374c54b297..3f2f277d2926 100644 --- a/python/tvm/__init__.py +++ b/python/tvm/__init__.py @@ -23,7 +23,8 @@ # top-level alias # tvm._ffi -from ._ffi.base import TVMError, __version__ +from ._ffi.base import TVMError, __version__, _RUNTIME_ONLY + from ._ffi.runtime_ctypes import DataTypeCode, DataType from ._ffi import register_object, register_func, register_extension, get_global_func @@ -68,7 +69,7 @@ # Contrib initializers from .contrib import rocm as _rocm, nvcc as _nvcc, sdaccel as _sdaccel -if support.libinfo().get("USE_MICRO", "OFF") == "ON": +if not _RUNTIME_ONLY and support.libinfo().get("USE_MICRO", "OFF") == "ON": from . import micro # NOTE: This file should be python2 compatible so we can diff --git a/python/tvm/micro/__init__.py b/python/tvm/micro/__init__.py index ba966d3791bb..3b323f4227a2 100644 --- a/python/tvm/micro/__init__.py +++ b/python/tvm/micro/__init__.py @@ -15,12 +15,15 @@ # specific language governing permissions and limitations # under the License. """MicroTVM module for bare-metal backends""" - from .build import autotvm_build_func from .build import AutoTvmModuleLoader from .build import get_standalone_crt_dir from .build import get_microtvm_template_projects -from .model_library_format import export_model_library_format, UnsupportedInModelLibraryFormatError + +from .model_library_format import ( + export_model_library_format, + UnsupportedInModelLibraryFormatError, +) from .project import generate_project, GeneratedProject, TemplateProject from .session import ( create_local_graph_executor,