diff --git a/CMakeLists.txt b/CMakeLists.txt index 23d146a65f2cc..81630841f5254 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,17 +201,13 @@ endif() # Custom targets add_custom_target(runtime DEPENDS tvm_runtime) -# Installation rulse +# Installation rules +install(TARGETS tvm DESTINATION lib${LIB_SUFFIX}) +install(TARGETS tvm_topi DESTINATION lib${LIB_SUFFIX}) install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX}) -if(WIN32) - install(TARGETS nnvm_compiler RUNTIME DESTINATION bin) - install(TARGETS nnvm_compiler ARCHIVE DESTINATION lib) -else() - install(TARGETS nnvm_compiler LIBRARY DESTINATION lib) -endif() +install(TARGETS nnvm_compiler DESTINATION lib${LIB_SUFFIX}) if (INSTALL_DEV) - install(TARGETS tvm DESTINATION lib${LIB_SUFFIX}) install( DIRECTORY "include/." DESTINATION "include" FILES_MATCHING diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml new file mode 100644 index 0000000000000..7f18f5eea4328 --- /dev/null +++ b/conda/conda_build_config.yaml @@ -0,0 +1,4 @@ +python: + - 3.5 + - 3.6 + - 3.7 \ No newline at end of file diff --git a/conda/nnvm/build.sh b/conda/nnvm/build.sh new file mode 100644 index 0000000000000..9f7889e610e75 --- /dev/null +++ b/conda/nnvm/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +cd nnvm/python +$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt diff --git a/conda/nnvm/meta.yaml b/conda/nnvm/meta.yaml new file mode 100644 index 0000000000000..a8b47d0de118b --- /dev/null +++ b/conda/nnvm/meta.yaml @@ -0,0 +1,39 @@ +{% set version = "0.4.dev" %} + +package: + name: nnvm + version: {{ version }} + +source: + path: ../.. + +build: + number: 0 + skip: True # [win] + +requirements: + build: + - {{ compiler('cxx') }} + host: + - python {{ python }} + - cython + - numpy + - setuptools + - decorator + - tvm-libs =={{ version }} + run: + - tvm =={{ version }} + - topi =={{ version }} + - tvm-libs =={{ version }} + - python + - {{ pin_compatible('numpy') }} + - decorator + +test: + imports: + - nnvm + +about: + home: https://github.com/dmlc/nnvm + license: Apache2 + summary: Bring deep learning to bare metal diff --git a/conda/topi/build.sh b/conda/topi/build.sh new file mode 100644 index 0000000000000..a1f5e491c8ebf --- /dev/null +++ b/conda/topi/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +cd topi/python +$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt diff --git a/topi/python/conda/meta.yaml b/conda/topi/meta.yaml similarity index 52% rename from topi/python/conda/meta.yaml rename to conda/topi/meta.yaml index 37d3a35da4339..af2fb4fd4228e 100644 --- a/topi/python/conda/meta.yaml +++ b/conda/topi/meta.yaml @@ -1,28 +1,32 @@ -{% set version = "0.1.dev" %} +{% set version = "0.4.dev" %} package: name: topi version: {{ version }} source: - path: .. + path: ../.. build: number: 0 - script: $PYTHON setup.py install requirements: - build: - - cmake - - python >=3 + host: + - python {{ python }} - numpy - setuptools - - nose - decorator + - tvm-libs =={{ version }} run: - - python >=3 - - numpy + - python + - {{ pin_compatible('numpy') }} - decorator + - tvm-libs =={{ version }} + - tvm =={{ version }} + +test: + imports: + - topi about: home: https://github.com/dmlc/tvm diff --git a/conda/tvm-libs/build.sh b/conda/tvm-libs/build.sh new file mode 100644 index 0000000000000..d427d922a21eb --- /dev/null +++ b/conda/tvm-libs/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +if [ -z "$PREFIX" ]; then + PREFIX="$CONDA_PREFIX" +fi + +rm -rf build || true +mkdir -p build +cd build +cmake -DUSE_LLVM=ON -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" .. +make -j2 VERBOSE=1 +make install +cd .. diff --git a/conda/tvm-libs/meta.yaml b/conda/tvm-libs/meta.yaml new file mode 100644 index 0000000000000..7875931fc1240 --- /dev/null +++ b/conda/tvm-libs/meta.yaml @@ -0,0 +1,25 @@ +{% set version = "0.4.dev" %} + +package: + name: tvm-libs + version: {{ version }} + +source: + path: ../.. + +build: + number: 0 + +requirements: + host: + # The OS X build will require some manual setup or it will break + # See https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html#macos-sdk + - {{ compiler('cxx') }} + build: + - llvmdev ==6.0.0 + - cmake + +about: + home: https://github.com/dmlc/tvm + license: Apache2 + summary: a low level domain specific language for compiling tensor computation pipelines \ No newline at end of file diff --git a/conda/tvm/build.sh b/conda/tvm/build.sh new file mode 100644 index 0000000000000..9c958a32e6294 --- /dev/null +++ b/conda/tvm/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +cd python +$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt diff --git a/python/conda/meta.yaml b/conda/tvm/meta.yaml similarity index 55% rename from python/conda/meta.yaml rename to conda/tvm/meta.yaml index f4e64dfd6bef6..478e095322ebc 100644 --- a/python/conda/meta.yaml +++ b/conda/tvm/meta.yaml @@ -1,4 +1,4 @@ -{% set version = "0.1.dev" %} +{% set version = "0.4.dev" %} package: name: tvm @@ -8,24 +8,27 @@ source: path: ../.. build: - number: 1 - skip: True # [win] - script_env: - - CONDA_CUDA_HOME + number: 0 requirements: build: - - llvmdev ==4.0.0 - - cmake - - python >=3 + - {{ compiler('cxx') }} + host: + - python {{ python }} + - cython - numpy - setuptools - - nose - decorator + - tvm-libs =={{ version }} run: - - python >=3 - - numpy + - python + - {{ pin_compatible('numpy') }} - decorator + - tvm-libs =={{ version }} + +test: + imports: + - tvm about: home: https://github.com/dmlc/tvm diff --git a/nnvm/python/conda/build.sh b/nnvm/python/conda/build.sh deleted file mode 100644 index 484d0626ae039..0000000000000 --- a/nnvm/python/conda/build.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -e - -if [ -z "$PREFIX" ]; then - PREFIX="$CONDA_PREFIX" -fi - -if [ "$(uname)" = 'Darwin' ] -then - # Without this, Apple's default shipped clang will refuse to see any - # headers like mutex. - export MACOSX_DEPLOYMENT_TARGET=10.9 -fi - -rm -rf build || true -mkdir -p build -cd build -# Enable static-libstdc++ to make it easier to link this library with -# other C++ compilers -CXXFLAGS=-static-libstdc++ cmake -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_INSTALL_PREFIX=${PREFIX} .. -make -j4 VERBOSE=1 -make install/fast -cd .. - -cd python -$PYTHON setup.py install -cd .. diff --git a/nnvm/python/conda/meta.yaml b/nnvm/python/conda/meta.yaml deleted file mode 100644 index 56e052000b405..0000000000000 --- a/nnvm/python/conda/meta.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{% set version = "0.1.dev" %} - -package: - name: nnvm - version: {{ version }} - -source: - path: ../.. - -build: - number: 1 - skip: True # [win] - -requirements: - build: - - cmake - - python >=3 - - numpy - - setuptools - - nose - - decorator - run: - - tvm - - topi - - python >=3 - - numpy - - decorator - -about: - home: https://github.com/dmlc/nnvm - license: Apache2 - summary: Bring deep learning to bare metal diff --git a/nnvm/python/nnvm/libinfo.py b/nnvm/python/nnvm/libinfo.py index 694bd0f92e7c2..652433fc3d8c5 100644 --- a/nnvm/python/nnvm/libinfo.py +++ b/nnvm/python/nnvm/libinfo.py @@ -28,10 +28,12 @@ def find_lib_path(): else: lib_name = "nnvm_compiler" if sys.platform.startswith('win32') else "libnnvm_compiler" - api_path = os.path.join(base_path, '../../lib/') - cmake_build_path = os.path.join(base_path, '../../../build/Release/') - cmake_build_path = os.path.join(base_path, '../../../build/') - dll_path = [base_path, api_path, cmake_build_path] + api_path = os.path.join(base_path, '..', '..', 'lib') + cmake_build_path_win = os.path.join(base_path, '..', '..', '..', 'build', 'Release') + cmake_build_path = os.path.join(base_path, '..', '..', '..', 'build') + install_path = os.path.join(base_path, '..', '..', '..') + dll_path = [base_path, api_path, cmake_build_path_win, cmake_build_path, + install_path] if sys.platform.startswith('linux') and os.environ.get('LD_LIBRARY_PATH', None): dll_path.extend([p.strip() for p in os.environ['LD_LIBRARY_PATH'].split(":")]) @@ -43,11 +45,12 @@ def find_lib_path(): if sys.platform.startswith('win32'): vs_configuration = 'Release' if platform.architecture()[0] == '64bit': - dll_path.append(os.path.join(base_path, '../../../build', vs_configuration)) - dll_path.append(os.path.join(base_path, '../../../windows/x64', vs_configuration)) + dll_path.append(os.path.join(base_path, '..', '..', '..', 'build', vs_configuration)) + dll_path.append(os.path.join(base_path, '..', '..', '..', 'windows', 'x64', + vs_configuration)) else: - dll_path.append(os.path.join(base_path, '../../../build', vs_configuration)) - dll_path.append(os.path.join(base_path, '../../../windows', vs_configuration)) + dll_path.append(os.path.join(base_path, '..', '..', '..', 'build', vs_configuration)) + dll_path.append(os.path.join(base_path, '..', '..', '..', 'windows', vs_configuration)) dll_path = [os.path.join(p, '%s.dll' % lib_name) for p in dll_path] elif sys.platform.startswith('darwin'): dll_path = [os.path.join(p, '%s.dylib' % lib_name) for p in dll_path] diff --git a/nnvm/python/setup.py b/nnvm/python/setup.py index 2b2102e319eba..f680690a2e10a 100644 --- a/nnvm/python/setup.py +++ b/nnvm/python/setup.py @@ -37,11 +37,18 @@ def config_cython(): libinfo = {'__file__': libinfo_py} exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo) -LIB_PATH = libinfo['find_lib_path']() -_, LIB_NAME = os.path.split(LIB_PATH[0]) __version__ = libinfo['__version__'] -curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) -rpath = os.path.relpath(LIB_PATH[0], curr_path) +if not os.getenv('CONDA_BUILD'): + LIB_PATH = libinfo['find_lib_path']() + _, LIB_NAME = os.path.split(LIB_PATH[0]) + curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) + rpath = os.path.relpath(LIB_PATH[0], curr_path) + setup_kwargs = dict( + include_package_data=True, + data_files=[('nnvm', [rpath])] + ) +else: + setup_kwargs = {} setup(name='nnvm', version=__version__, @@ -52,6 +59,4 @@ def config_cython(): ], packages=find_packages(), url='https://github.com/dmlc/nnvm', - include_package_data=True, - data_files=[('nnvm', [rpath])]) - + **setup_kwargs) diff --git a/python/conda/build.sh b/python/conda/build.sh deleted file mode 100644 index 60582de9523b7..0000000000000 --- a/python/conda/build.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -set -e - -# See Note [CUDA_TOOLKIT_ROOT_DIR versus CUDA_BIN_PATH] -if [ -z "$CONDA_CUDA_HOME" ]; then - CUDA_ARGS="" -else - # See Note [Bash argument quoting] - CUDA_ARGS="-DCUDA_TOOLKIT_ROOT_DIR=$(printf %q "$CONDA_CUDA_HOME")" -fi - -if [ -z "$PREFIX" ]; then - PREFIX="$CONDA_PREFIX" -fi - -if [ "$(uname)" = 'Darwin' ] -then - # Without this, Apple's default shipped clang will refuse to see any - # headers like mutex. - export MACOSX_DEPLOYMENT_TARGET=10.9 -fi - -rm -rf build || true -mkdir -p build -cd build -# Enable static-libstdc++ to make it easier to link this library with -# other C++ compilers -CXXFLAGS=-static-libstdc++ cmake -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DUSE_CUDA=1 -DUSE_LLVM=1 -DINSTALL_DEV=1 $CUDA_ARGS .. -make -j20 VERBOSE=1 -make install/fast -cd .. - -# Also install the headers for libraries that TVM vendored -mkdir -p "$PREFIX/include" -# TODO: arguably dlpack and dmlc-core should get its own packaging and -# install their headers themselves -cp -R dlpack/include/. "$PREFIX/include" -cp -R dmlc-core/include/. "$PREFIX/include" -# TODO: HalideIR's includes could conflict, but TVM currently assumes they -# are installed here, awfully enough -cp -R HalideIR/src/. "$PREFIX/include" - -cd python -$PYTHON setup.py install -cd .. diff --git a/python/setup.py b/python/setup.py index 188938d76c3d8..5ae7a6d909e46 100644 --- a/python/setup.py +++ b/python/setup.py @@ -27,14 +27,17 @@ def get_lib_path(): libinfo_py = os.path.join(CURRENT_DIR, './tvm/_ffi/libinfo.py') libinfo = {'__file__': libinfo_py} exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo) - lib_path = libinfo['find_lib_path']() version = libinfo['__version__'] - libs = [lib_path[0]] - if libs[0].find("runtime") == -1: - for name in lib_path[1:]: - if name.find("runtime") != -1: - libs.append(name) - break + if not os.getenv('CONDA_BUILD'): + lib_path = libinfo['find_lib_path']() + libs = [lib_path[0]] + if libs[0].find("runtime") == -1: + for name in lib_path[1:]: + if name.find("runtime") != -1: + libs.append(name) + break + else: + libs = None return libs, version LIB_LIST, __version__ = get_lib_path() @@ -89,23 +92,33 @@ def has_ext_modules(self): def is_pure(self): return False +include_libs = False +wheel_include_libs = False +if not os.getenv('CONDA_BUILD'): + if "bdist_wheel" in sys.argv: + wheel_include_libs = True + else: + include_libs = True + +setup_kwargs = {} + # For bdist_wheel only -if "bdist_wheel" in sys.argv: - with open("MANIFEST.in", "w") as fo: - for path in LIB_LIST: - shutil.copy(path, os.path.join(CURRENT_DIR, 'tvm')) - _, libname = os.path.split(path) - fo.write("include tvm/%s\n" % libname) +if wheel_include_libs: + for path in LIB_LIST: + shutil.copy(path, os.path.join(CURRENT_DIR, 'tvm')) + _, libname = os.path.split(path) + fo.write("include tvm/%s\n" % libname) setup_kwargs = { "include_package_data": True } -else: + +if include_libs: curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) for i, path in enumerate(LIB_LIST): LIB_LIST[i] = os.path.relpath(path, curr_path) setup_kwargs = { "include_package_data": True, - "data_files": [('tvm', LIB_LIST)] + "package_data": {'tvm': LIB_LIST} } setup(name='tvm', @@ -122,8 +135,9 @@ def is_pure(self): ext_modules=config_cython(), **setup_kwargs) -# Wheel cleanup -if "bdist_wheel" in sys.argv: + +if wheel_include_libs: + # Wheel cleanup os.remove("MANIFEST.in") for path in LIB_LIST: _, libname = os.path.split(path) diff --git a/python/tvm/_ffi/libinfo.py b/python/tvm/_ffi/libinfo.py index b449e712c32c3..390849f8536d4 100644 --- a/python/tvm/_ffi/libinfo.py +++ b/python/tvm/_ffi/libinfo.py @@ -40,11 +40,11 @@ def find_lib_path(name=None, search_path=None, optional=False): dll_path.extend([p.strip() for p in os.environ['DYLD_LIBRARY_PATH'].split(":")]) # Pip lib directory - dll_path.append(os.path.join(ffi_dir, "../")) + dll_path.append(os.path.join(ffi_dir, "..")) # Default cmake build directory dll_path.append(os.path.join(source_dir, "build")) dll_path.append(os.path.join(source_dir, "build", "Release")) - # Default mkae build directory + # Default make build directory dll_path.append(os.path.join(source_dir, "lib")) dll_path.append(install_lib_dir) diff --git a/topi/python/setup.py b/topi/python/setup.py index 6967051acbd8e..dadb79453857c 100644 --- a/topi/python/setup.py +++ b/topi/python/setup.py @@ -29,25 +29,31 @@ def get_lib_path(): libinfo_py = os.path.join(CURRENT_DIR, '../../python/tvm/_ffi/libinfo.py') libinfo = {'__file__': libinfo_py} exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo) - lib_path = libinfo['find_lib_path'](get_lib_names()) version = libinfo['__version__'] - libs = [lib_path[0]] - if libs[0].find("runtime") == -1: - for name in lib_path[1:]: - if name.find("runtime") != -1: - libs.append(name) - break + if not os.getenv('CONDA_BUILD'): + lib_path = libinfo['find_lib_path'](get_lib_names()) + libs = [lib_path[0]] + if libs[0].find("runtime") == -1: + for name in lib_path[1:]: + if name.find("runtime") != -1: + libs.append(name) + break + else: + libs = None return libs, version LIB_LIST, __version__ = get_lib_path() -curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) -for i, path in enumerate(LIB_LIST): - LIB_LIST[i] = os.path.relpath(path, curr_path) -setup_kwargs = { - "include_package_data": True, - "data_files": [('topi', LIB_LIST)] -} +if not os.getenv('CONDA_BUILD'): + curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) + for i, path in enumerate(LIB_LIST): + LIB_LIST[i] = os.path.relpath(path, curr_path) + setup_kwargs = { + "include_package_data": True, + "data_files": [('topi', LIB_LIST)] + } +else: + setup_kwargs = {} setup(name='topi', version=__version__,