From f501b6e2349b69bfb2f8738fe009467b1abe5437 Mon Sep 17 00:00:00 2001 From: RandySheriffH <48490400+RandySheriffH@users.noreply.github.com> Date: Tue, 8 Oct 2019 12:02:45 -0700 Subject: [PATCH] pack pyop in nightly build (#2018) * pack pyop in nightly build * correct logic * add comment * exclude debug build * add dependency * reset postbuild rule * remove dep --- cmake/onnxruntime_python.cmake | 12 +++++++++++- setup.py | 8 +++++++- tools/ci_build/build.py | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake index 088705037f..4a6fe1c421 100644 --- a/cmake/onnxruntime_python.cmake +++ b/cmake/onnxruntime_python.cmake @@ -95,6 +95,7 @@ set(onnxruntime_pybind11_state_dependencies ) add_dependencies(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_dependencies}) + if (MSVC) # if MSVC, pybind11 looks for release version of python lib (pybind11/detail/common.h undefs _DEBUG) target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} @@ -246,4 +247,13 @@ if (onnxruntime_USE_NUPHAR) ${onnxruntime_python_nuphar_python_srcs} $/onnxruntime/nuphar/ ) -endif() \ No newline at end of file +endif() + +if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS) + add_custom_command( + TARGET onnxruntime_pybind11_state POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + $ + $/onnxruntime/capi/ + ) +endif() diff --git a/setup.py b/setup.py index b1e826bba9..5c6e45e44e 100644 --- a/setup.py +++ b/setup.py @@ -120,16 +120,22 @@ if platform.system() == 'Linux': libs.extend(['libngraph.so', 'libcodegen.so', 'libcpu_backend.so', 'libmkldnn.so', 'libtbb_debug.so', 'libtbb_debug.so.2', 'libtbb.so', 'libtbb.so.2']) # Nuphar Libs libs.extend(['libtvm.so.0.5.1']) + if nightly_build: + libs.extend(['libonnxruntime_pywrapper.so']) elif platform.system() == "Darwin": libs = ['onnxruntime_pybind11_state.so', 'libmkldnn.0.dylib', 'mimalloc.so'] # TODO add libmklml and libiomp5 later. + if nightly_build: + libs.extend(['libonnxruntime_pywrapper.dylib']) else: libs = ['onnxruntime_pybind11_state.pyd', 'mkldnn.dll', 'mklml.dll', 'libiomp5md.dll'] libs.extend(['ngraph.dll', 'cpu_backend.dll', 'tbb.dll', 'mimalloc-override.dll', 'mimalloc-redirect.dll', 'mimalloc-redirect32.dll']) # Nuphar Libs libs.extend(['tvm.dll']) + if nightly_build: + libs.extend(['onnxruntime_pywrapper.dll']) if is_manylinux2010: - data = [] + data = ['capi/libonnxruntime_pywrapper.so'] if nightly_build else [] ext_modules = [ Extension( 'onnxruntime.capi.onnxruntime_pybind11_state', diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index aa7ec9dd69..b81ef1efd5 100755 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -369,7 +369,8 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home "-Donnxruntime_USE_FULL_PROTOBUF=" + ("ON" if args.use_full_protobuf or args.use_ngraph or args.use_tensorrt or args.build_server or args.gen_doc else "OFF"), "-Donnxruntime_DISABLE_CONTRIB_OPS=" + ("ON" if args.disable_contrib_ops else "OFF"), "-Donnxruntime_MSVC_STATIC_RUNTIME=" + ("ON" if args.enable_msvc_static_runtime else "OFF"), - "-Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=" + ("ON" if args.enable_language_interop_ops else "OFF"), + # enable pyop if it is nightly build + "-Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=" + ("ON" if args.enable_language_interop_ops or (args.config != 'Debug' and bool(os.getenv('NIGHTLY_BUILD') == '1')) else "OFF"), ] if args.use_brainslice: bs_pkg_name = args.brain_slice_package_name.split('.', 1)