diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2a8c608a7f..18b09c7239 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1815,10 +1815,6 @@ foreach(target_name ${ONNXRUNTIME_TARGETS}) include(${target_name}.cmake) endforeach() -if(MSVC AND onnxruntime_ENABLE_EAGER_MODE) - target_compile_options(onnxruntime_eager PUBLIC "/wd4100" "/wd4324" "/wd4458" "/wd4127" "/wd4193" "/wd4624" "/wd4702") -endif() - if (CMAKE_SYSTEM_NAME STREQUAL "Android") list(APPEND onnxruntime_EXTERNAL_LIBRARIES log) endif() diff --git a/cmake/onnxruntime_eager.cmake b/cmake/onnxruntime_eager.cmake index fbca8d66d0..2fb2f8a852 100644 --- a/cmake/onnxruntime_eager.cmake +++ b/cmake/onnxruntime_eager.cmake @@ -9,6 +9,18 @@ file(GLOB onnxruntime_eager_srcs CONFIGURE_DEPENDS source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_eager_srcs}) add_library(onnxruntime_eager ${onnxruntime_eager_srcs}) +if(MSVC AND onnxruntime_ENABLE_EAGER_MODE) + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_aten.cpp" PROPERTIES COMPILE_FLAGS "/wd4100" COMPILE_FLAGS "/wd4458") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_customops.g.cpp" PROPERTIES COMPILE_FLAGS "/wd4100") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_backends.cpp" PROPERTIES COMPILE_FLAGS "/wd4100") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_hooks.cpp" PROPERTIES COMPILE_FLAGS "/wd4100") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_eager.cpp" PROPERTIES COMPILE_FLAGS "/wd4100") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_log.cpp" PROPERTIES COMPILE_FLAGS "/wd4100" COMPILE_FLAGS "/wd4324") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_guard.cpp" PROPERTIES COMPILE_FLAGS "/wd4100") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_tensor.cpp" PROPERTIES COMPILE_FLAGS "/wd4100" COMPILE_FLAGS "/wd4458" COMPILE_FLAGS "/wd4127") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_ops.cpp" PROPERTIES COMPILE_FLAGS "/wd4100") + set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_util.cpp" PROPERTIES COMPILE_FLAGS "/wd4100") +endif() install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/eager DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core) onnxruntime_add_include_to_target(onnxruntime_eager onnxruntime_common onnxruntime_framework onnxruntime_optimizer onnxruntime_graph onnx onnx_proto ${PROTOBUF_LIB} flatbuffers) if(onnxruntime_ENABLE_INSTRUMENT) diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake index 150d730c1e..fc6da05acd 100644 --- a/cmake/onnxruntime_python.cmake +++ b/cmake/onnxruntime_python.cmake @@ -32,7 +32,7 @@ if (onnxruntime_ENABLE_EAGER_MODE) list(APPEND CMAKE_PREFIX_PATH ${onnxruntime_PREBUILT_PYTORCH_PATH}) find_package(Torch REQUIRED) find_library(TORCH_PYTHON_LIBRARY torch_python PATHS "${TORCH_INSTALL_PREFIX}/lib") - + file(GLOB onnxruntime_eager_extension_srcs CONFIGURE_DEPENDS "${ORTTRAINING_ROOT}/orttraining/eager/*.cpp" ) @@ -114,6 +114,9 @@ if (onnxruntime_ENABLE_EAGER_MODE) set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_guard.cpp" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_tensor.cpp" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter) endif() + if (MSVC) + target_compile_options(onnxruntime_pybind11_state PUBLIC "/wd4100" "/wd4324" "/wd4458" "/wd4127" "/wd4193" "/wd4624" "/wd4702") + endif() endif() target_link_libraries(onnxruntime_pybind11_state PRIVATE diff --git a/orttraining/orttraining/eager/test/ort_eps_test.py b/orttraining/orttraining/eager/test/ort_eps_test.py index 394e3b5fde..662eb9ae64 100644 --- a/orttraining/orttraining/eager/test/ort_eps_test.py +++ b/orttraining/orttraining/eager/test/ort_eps_test.py @@ -98,7 +98,7 @@ class OrtEPTests(unittest.TestCase): def test_import_custom_eps(self): torch_ort.set_device(0, 'CPUExecutionProvider', {}) - torch_ort._register_provider_lib('TestExecutionProvider', self.get_test_execution_provider_path(), {'some_config':'val'}) + torch_ort._register_provider_lib('TestExecutionProvider', self.get_test_execution_provider_path(), {}) torch_ort.set_device(1, 'TestExecutionProvider', {'device_id':'0', 'some_config':'val'}) ort_device = torch_ort.device(1) torch_ort._register_provider_lib('TestExecutionProvider', self.get_test_execution_provider_path(), {}) diff --git a/orttraining/orttraining/python/orttraining_python_module.cc b/orttraining/orttraining/python/orttraining_python_module.cc index 7730e3d56d..024e5c0c5e 100644 --- a/orttraining/orttraining/python/orttraining_python_module.cc +++ b/orttraining/orttraining/python/orttraining_python_module.cc @@ -293,7 +293,7 @@ PYBIND11_MODULE(onnxruntime_pybind11_state, m) { addObjectMethodsForTraining(m, ORTTrainingRegisterExecutionProviders); #ifdef ENABLE_EAGER_MODE - //addObjectMethodsForEager(m); + addObjectMethodsForEager(m); #endif m.def("_register_provider_lib", [](const std::string& name, diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 21d2f5bf4f..a44d6a19c6 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -613,24 +613,15 @@ def run_subprocess(args, cwd=None, capture_stdout=False, dll_path=None, my_env = os.environ.copy() if dll_path: - if is_windows(): - my_env["PATH"] = dll_path + os.pathsep + my_env["PATH"] + if "LD_LIBRARY_PATH" in my_env: + my_env["LD_LIBRARY_PATH"] += os.pathsep + dll_path else: - if "LD_LIBRARY_PATH" in my_env: - my_env["LD_LIBRARY_PATH"] += os.pathsep + dll_path - else: - my_env["LD_LIBRARY_PATH"] = dll_path + my_env["LD_LIBRARY_PATH"] = dll_path if python_path: - if is_windows(): - if "PYTHONPATH" in my_env: - my_env["PYTHONPATH"] = python_path + os.pathsep + my_env["PYTHONPATH"] - else: - my_env["PYTHONPATH"] = python_path + if "PYTHONPATH" in my_env: + my_env["PYTHONPATH"] += os.pathsep + python_path else: - if "PYTHONPATH" in my_env: - my_env["PYTHONPATH"] += os.pathsep + python_path - else: - my_env["PYTHONPATH"] = python_path + my_env["PYTHONPATH"] = python_path my_env.update(env)