mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-27 20:02:15 +00:00
Improve build throughput and enable using the Visual Studio 2019 cmake generator (#1411)
This commit is contained in:
parent
5ee0f185dc
commit
7a681fb964
3 changed files with 56 additions and 6 deletions
|
|
@ -1,4 +1,15 @@
|
|||
// Please don't manually edit this file. Generated from reduction_test_cases_generator.py
|
||||
// Optimizations are disabled in this file to improve build throughput
|
||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
||||
#pragma optimize ("", off)
|
||||
#elif defined(__GNUC__)
|
||||
#if defined(__clang__)
|
||||
#pragma clang optimize off
|
||||
#else
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("O0")
|
||||
#endif
|
||||
#endif
|
||||
ReductionTestCases testcases = {
|
||||
// input_data
|
||||
{
|
||||
|
|
@ -5355,3 +5366,12 @@ ReductionTestCases testcases = {
|
|||
1.000000f,
|
||||
})},
|
||||
}};
|
||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
||||
#pragma optimize ("", on)
|
||||
#elif defined(__GNUC__)
|
||||
#if defined(__clang__)
|
||||
#pragma clang optimize on
|
||||
#else
|
||||
#pragma GCC pop_options
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -63,6 +63,30 @@ def PrintResult(op, axes, keepdims, res):
|
|||
|
||||
print ("})},")
|
||||
|
||||
def PrintDisableOptimizations():
|
||||
print ("// Optimizations are disabled in this file to improve build throughput")
|
||||
print ("#if defined(_MSC_VER) || defined(__INTEL_COMPILER)")
|
||||
print ("#pragma optimize (\"\", off)")
|
||||
print ("#elif defined(__GNUC__)")
|
||||
print ("#if defined(__clang__)")
|
||||
print ("\t#pragma clang optimize off")
|
||||
print ("#else")
|
||||
print ("\t#pragma GCC push_options")
|
||||
print ("\t#pragma GCC optimize (\"O0\")")
|
||||
print ("#endif")
|
||||
print ("#endif")
|
||||
|
||||
def PrintReenableOptimizations():
|
||||
print ("#if defined(_MSC_VER) || defined(__INTEL_COMPILER)")
|
||||
print ("t#pragma optimize (\"\", on)")
|
||||
print ("#elif defined(__GNUC__)")
|
||||
print ("#if defined(__clang__)")
|
||||
print ("\t#pragma clang optimize on")
|
||||
print ("#else")
|
||||
print ("\t#pragma GCC pop_options")
|
||||
print ("#endif")
|
||||
print ("#endif")
|
||||
|
||||
if __name__ == "__main__":
|
||||
from itertools import product
|
||||
input_shape = [2,3,2,2,3]
|
||||
|
|
@ -73,6 +97,7 @@ if __name__ == "__main__":
|
|||
ops = ["ReduceL1", "ReduceL2", "ReduceLogSum", "ReduceLogSumExp", "ReduceMax", "ReduceMean",
|
||||
"ReduceMin", "ReduceProd", "ReduceSum", "ReduceSumSquare", "ArgMax", "ArgMin"]
|
||||
print ("// Please don't manually edit this file. Generated from reduction_test_cases_generator.py")
|
||||
PrintDisableOptimizations()
|
||||
print ("ReductionTestCases testcases = {")
|
||||
print ("// input_data")
|
||||
print ("{")
|
||||
|
|
@ -101,3 +126,4 @@ if __name__ == "__main__":
|
|||
|
||||
print ("}")
|
||||
print ("};")
|
||||
PrintReenableOptimizations()
|
||||
|
|
|
|||
|
|
@ -146,6 +146,8 @@ Use the individual flags to only run the specified stages.
|
|||
parser.add_argument("--skip_onnx_tests", action='store_true', help="Explicitly disable all onnx related tests")
|
||||
parser.add_argument("--enable_msvc_static_runtime", action='store_true', help="Enable static linking of MSVC runtimes.")
|
||||
parser.add_argument("--enable_language_interop_ops", action='store_true', help="Enable operator implemented in language other than cpp")
|
||||
parser.add_argument("--cmake_generator", choices=['Visual Studio 15 2017', 'Visual Studio 16 2019'],
|
||||
default='Visual Studio 15 2017', help="Specify the generator that CMake invokes. This is only supported on Windows")
|
||||
return parser.parse_args()
|
||||
|
||||
def resolve_executable_path(command_or_path):
|
||||
|
|
@ -488,6 +490,8 @@ def setup_cuda_vars(args):
|
|||
"Current version is {}. CUDA 9.2 requires version 14.11.*".format(vc_ver_str),
|
||||
"If necessary manually install the 14.11 toolset using the Visual Studio 2017 updater.",
|
||||
"See 'Windows CUDA Build' in build.md in the root directory of this repository.")
|
||||
|
||||
# TODO: check if cuda_version >=10.1, when cuda is enabled and VS version >=2019
|
||||
|
||||
return cuda_home, cudnn_home
|
||||
|
||||
|
|
@ -705,7 +709,7 @@ def build_python_wheel(source_dir, build_dir, configs, use_cuda, use_ngraph, use
|
|||
args.append('--use_openvino')
|
||||
run_subprocess(args, cwd=cwd)
|
||||
|
||||
def build_protoc_for_windows_host(cmake_path, source_dir, build_dir):
|
||||
def build_protoc_for_windows_host(cmake_path, source_dir, build_dir, cmake_generator):
|
||||
if not is_windows():
|
||||
raise BuildError('Currently only support building protoc for Windows host while cross-compiling for ARM/ARM64 arch')
|
||||
|
||||
|
|
@ -718,7 +722,7 @@ def build_protoc_for_windows_host(cmake_path, source_dir, build_dir):
|
|||
'-T',
|
||||
'host=x64',
|
||||
'-G',
|
||||
'Visual Studio 15 2017',
|
||||
cmake_generator,
|
||||
'-Dprotobuf_BUILD_TESTS=OFF',
|
||||
'-Dprotobuf_WITH_ZLIB_DEFAULT=OFF',
|
||||
'-Dprotobuf_BUILD_SHARED_LIBS=OFF']
|
||||
|
|
@ -802,16 +806,16 @@ def main():
|
|||
cmake_extra_args = []
|
||||
if(is_windows()):
|
||||
if (args.x86):
|
||||
cmake_extra_args = ['-A','Win32','-T','host=x64','-G', 'Visual Studio 15 2017']
|
||||
cmake_extra_args = ['-A','Win32','-T','host=x64','-G', args.cmake_generator]
|
||||
elif (args.arm or args.arm64):
|
||||
# Cross-compiling for ARM(64) architecture
|
||||
# First build protoc for host to use during cross-compilation
|
||||
build_protoc_for_windows_host(cmake_path, source_dir, build_dir)
|
||||
build_protoc_for_windows_host(cmake_path, source_dir, build_dir, args.cmake_generator)
|
||||
if args.arm:
|
||||
cmake_extra_args = ['-A', 'ARM']
|
||||
else:
|
||||
cmake_extra_args = ['-A', 'ARM64']
|
||||
cmake_extra_args += ['-G', 'Visual Studio 15 2017']
|
||||
cmake_extra_args += ['-G', args.cmake_generator]
|
||||
# Cannot test on host build machine for cross-compiled builds (Override any user-defined behaviour for test if any)
|
||||
if args.test:
|
||||
log.info("Cannot test on host build machine for cross-compiled ARM(64) builds. Will skip test running after build.")
|
||||
|
|
@ -823,7 +827,7 @@ def main():
|
|||
if (args.cuda_version):
|
||||
toolset += ',cuda=' + args.cuda_version
|
||||
|
||||
cmake_extra_args = ['-A','x64','-T', toolset, '-G', 'Visual Studio 15 2017']
|
||||
cmake_extra_args = ['-A','x64','-T', toolset, '-G', args.cmake_generator]
|
||||
if is_ubuntu_1604():
|
||||
if (args.arm or args.arm64):
|
||||
raise BuildError("Only Windows ARM(64) cross-compiled builds supported currently through this script")
|
||||
|
|
|
|||
Loading…
Reference in a new issue