Skip to content

Commit

Permalink
[Support] Add libinfo into the runtime build (apache#9310)
Browse files Browse the repository at this point in the history
* Move libinfo into the runtime build

* put libinfo back into libtvm

* limit microtvm imports when we only have the runtime lib

* fix lint

* try conditional for micro import
  • Loading branch information
Matthew Brookhart authored and mehrdadh committed Dec 1, 2021
1 parent b1d6a19 commit 09a0e37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -478,15 +478,15 @@ add_library(tvm SHARED $<TARGET_OBJECTS:tvm_objs> $<TARGET_OBJECTS:tvm_runtime_o
set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_NO_UNDEFINED_SYMBOLS}")
set_property(TARGET tvm APPEND PROPERTY LINK_OPTIONS "${TVM_VISIBILITY_FLAG}")
if(BUILD_STATIC_RUNTIME)
add_library(tvm_runtime STATIC $<TARGET_OBJECTS:tvm_runtime_objs>)
add_library(tvm_runtime STATIC $<TARGET_OBJECTS:tvm_runtime_objs> $<TARGET_OBJECTS:tvm_libinfo_objs>)
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.")
string(CONCAT NOTICE ${NOTICE_MULTILINE})
add_custom_command(TARGET tvm_runtime POST_BUILD
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --yellow --bold ${NOTICE})
else()
add_library(tvm_runtime SHARED $<TARGET_OBJECTS:tvm_runtime_objs>)
add_library(tvm_runtime SHARED $<TARGET_OBJECTS:tvm_runtime_objs> $<TARGET_OBJECTS:tvm_libinfo_objs>)
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}")
Expand Down
5 changes: 3 additions & 2 deletions python/tvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions python/tvm/micro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 09a0e37

Please sign in to comment.