Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace some old file system calls with C++17 std::filesystem APIs. #19196

Merged
merged 38 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d965666
update
snnn Jan 17, 2024
9d55230
update
snnn Jan 18, 2024
0c7f1b0
Fix build
snnn Jan 18, 2024
cc89bbc
stash
snnn Jan 18, 2024
6cb7e0b
update
snnn Jan 18, 2024
bea81a6
update
snnn Jan 18, 2024
a87309f
update
snnn Jan 19, 2024
bf29599
push
snnn Jan 19, 2024
c1574c7
update
snnn Jan 19, 2024
e035b59
Merge remote-tracking branch 'origin/main' into snnn/filesystem
snnn Jan 24, 2024
2bd4e4e
update
snnn Jan 24, 2024
fecd8b0
revert
snnn Jan 24, 2024
fc583c1
revert
snnn Jan 24, 2024
82cb246
update
snnn Jan 24, 2024
2fc1543
format code
snnn Jan 24, 2024
6a489cc
Merge remote-tracking branch 'origin/main' into snnn/filesystem
snnn Jan 25, 2024
fef0732
Enable CPUINFO
snnn Feb 26, 2024
9a1142c
Merge branch 'snnn/enable_cpuinfo_for_onecore' into snnn/filesystem
snnn Feb 26, 2024
05947cb
update
snnn Mar 1, 2024
0eef1ed
Merge remote-tracking branch 'origin/main' into snnn/filesystem
snnn Mar 1, 2024
6b3ba12
update
snnn Mar 1, 2024
b1ba813
Merge remote-tracking branch 'origin/main' into snnn/filesystem
snnn Mar 1, 2024
7febd24
Merge remote-tracking branch 'origin/main' into snnn/filesystem2
snnn Mar 4, 2024
68d759d
update
snnn Mar 4, 2024
74b3e33
update
snnn Mar 4, 2024
b0a9bcf
update
snnn Mar 4, 2024
2572383
Merge branch 'snnn/filesystem2' of https://github.com/Microsoft/onnxr…
snnn Mar 4, 2024
f654009
update
snnn Mar 4, 2024
210cd1b
update
snnn Mar 4, 2024
77f6b85
Merge remote-tracking branch 'origin/main' into snnn/filesystem2
snnn Mar 4, 2024
cc23da1
update
snnn Mar 4, 2024
01c00c5
Update onnxruntime/test/providers/cpu/model_tests.cc
snnn Mar 6, 2024
e0c9d86
update
snnn Mar 6, 2024
d82c011
Merge branch 'snnn/filesystem' of https://github.com/snnn/onnxruntime…
snnn Mar 6, 2024
0ee115d
Merge remote-tracking branch 'origin/main' into snnn/filesystem
snnn Mar 6, 2024
e589fb2
update
snnn Mar 6, 2024
d1655e8
Merge remote-tracking branch 'origin/main' into snnn/filesystem
snnn Mar 8, 2024
dcb8d10
update
snnn Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1251,17 +1251,15 @@ if (onnxruntime_USE_TVM)
$<TARGET_PROPERTY:tvm,INTERFACE_INCLUDE_DIRECTORIES>)

set(onnxruntime_tvm_libs onnxruntime_providers_tvm)

# needs to link with stdc++fs in Linux
if (UNIX)
if (NOT APPLE)
set(FS_STDLIB stdc++fs)
endif()
endif()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES tvm ${FS_STDLIB})
list(APPEND onnxruntime_EXTERNAL_LIBRARIES tvm)
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES tvm)
endif()

# needs to link with stdc++fs in Linux
if (UNIX AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
set(FS_STDLIB stdc++fs)
endif()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${FS_STDLIB})

