From a475f2824df2fde34e9a204dac2f9e409d73c7d1 Mon Sep 17 00:00:00 2001 From: Sheil Kumar Date: Fri, 24 Apr 2020 20:20:04 -0700 Subject: [PATCH] Create the Nuget WindowsAI Pipeline (#3684) * add windowsai.yml for new Microsoft.AI.MachineLearning nuget * temporarily add windowsai.yml to gpu.yml * pass in build arch * remove install onnx task * no dml for arm or arm64 * refactor nuget pipeline defs * update package creation * pass in build and sources path * missing hyphens * copy license file * fix parameter variable * disable arm builds for now * remove commented script block * download pipeline atifcat name update * set working dir * Add bundling nuget script * path combine * null path * combine needs parentheses * binplace microsoft.* dlls in new nuget package * update artifact name * move merged nuget to artifacts directory * move to merged subfolder in artifacts staging dir * forward slash to back * enable arm * vcvarsall needs x64 vars setup * Run Tests * fix tests * move global variables * update yml to not have global variable in template * removed parameters * fixes * Add build arch as an env variable * ne not neq * %Var% for batch script * dont pass argument for x64 * disable arm tests * skip csharp/cxx tests for microsoft nuget package * remove test-win as it tests only c# cxx and capi * test build for store apps * dont build for store * tools/nuget/generate_nuspec_for_native_nuget.py * remove args. * add new props and targets for microsoft.ai * make windowsai props/targets static * add dependency * dont ship dot net props * Remove c# fom windowsai nuget * copy license file * native packages must have win10 as the platform, not win * cuda header in wrong if branch * no dml for arm builds * only build dml for x64/ x86 * User/sheilk/props update (#3616) * prelim store work * props * Fix desktop nuget props/targets * clean up targets and make store apps work Co-authored-by: Sheil Kumar * update windowsai.yml with latest * remove extra dloadhelpers * Add abi headers to abi dir, and reference native includes * update windowsai.yml * minor update * remove parameters * add doesrp param * hard code esrp to true * add directml for x86/x64 * revert gpu yml changes * add store builds * add store builds * add checks again in old way * dup job names for store and desktop builds * move all of the runtime binaries to win10 folder * only set safeseh on x86 * disable the store builds for now... missing msvcprt.lib * copy paste deletion... * switch back to win- (#3646) Co-authored-by: Sheil Kumar * use stahlworks * & not supported in ado * add cuda to cpu nuget(???) and EnableDelayedExpansion to enable x86 dml package * revert nocontribops * add underscore... * extra win/win10 change * merged nuget... still not being bundled... * files in merged directory * missing parens causing dml to be included in cpu package * more diagnostic info * switch dir to get-childitem * wait for compression to complete * add winml_adapter to mkml and gpu packages * enable_wcos * add mklml binaries * props and targets missing from mklml Co-authored-by: Sheil Kumar --- cmake/CMakeLists.txt | 13 + cmake/onnxruntime_providers.cmake | 9 +- cmake/winml.cmake | 6 +- csharp/OnnxRuntime.CSharp.proj | 20 +- .../Microsoft.AI.MachineLearning.props | 11 + .../Microsoft.AI.MachineLearning.targets | 34 +++ .../Microsoft.ML.OnnxRuntime.csproj | 72 ------ tools/ci_build/build.py | 4 + .../nuget/templates/bundle_dlls.yml | 3 - .../nuget/templates/cpu-mklml.yml | 2 +- .../azure-pipelines/nuget/templates/gpu.yml | 41 ++- .../nuget/templates/windowsai.yml | 236 ++++++++++++++++++ .../templates/enable-telemetry.yml | 13 + .../templates/windowsai-nuget-build.yml | 185 ++++++++++++++ .../nuget/generate_nuspec_for_native_nuget.py | 182 +++++++------- 15 files changed, 646 insertions(+), 185 deletions(-) create mode 100644 csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.props create mode 100644 csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.targets create mode 100644 tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml create mode 100644 tools/ci_build/github/azure-pipelines/templates/enable-telemetry.yml create mode 100644 tools/ci_build/github/azure-pipelines/templates/windowsai-nuget-build.yml diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 019c2e674c..947bb7a73d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -946,3 +946,16 @@ if (onnxruntime_BUILD_CSHARP) # set_property(GLOBAL PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "netstandard2.0") include(onnxruntime_csharp.cmake) endif() + +if (onnxruntime_BUILD_FOR_WINDOWS_STORE) + set_target_properties(onnxruntime PROPERTIES VS_GLOBAL_AppContainerApplication true) + set_target_properties(winml_dll PROPERTIES VS_GLOBAL_AppContainerApplication true) + + target_link_options(onnxruntime PRIVATE /DYNAMICBASE /NXCOMPAT /APPCONTAINER) + target_link_options(winml_dll PRIVATE /DYNAMICBASE /NXCOMPAT /APPCONTAINER) + + if (onnxruntime_target_platform STREQUAL "x86") + target_link_options(onnxruntime PRIVATE /SAFESEH) + target_link_options(winml_dll PRIVATE /SAFESEH) + endif() +endif() diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index 7afdb69270..0b202013a9 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -430,7 +430,14 @@ if (onnxruntime_USE_DML) endfunction() target_add_dml(onnxruntime_providers_dml) - target_link_libraries(onnxruntime_providers_dml PRIVATE d3d12.lib dxgi.lib delayimp.lib) + target_link_libraries(onnxruntime_providers_dml PRIVATE d3d12.lib dxgi.lib) + + if (onnxruntime_BUILD_FOR_WINDOWS_STORE) + target_link_libraries(onnxruntime_providers_dml PRIVATE dloadhelper.lib) + else() + target_link_libraries(onnxruntime_providers_dml PRIVATE delayimp.lib) + endif() + set(onnxruntime_DELAYLOAD_FLAGS "${onnxruntime_DELAYLOAD_FLAGS} /DELAYLOAD:DirectML.dll /DELAYLOAD:d3d12.dll /DELAYLOAD:dxgi.dll") # The DML EP requires C++17 diff --git a/cmake/winml.cmake b/cmake/winml.cmake index 2f6af2248f..47e7ea6242 100644 --- a/cmake/winml.cmake +++ b/cmake/winml.cmake @@ -615,7 +615,11 @@ target_link_libraries(winml_dll PRIVATE winml_lib_api) target_link_libraries(winml_dll PRIVATE winml_lib_image) target_link_libraries(winml_dll PRIVATE winml_lib_ort) target_link_libraries(winml_dll PRIVATE winml_lib_telemetry) -target_link_libraries(winml_dll PRIVATE delayimp.lib) +if (onnxruntime_BUILD_FOR_WINDOWS_STORE) + target_link_libraries(winml_dll PRIVATE dloadhelper.lib) +else() + target_link_libraries(winml_dll PRIVATE delayimp.lib) +endif() # Any project that links in debug_alloc.obj needs this lib. # unresolved external symbol __imp_SymSetOptions diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index 3f583996e4..01ed2eb326 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -72,7 +72,7 @@ CMake creates a target to this project - + @@ -119,8 +119,24 @@ CMake creates a target to this project - + + + + + + + + + + + + + + + + + diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.props b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.props new file mode 100644 index 0000000000..9cba31ea5c --- /dev/null +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.props @@ -0,0 +1,11 @@ + + + + + $(MSBuildThisFileDirectory)../../build/native/include/;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)../../build/native/include/;%(AdditionalIncludeDirectories) + + + diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.targets b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.targets new file mode 100644 index 0000000000..a88b5c23fd --- /dev/null +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.AI.MachineLearning.targets @@ -0,0 +1,34 @@ + + + + x86 + $(Platform) + + + + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\Microsoft.AI.MachineLearning.dll + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\onnxruntime.dll + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\directml.dll + + + + + $(WindowsAIBinary) + + + + + $(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary) + + + $(WindowsAIBinary);$(OnnxRuntimeBinary) + + + + + Binplacing WindowsAI binaries: {0} and {1}. + + + + + diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj index bceeb06ba1..1cef1ee54e 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj @@ -93,78 +93,6 @@ CopyToOutputDirectory="Always" Visible="false" /> - - - - - - - - wheel_filename_file + set /p WHEEL_FILENAME=') -def generate_dependencies(list, version): - list.append('') +def generate_dependencies(list, package_name, version): + if (package_name != 'Microsoft.AI.MachineLearning'): + list.append('') + # Support .Net Core + list.append('') + list.append('') + list.append('') + # Support .Net Standard + list.append('') + list.append('') + list.append('') + # Support .Net Framework + list.append('') + list.append('') + list.append('') - # Support .Net Core - list.append('') - list.append('') - list.append('') - - # Support .Net Standard - list.append('') - list.append('') - list.append('') - - # Support .Net Framework - list.append('') - list.append('') - list.append('') - - list.append('') + list.append('') def get_env_var(key): return os.environ.get(key) @@ -106,7 +104,7 @@ def generate_metadata(list, args): generate_license(metadata_list) generate_project_url(metadata_list, 'https://github.com/Microsoft/onnxruntime') generate_repo_url(metadata_list, 'https://github.com/Microsoft/onnxruntime.git', args.commit_id) - generate_dependencies(metadata_list, args.package_version) + generate_dependencies(metadata_list, args.package_name, args.package_version) generate_release_notes(metadata_list) metadata_list.append('') @@ -115,90 +113,106 @@ def generate_metadata(list, args): def generate_files(list, args): files_list = [''] + is_cpu_package = args.package_name == 'Microsoft.ML.OnnxRuntime' + is_mklml_package = args.package_name == 'Microsoft.ML.OnnxRuntime.MKLML' + is_cuda_gpu_package = args.package_name == 'Microsoft.ML.OnnxRuntime.Gpu' + is_dml_package = args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' + is_windowsai_package = args.package_name == 'Microsoft.AI.MachineLearning' + + includes_cuda = is_cuda_gpu_package or is_cpu_package # Why does the CPU package ship the cuda provider headers? + includes_winml = is_windowsai_package + includes_directml = (is_dml_package or is_windowsai_package) and (args.target_architecture == 'x64' or args.target_architecture == 'x86') + # Process headers files_list.append('') files_list.append('') - if (args.package_name != 'Microsoft.ML.OnnxRuntime.DirectML'): + if includes_cuda: files_list.append('') - else: # it is a DirectML package + + if includes_directml: files_list.append('') - # Process DirectML dll - if os.path.exists(os.path.join(args.native_build_path, 'DirectML.dll')): - files_list.append('') - files_list.append('') - files_list.append('') - + + if includes_winml: + # Add microsoft.ai.machinelearning headers + files_list.append('') + files_list.append('') + files_list.append('') + # Process microsoft.ai.machinelearning.winmd + files_list.append('') + + # Process runtimes # Process onnxruntime import lib, dll, and pdb files_list.append('') files_list.append('') files_list.append('') + + if includes_directml: + files_list.append('') + files_list.append('') + files_list.append('') + + if includes_winml: + # Process microsoft.ai.machinelearning import lib, dll, and pdb + files_list.append('') + files_list.append('') + files_list.append('') + + if is_cpu_package or is_cuda_gpu_package or is_dml_package or is_mklml_package: + # Process dnll.dll + if os.path.exists(os.path.join(args.native_build_path, 'dnnl.dll')): + files_list.append('') + + # Process mklml.dll + if os.path.exists(os.path.join(args.native_build_path, 'mklml.dll')): + files_list.append('') - if (is_windows()): - # Process Microsoft.AI.MachineLearning lib, dll, and pdb - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime'): - files_list.append('') - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime'): - files_list.append('') - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime'): - files_list.append('') - # Process microsoft.ai.machinelearning.winmd - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime'): - files_list.append('') - # Process microsoft.ai.machinelearning headers - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime'): - files_list.append('') - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime'): - files_list.append('') - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime'): - files_list.append('') - - if (args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' or args.package_name == 'Microsoft.ML.OnnxRuntime') and os.path.exists(os.path.join(args.ort_build_path, args.build_config, 'dualapipartitionattribute.h')): - files_list.append('') - - # Process dnll.dll - if os.path.exists(os.path.join(args.native_build_path, 'dnnl.dll')): - files_list.append('') + # Process libiomp5md.dll + if os.path.exists(os.path.join(args.native_build_path, 'libiomp5md.dll')): + files_list.append('') - # Process mklml.dll - if os.path.exists(os.path.join(args.native_build_path, 'mklml.dll')): - files_list.append('') + # Process tvm.dll + if os.path.exists(os.path.join(args.native_build_path, 'tvm.dll')): + files_list.append('') - # Process libiomp5md.dll - if os.path.exists(os.path.join(args.native_build_path, 'libiomp5md.dll')): - files_list.append('') - - # Process tvm.dll - if os.path.exists(os.path.join(args.native_build_path, 'tvm.dll')): - files_list.append('') + # Some tools to be packaged in nightly build only, should not be released + # These are copied to the runtimes folder for convenience of loading with the dlls + if args.is_release_build.lower() != 'true' and args.target_architecture == 'x64' and os.path.exists(os.path.join(args.native_build_path, 'onnxruntime_perf_test.exe')): + files_list.append('') + if args.is_release_build.lower() != 'true' and args.target_architecture == 'x64' and os.path.exists(os.path.join(args.native_build_path, 'onnx_test_runner.exe')): + files_list.append('') + + # Process props and targets files + if is_windowsai_package: + # Process props file + windowsai_props = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', 'Microsoft.AI.MachineLearning.props') + files_list.append('') + # Process targets files + windowsai_targets = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', 'Microsoft.AI.MachineLearning.targets') + files_list.append('') + + if is_cpu_package or is_cuda_gpu_package or is_dml_package or is_mklml_package: + # Process props file + source_props = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', 'props.xml') + target_props = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', args.package_name + '.props') + os.system('copy ' + source_props + ' ' + target_props) + files_list.append('') + files_list.append('') + + # Process targets file + source_targets = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', 'targets.xml') + target_targets = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', args.package_name + '.targets') + os.system('copy ' + source_targets + ' ' + target_targets) + files_list.append('') + files_list.append('') + + # Process License, ThirdPartyNotices, Privacy, README files_list.append('') files_list.append('') files_list.append('') files_list.append('') - - # Process props file - source_props = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', 'props.xml') - target_props = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', args.package_name + '.props') - os.system('copy ' + source_props + ' ' + target_props) - files_list.append('') - files_list.append('') - - # Process targets file - source_targets = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', 'targets.xml') - target_targets = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime', args.package_name + '.targets') - os.system('copy ' + source_targets + ' ' + target_targets) - files_list.append('') - files_list.append('') - - # Some tools to be packaged in nightly build only, should not be released - # These are copied to the runtimes folder for convenience of loading with the dlls - if args.is_release_build.lower() != 'true' and args.target_architecture == 'x64' and os.path.exists(os.path.join(args.native_build_path, 'onnxruntime_perf_test.exe')): - files_list.append('') - - if args.is_release_build.lower() != 'true' and args.target_architecture == 'x64' and os.path.exists(os.path.join(args.native_build_path, 'onnx_test_runner.exe')): - files_list.append('') files_list.append('')