# onnxruntime-extensions
if (onnxruntime_USE_EXTENSIONS)
Expand Down
3 changes: 0 additions & 3 deletions cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,6 @@ if (onnxruntime_ENABLE_CPUINFO)
if (${onnxruntime_target_platform} MATCHES "^(ARM.*|arm.*)$" )
message(WARNING "Cpuinfo not included for compilation problems with Windows ARM.")
set(CPUINFO_SUPPORTED FALSE)
elseif (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
message(WARNING "Cpuinfo not included non-Desktop builds")
set(CPUINFO_SUPPORTED FALSE)
endif()
elseif (NOT ${onnxruntime_target_platform} MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64|arm64)$")
message(WARNING
Expand Down
134 changes: 73 additions & 61 deletions cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -734,34 +734,37 @@ target_include_directories(onnxruntime_test_utils PUBLIC "${TEST_SRC_DIR}/util/i
set_target_properties(onnxruntime_test_utils PROPERTIES FOLDER "ONNXRuntimeTest")
source_group(TREE ${TEST_SRC_DIR} FILES ${onnxruntime_test_utils_src})

set(onnx_test_runner_src_dir ${TEST_SRC_DIR}/onnx)
file(GLOB onnx_test_runner_common_srcs CONFIGURE_DEPENDS
${onnx_test_runner_src_dir}/*.h
${onnx_test_runner_src_dir}/*.cc)
if(NOT IOS)
set(onnx_test_runner_src_dir ${TEST_SRC_DIR}/onnx)
file(GLOB onnx_test_runner_common_srcs CONFIGURE_DEPENDS
${onnx_test_runner_src_dir}/*.h
${onnx_test_runner_src_dir}/*.cc)

list(REMOVE_ITEM onnx_test_runner_common_srcs ${onnx_test_runner_src_dir}/main.cc)
list(REMOVE_ITEM onnx_test_runner_common_srcs ${onnx_test_runner_src_dir}/main.cc)

onnxruntime_add_static_library(onnx_test_runner_common ${onnx_test_runner_common_srcs})
if(MSVC)
target_compile_options(onnx_test_runner_common PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
"$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
else()
target_compile_definitions(onnx_test_runner_common PUBLIC -DNSYNC_ATOMIC_CPP11)
target_include_directories(onnx_test_runner_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
onnxruntime_add_include_to_target(onnx_test_runner_common nsync::nsync_cpp)
endif()
if (MSVC AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
#TODO: fix the warnings, they are dangerous
target_compile_options(onnx_test_runner_common PRIVATE "/wd4244")
endif()
onnxruntime_add_include_to_target(onnx_test_runner_common onnxruntime_common onnxruntime_framework
onnxruntime_test_utils onnx onnx_proto re2::re2 flatbuffers::flatbuffers Boost::mp11 safeint_interface)
onnxruntime_add_static_library(onnx_test_runner_common ${onnx_test_runner_common_srcs})
if(MSVC)
target_compile_options(onnx_test_runner_common PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
"$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
else()
target_compile_definitions(onnx_test_runner_common PUBLIC -DNSYNC_ATOMIC_CPP11)
target_include_directories(onnx_test_runner_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
onnxruntime_add_include_to_target(onnx_test_runner_common nsync::nsync_cpp)
endif()
if (MSVC AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
#TODO: fix the warnings, they are dangerous
target_compile_options(onnx_test_runner_common PRIVATE "/wd4244")
endif()
onnxruntime_add_include_to_target(onnx_test_runner_common onnxruntime_common onnxruntime_framework
onnxruntime_test_utils onnx onnx_proto re2::re2 flatbuffers::flatbuffers Boost::mp11 safeint_interface)

add_dependencies(onnx_test_runner_common onnx_test_data_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnx_test_runner_common PRIVATE ${eigen_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
add_dependencies(onnx_test_runner_common onnx_test_data_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnx_test_runner_common PRIVATE ${eigen_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})

set_target_properties(onnx_test_runner_common PROPERTIES FOLDER "ONNXRuntimeTest")
set_target_properties(onnx_test_runner_common PROPERTIES FOLDER "ONNXRuntimeTest")
set(onnx_test_runner_common_lib onnx_test_runner_common)
endif()

set(all_tests ${onnxruntime_test_common_src} ${onnxruntime_test_ir_src} ${onnxruntime_test_optimizer_src}
${onnxruntime_test_framework_src} ${onnxruntime_test_providers_src} ${onnxruntime_test_quantiztion_src})
Expand Down Expand Up @@ -819,6 +822,13 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
"${TEST_SRC_DIR}/providers/cpu/tensor/grid_sample_test.cc")
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
message("Disable model tests in onnxruntime_test_all")
snnn marked this conversation as resolved.
Show resolved Hide resolved
list(REMOVE_ITEM all_tests
"${TEST_SRC_DIR}/providers/cpu/model_tests.cc"
)
endif()

set(test_all_args)
if (onnxruntime_USE_TENSORRT)
# TRT EP CI takes much longer time when updating to TRT 8.2
Expand All @@ -836,7 +846,7 @@ AddTest(
TARGET onnxruntime_test_all
SOURCES ${all_tests} ${onnxruntime_unittest_main_src}
LIBS
onnx_test_runner_common ${onnxruntime_test_providers_libs} ${onnxruntime_test_common_libs}
${onnx_test_runner_common_lib} ${onnxruntime_test_providers_libs} ${onnxruntime_test_common_libs}
onnx_test_data_proto
DEPENDS ${all_dependencies}
TEST_ARGS ${test_all_args}
Expand Down Expand Up @@ -1045,45 +1055,47 @@ if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
list(APPEND onnx_test_libs onnxruntime_language_interop onnxruntime_pyop)
endif()

onnxruntime_add_executable(onnx_test_runner ${onnx_test_runner_src_dir}/main.cc)
if(MSVC)
target_compile_options(onnx_test_runner PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
"$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set_target_properties(onnx_test_runner PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
set_target_properties(onnx_test_runner PROPERTIES LINK_FLAGS "-s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1 -s PROXY_TO_PTHREAD=1 -s EXIT_RUNTIME=1")
else()
set_target_properties(onnx_test_runner PROPERTIES LINK_FLAGS "-s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1")
endif()
endif()
if (NOT IOS)
onnxruntime_add_executable(onnx_test_runner ${onnx_test_runner_src_dir}/main.cc)
if(MSVC)
target_compile_options(onnx_test_runner PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--compiler-options /utf-8>"
"$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/utf-8>")
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set_target_properties(onnx_test_runner PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
set_target_properties(onnx_test_runner PROPERTIES LINK_FLAGS "-s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1 -s PROXY_TO_PTHREAD=1 -s EXIT_RUNTIME=1")
else()
set_target_properties(onnx_test_runner PROPERTIES LINK_FLAGS "-s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1")
endif()
endif()

target_link_libraries(onnx_test_runner PRIVATE onnx_test_runner_common ${GETOPT_LIB_WIDE} ${onnx_test_libs} nlohmann_json::nlohmann_json)
target_include_directories(onnx_test_runner PRIVATE ${ONNXRUNTIME_ROOT})
if (onnxruntime_USE_ROCM)
target_include_directories(onnx_test_runner PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
endif()
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
target_link_libraries(onnx_test_runner PRIVATE Python::Python)
endif()
set_target_properties(onnx_test_runner PROPERTIES FOLDER "ONNXRuntimeTest")
target_link_libraries(onnx_test_runner PRIVATE onnx_test_runner_common ${GETOPT_LIB_WIDE} ${onnx_test_libs} nlohmann_json::nlohmann_json)
target_include_directories(onnx_test_runner PRIVATE ${ONNXRUNTIME_ROOT})
if (onnxruntime_USE_ROCM)
target_include_directories(onnx_test_runner PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
endif()
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
target_link_libraries(onnx_test_runner PRIVATE Python::Python)
endif()
set_target_properties(onnx_test_runner PROPERTIES FOLDER "ONNXRuntimeTest")

if (onnxruntime_USE_TVM)
if (WIN32)
target_link_options(onnx_test_runner PRIVATE "/STACK:4000000")
endif()
endif()
if (onnxruntime_USE_TVM)
if (WIN32)
target_link_options(onnx_test_runner PRIVATE "/STACK:4000000")
endif()
endif()

install(TARGETS onnx_test_runner
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS onnx_test_runner
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
if(onnxruntime_BUILD_BENCHMARKS)
Expand Down
Loading
Loading