diff --git a/.config/tsaoptions.json b/.config/tsaoptions.json
new file mode 100644
index 0000000000000..b2b3180feffc4
--- /dev/null
+++ b/.config/tsaoptions.json
@@ -0,0 +1,8 @@
+{
+ "notificationAliases": ["chasun@microsoft.com"],
+ "areaPath": "Vienna\\ONNX Runtime\\Shared Core",
+ "codebaseName": "onnxruntime_master",
+ "instanceUrl": "https://msdata.visualstudio.com/",
+ "projectName": "Vienna",
+ "ignoreBranchName": true
+}
\ No newline at end of file
diff --git a/.github/workflows/publish-c-apidocs.yml b/.github/workflows/publish-c-apidocs.yml
new file mode 100644
index 0000000000000..12e3e9760a027
--- /dev/null
+++ b/.github/workflows/publish-c-apidocs.yml
@@ -0,0 +1,43 @@
+name: Update C/C++ API Docs
+on:
+ workflow_dispatch
+
+jobs:
+ publish:
+ name: Generate C/C++ API docs
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install doxygen and dependencies
+ run: |
+ sudo apt update
+ sudo apt-get install libclang-9-dev
+ sudo apt-get install libclang-cpp9
+ wget https://www.doxygen.nl/files/doxygen-1.9.2.linux.bin.tar.gz
+ tar xvzf doxygen-1.9.2.linux.bin.tar.gz
+ - name: Set commit ID
+ id: vars
+ run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+ - name: Run doxygen
+ run: |
+ mkdir -p build/doxygen
+ cd docs/c_cxx
+ ../../doxygen-1.9.2/bin/doxygen
+ - uses: actions/checkout@v2
+ with:
+ ref: gh-pages
+ clean: false
+ - name: Move API docs into target area
+ run: |
+ rm -rf docs/api/c
+ mv build/doxygen/html docs/api/c
+ - name: Create Pull Request
+ uses: peter-evans/create-pull-request@v3
+ with:
+ branch: gh-pages-pr
+ base: gh-pages
+ title: '[Automated]: Update C/C++ API docs'
+ commit-message: 'Update C/C++ API docs to commit ${{ steps.vars.outputs.sha_short }}'
+ add-paths: docs/api/c
+
+
\ No newline at end of file
diff --git a/.github/workflows/publish-python-apidocs.yml b/.github/workflows/publish-python-apidocs.yml
new file mode 100644
index 0000000000000..ba7c4eaf58b9e
--- /dev/null
+++ b/.github/workflows/publish-python-apidocs.yml
@@ -0,0 +1,48 @@
+name: Update Python API Docs
+on:
+ workflow_dispatch
+
+jobs:
+ publish:
+ name: Generate Python API docs
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install tools
+ run: |
+ sudo apt update
+ sudo apt-get install pip
+ sudo apt-get install graphviz
+ - name: Install dependencies
+ run: |
+ cd docs/python
+ pip install -r requirements.txt
+ pip install flatbuffers protobuf==3.19.1
+ pip install -i https://test.pypi.org/simple/ ort-nightly
+ pip list
+ - name: Generate Python docs with Sphinx
+ run: |
+ cd tools/doc
+ ./builddoc.sh /usr/bin ../.. ../../build
+ - name: Set vars
+ id: vars
+ run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
+ - uses: actions/checkout@v2
+ with:
+ ref: gh-pages
+ clean: false
+ - name: Move API docs into target area
+ run: |
+ ls docs/api
+ rm -rf docs/api/python
+ mv build/docs/inference/html docs/api/python
+ - name: Create Pull Request
+ uses: peter-evans/create-pull-request@v3
+ with:
+ branch: gh-pages-pr-python-docs
+ base: gh-pages
+ title: '[Automated]: Update Python API docs'
+ commit-message: 'Update Python API docs to commit ${{ steps.vars.outputs.sha_short }}'
+ add-paths: docs/api/python
+
+
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index d49627f67ff6f..d27dedbc2b7ce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@ gen
*~
.vs
.DS_Store
+*.DS_Store
TestResults/
.idea/
onnxruntime.egg-info
@@ -48,10 +49,6 @@ java/gradle
java/.gradle
java/hs_*.log
onnxruntime/python/version_info.py
-/tools/perf_util/target/classes/com/msft/send_perf_metrics
-/tools/perf_util/send_perf_metrics.iml
-/tools/perf_util/target/classes
-/tools/perf_util/src/main/resources
/orttraining/orttraining/eager/ort_aten.g.cpp
/orttraining/orttraining/eager/ort_customops.g.cpp
/csharp/**/packages
diff --git a/.gitmodules b/.gitmodules
index 4e09a75462522..770156842e28c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -9,16 +9,13 @@
url = https://github.com/google/benchmark.git
[submodule "cmake/external/onnx"]
path = cmake/external/onnx
- url = https://github.com/onnx/onnx
-[submodule "cmake/external/tvm"]
- path = cmake/external/tvm
- url = https://github.com/microsoft/onnxruntime-tvm.git
+ url = https://github.com/onnx/onnx.git
[submodule "cmake/external/date"]
path = cmake/external/date
url = https://github.com/HowardHinnant/date.git
[submodule "cmake/external/nsync"]
path = cmake/external/nsync
- url = https://github.com/google/nsync
+ url = https://github.com/google/nsync.git
[submodule "cmake/external/re2"]
path = cmake/external/re2
url = https://github.com/google/re2.git
@@ -39,10 +36,10 @@
url = https://github.com/NVlabs/cub.git
[submodule "cmake/external/wil"]
path = cmake/external/wil
- url = https://github.com/microsoft/wil
+ url = https://github.com/microsoft/wil.git
[submodule "cmake/external/json"]
path = cmake/external/json
- url = https://github.com/nlohmann/json
+ url = https://github.com/nlohmann/json.git
[submodule "server/external/spdlog"]
path = server/external/spdlog
url = https://github.com/gabime/spdlog.git
@@ -59,23 +56,19 @@
[submodule "cmake/external/mp11"]
path = cmake/external/mp11
url = https://github.com/boostorg/mp11.git
-[submodule "cmake/external/coremltools"]
- path = cmake/external/coremltools
- url = https://github.com/apple/coremltools.git
[submodule "cmake/external/dlpack"]
path = cmake/external/dlpack
url = https://github.com/dmlc/dlpack.git
[submodule "cmake/external/emsdk"]
path = cmake/external/emsdk
url = https://github.com/emscripten-core/emsdk.git
- branch = 2.0.26
+ branch = 3.1.3
[submodule "cmake/external/onnxruntime-extensions"]
path = cmake/external/onnxruntime-extensions
url = https://github.com/microsoft/onnxruntime-extensions.git
[submodule "cmake/external/pytorch_cpuinfo"]
path = cmake/external/pytorch_cpuinfo
url = https://github.com/pytorch/cpuinfo.git
-
[submodule "cmake/external/onnx-tensorrt"]
path = cmake/external/onnx-tensorrt
url = https://github.com/onnx/onnx-tensorrt.git
diff --git a/.pipelines/OneBranch.Nuget-WindowsAI-Pipeline.Official.yml b/.pipelines/OneBranch.Nuget-WindowsAI-Pipeline.Official.yml
new file mode 100644
index 0000000000000..5a6500161e9c4
--- /dev/null
+++ b/.pipelines/OneBranch.Nuget-WindowsAI-Pipeline.Official.yml
@@ -0,0 +1,348 @@
+parameters:
+- name: UploadSymbols
+ displayName: Upload Symbols to Microsoft symbol server?
+ type: boolean
+ default: false
+
+trigger: none
+
+variables:
+ CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)]
+ DEBIAN_FRONTEND: noninteractive
+
+resources:
+ repositories:
+ - repository: templates
+ type: git
+ name: OneBranch.Pipelines/GovernedTemplates
+ ref: refs/heads/main
+
+extends:
+ template: v2/OneBranch.Official.CrossPlat.yml@templates
+ parameters:
+ git:
+ submodules: false
+ globalSdl: # https://aka.ms/obpipelines/sdl
+ # tsa:
+ # enabled: true
+ # credscan:
+ # suppressionsFile: $(Build.SourcesDirectory)\.config\CredScanSuppressions.json
+ prefast:
+ enabled: false
+ cg:
+ failOnAlert: false
+ policheck:
+ break: true # always break the build on policheck issues. You can disable it by setting to 'false'
+ exclusionsFile: '$(Build.SourcesDirectory)\tools\ci_build\policheck_exclusions.xml'
+ # suppression:
+ # suppressionFile: $(Build.SourcesDirectory)\.gdn\global.gdnsuppress
+
+ stages:
+ - stage: Windows_Build
+ jobs:
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: x64
+
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: x86
+ PythonPackageName: pythonx86
+
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: arm
+
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: arm64
+
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: x64
+ Runtime: static
+
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: x86
+ PythonPackageName: pythonx86
+ Runtime: static
+
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: arm
+ Runtime: static
+
+ - template: .pipelines/windowsai-steps.yml@self
+ parameters:
+ BuildArch: arm64
+ Runtime: static
+
+
+ - job: NuGet_Packaging
+ pool:
+ type: windows
+ variables:
+ ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
+ ob_sdl_binskim_break: false
+ ob_symbolsPublishing_enabled: ${{ parameters.UploadSymbols }}
+ ob_symbolsPublishing_symbolsFolder: $(Build.SourcesDirectory)/unzipped
+ dependsOn:
+ - Windows_Packaging_x64_dynamic
+ - Windows_Packaging_x86_dynamic
+ - Windows_Packaging_arm_dynamic
+ - Windows_Packaging_arm64_dynamic
+ - Windows_Packaging_x64_static
+ - Windows_Packaging_x86_static
+ - Windows_Packaging_arm_static
+ - Windows_Packaging_arm64_static
+ condition: succeeded()
+ steps:
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML x64'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_x64_dynamic'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-x64'
+
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML x86'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_x86_dynamic'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-x86'
+
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML arm64'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_arm64_dynamic'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-arm64'
+
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML arm'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_arm_dynamic'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-arm'
+
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML x64 StaticRuntime'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_x64_static'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-x64-static-runtime'
+
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML x86 StaticRuntime'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_x86_static'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-x86-static-runtime'
+
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML arm64 StaticRuntime'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_arm64_static'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-arm64-static-runtime'
+
+ - task: DownloadPipelineArtifact@0
+ displayName: 'Download Pipeline Artifact - NuGet DirectML arm StaticRuntime'
+ inputs:
+ artifactName: 'drop_Windows_Build_Windows_Packaging_arm_static'
+ targetPath: '$(Build.BinariesDirectory)/nuget-artifact-arm-static-runtime'
+
+ - task: PowerShell@2
+ displayName: 'Bundle NuGet and other binaries'
+ inputs:
+ targetType: 'inline'
+ script: |
+ Add-Type -AssemblyName "System.IO.Compression.FileSystem"
+
+ $nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $x64_nuget_package_name = $nupkgs[0].Name
+ $x64_nuget_package = $nupkgs[0].FullName
+ $x64_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $x64_nupkg_unzipped_directory = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x64_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($x64_nuget_package, $x64_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-x64-static-runtime -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $x64_static_runtime_nuget_package = $nupkgs[0].FullName
+ $x64_static_runtime_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $x64_static_runtime_nupkg_unzipped_directory = [System.IO.Path]::Combine($x64_static_runtime_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x64_static_runtime_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($x64_static_runtime_nuget_package, $x64_static_runtime_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-x86 -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $x86_nuget_package = $nupkgs[0].FullName
+ $x86_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $x86_nupkg_unzipped_directory = [System.IO.Path]::Combine($x86_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x86_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($x86_nuget_package, $x86_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-x86-static-runtime -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $x86_static_runtime_nuget_package = $nupkgs[0].FullName
+ $x86_static_runtime_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $x86_static_runtime_nupkg_unzipped_directory = [System.IO.Path]::Combine($x86_static_runtime_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x86_static_runtime_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($x86_static_runtime_nuget_package, $x86_static_runtime_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-arm64 -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $arm64_nuget_package = $nupkgs[0].FullName
+ $arm64_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $arm64_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm64_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($arm64_nuget_package, $arm64_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-arm64-static-runtime -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $arm64_static_runtime_nuget_package = $nupkgs[0].FullName
+ $arm64_static_runtime_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $arm64_static_runtime_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm64_static_runtime_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm64_static_runtime_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($arm64_static_runtime_nuget_package, $arm64_static_runtime_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-arm -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $arm_nuget_package = $nupkgs[0].FullName
+ $arm_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $arm_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($arm_nuget_package, $arm_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-arm-static-runtime -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse)
+ $arm_static_runtime_nuget_package = $nupkgs[0].FullName
+ $arm_static_runtime_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $arm_static_runtime_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm_static_runtime_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm_static_runtime_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($arm_static_runtime_nuget_package, $arm_static_runtime_nupkg_unzipped_directory)
+
+ $x64_static_runtime_path_old = [System.IO.Path]::Combine($x64_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-x64', '_native')
+ $x64_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x64', '_native', 'static')
+ $x86_runtime_path_old = [System.IO.Path]::Combine($x86_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native')
+ $x86_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native')
+ $x86_static_runtime_path_old = [System.IO.Path]::Combine($x86_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native')
+ $x86_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native', 'static')
+ $arm64_runtime_path_old = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
+ $arm64_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
+ $arm64_static_runtime_path_old = [System.IO.Path]::Combine($arm64_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
+ $arm64_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native', 'static')
+ $arm_runtime_path_old = [System.IO.Path]::Combine($arm_nupkg_unzipped_directory, 'runtimes', 'win-arm', '_native')
+ $arm_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm', '_native')
+ $arm_static_runtime_path_old = [System.IO.Path]::Combine($arm_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-arm', '_native')
+ $arm_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm', '_native', 'static')
+ $uap_build_path_old = [System.IO.Path]::Combine($x64_static_runtime_nupkg_unzipped_directory, 'build', 'native')
+ $uap_build_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'build', 'uap10.0')
+
+ New-Item -Path $x64_static_runtime_path_new -ItemType Directory
+ New-Item -Path $x86_runtime_path_new -ItemType Directory
+ New-Item -Path $x86_static_runtime_path_new -ItemType Directory
+ New-Item -Path $arm64_runtime_path_new -ItemType Directory
+ New-Item -Path $arm64_static_runtime_path_new -ItemType Directory
+ New-Item -Path $arm_runtime_path_new -ItemType Directory
+ New-Item -Path $arm_static_runtime_path_new -ItemType Directory
+
+ Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'onnxruntime.dll')) $x86_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'onnxruntime.lib')) $x86_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $x86_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $x86_runtime_path_new
+
+ Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'onnxruntime.dll')) $arm64_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'onnxruntime.lib')) $arm64_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $arm64_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $arm64_runtime_path_new
+
+ Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'onnxruntime.dll')) $arm_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'onnxruntime.lib')) $arm_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $arm_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $arm_runtime_path_new
+
+ Copy-Item ([System.IO.Path]::Combine($x64_static_runtime_path_old, 'onnxruntime.dll')) ([System.IO.Path]::Combine($x64_static_runtime_path_new, 'onnxruntime.dll'))
+ Copy-Item ([System.IO.Path]::Combine($x64_static_runtime_path_old, 'onnxruntime.lib')) ([System.IO.Path]::Combine($x64_static_runtime_path_new, 'onnxruntime.lib'))
+ Copy-Item ([System.IO.Path]::Combine($x64_static_runtime_path_old, 'microsoft.ai.machinelearning.dll')) ([System.IO.Path]::Combine($x64_static_runtime_path_new, 'microsoft.ai.machinelearning.dll'))
+ Copy-Item ([System.IO.Path]::Combine($x64_static_runtime_path_old, 'microsoft.ai.machinelearning.lib')) ([System.IO.Path]::Combine($x64_static_runtime_path_new, 'microsoft.ai.machinelearning.lib'))
+
+ Copy-Item ([System.IO.Path]::Combine($x86_static_runtime_path_old, 'onnxruntime.dll')) ([System.IO.Path]::Combine($x86_static_runtime_path_new, 'onnxruntime.dll'))
+ Copy-Item ([System.IO.Path]::Combine($x86_static_runtime_path_old, 'onnxruntime.lib')) ([System.IO.Path]::Combine($x86_static_runtime_path_new, 'onnxruntime.lib'))
+ Copy-Item ([System.IO.Path]::Combine($x86_static_runtime_path_old, 'microsoft.ai.machinelearning.dll')) ([System.IO.Path]::Combine($x86_static_runtime_path_new, 'microsoft.ai.machinelearning.dll'))
+ Copy-Item ([System.IO.Path]::Combine($x86_static_runtime_path_old, 'microsoft.ai.machinelearning.lib')) ([System.IO.Path]::Combine($x86_static_runtime_path_new, 'microsoft.ai.machinelearning.lib'))
+
+ Copy-Item ([System.IO.Path]::Combine($arm64_static_runtime_path_old, 'onnxruntime.dll')) ([System.IO.Path]::Combine($arm64_static_runtime_path_new, 'onnxruntime.dll'))
+ Copy-Item ([System.IO.Path]::Combine($arm64_static_runtime_path_old, 'onnxruntime.lib')) ([System.IO.Path]::Combine($arm64_static_runtime_path_new, 'onnxruntime.lib'))
+ Copy-Item ([System.IO.Path]::Combine($arm64_static_runtime_path_old, 'microsoft.ai.machinelearning.dll')) ([System.IO.Path]::Combine($arm64_static_runtime_path_new, 'microsoft.ai.machinelearning.dll'))
+ Copy-Item ([System.IO.Path]::Combine($arm64_static_runtime_path_old, 'microsoft.ai.machinelearning.lib')) ([System.IO.Path]::Combine($arm64_static_runtime_path_new, 'microsoft.ai.machinelearning.lib'))
+
+ Copy-Item ([System.IO.Path]::Combine($arm_static_runtime_path_old, 'onnxruntime.dll')) ([System.IO.Path]::Combine($arm_static_runtime_path_new, 'onnxruntime.dll'))
+ Copy-Item ([System.IO.Path]::Combine($arm_static_runtime_path_old, 'onnxruntime.lib')) ([System.IO.Path]::Combine($arm_static_runtime_path_new, 'onnxruntime.lib'))
+ Copy-Item ([System.IO.Path]::Combine($arm_static_runtime_path_old, 'microsoft.ai.machinelearning.dll')) ([System.IO.Path]::Combine($arm_static_runtime_path_new, 'microsoft.ai.machinelearning.dll'))
+ Copy-Item ([System.IO.Path]::Combine($arm_static_runtime_path_old, 'microsoft.ai.machinelearning.lib')) ([System.IO.Path]::Combine($arm_static_runtime_path_new, 'microsoft.ai.machinelearning.lib'))
+
+ Copy-Item -Recurse $uap_build_path_old $uap_build_path_new
+
+ $merged_nuget_path = [System.IO.Path]::Combine($Env:BUILD_ARTIFACTSTAGINGDIRECTORY, 'merged')
+ if (!(Test-Path $merged_nuget_path)) {
+ New-Item -Path $merged_nuget_path -ItemType Directory
+ }
+
+ $merged_nuget = [System.IO.Path]::Combine($merged_nuget_path, $x64_nuget_package_name)
+ Start-Process -FilePath "7z" -ArgumentList "-tzip a -r $merged_nuget ." -WorkingDirectory $x64_nupkg_unzipped_directory -NoNewWindow -Wait
+
+ workingDirectory: $(Build.BinariesDirectory)\nuget-artifact-x64
+
+ - task: PowerShell@2
+ displayName: 'Bundle Symbols NuGet'
+ inputs:
+ targetType: 'inline'
+ script: |
+ Add-Type -AssemblyName "System.IO.Compression.FileSystem"
+
+ $nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*.snupkg -Recurse)
+ $x64_nuget_package_name = $nupkgs[0].Name
+ $x64_nuget_package = $nupkgs[0].FullName
+ $x64_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $x64_nupkg_unzipped_directory = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory_root, 'symbols', [System.IO.Path]::GetFileNameWithoutExtension($x64_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($x64_nuget_package, $x64_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-x86 -Filter Microsoft.AI.MachineLearning*.snupkg -Recurse)
+ $x86_nuget_package = $nupkgs[0].FullName
+ $x86_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $x86_nupkg_unzipped_directory = [System.IO.Path]::Combine($x86_nupkg_unzipped_directory_root, 'symbols', [System.IO.Path]::GetFileNameWithoutExtension($x86_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($x86_nuget_package, $x86_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-arm64 -Filter Microsoft.AI.MachineLearning*.snupkg -Recurse)
+ $arm64_nuget_package = $nupkgs[0].FullName
+ $arm64_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $arm64_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory_root, 'symbols', [System.IO.Path]::GetFileNameWithoutExtension($arm64_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($arm64_nuget_package, $arm64_nupkg_unzipped_directory)
+
+ $nupkgs = (Get-ChildItem ..\nuget-artifact-arm -Filter Microsoft.AI.MachineLearning*.snupkg -Recurse)
+ $arm_nuget_package = $nupkgs[0].FullName
+ $arm_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName
+ $arm_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm_nupkg_unzipped_directory_root, 'symbols', [System.IO.Path]::GetFileNameWithoutExtension($arm_nuget_package))
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($arm_nuget_package, $arm_nupkg_unzipped_directory)
+
+ $x86_runtime_path_old = [System.IO.Path]::Combine($x86_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native')
+ $x86_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native')
+ $arm64_runtime_path_old = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
+ $arm64_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
+ $arm_runtime_path_old = [System.IO.Path]::Combine($arm_nupkg_unzipped_directory, 'runtimes', 'win-arm', '_native')
+ $arm_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm', '_native')
+
+ New-Item -Path $x86_runtime_path_new -ItemType Directory
+ New-Item -Path $arm64_runtime_path_new -ItemType Directory
+ New-Item -Path $arm_runtime_path_new -ItemType Directory
+
+ Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'onnxruntime.pdb')) $x86_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'microsoft.ai.machinelearning.pdb')) $x86_runtime_path_new
+
+ Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'onnxruntime.pdb')) $arm64_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'microsoft.ai.machinelearning.pdb')) $arm64_runtime_path_new
+
+ Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'onnxruntime.pdb')) $arm_runtime_path_new
+ Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'microsoft.ai.machinelearning.pdb')) $arm_runtime_path_new
+
+ $merged_nuget_path = [System.IO.Path]::Combine($Env:BUILD_ARTIFACTSTAGINGDIRECTORY, 'merged')
+ if (!(Test-Path $merged_nuget_path)) {
+ New-Item -Path $merged_nuget_path -ItemType Directory
+ }
+
+ $merged_nuget = [System.IO.Path]::Combine($merged_nuget_path, $x64_nuget_package_name)
+
+ Start-Process -FilePath "7z" -ArgumentList "-tzip a -r $merged_nuget ." -WorkingDirectory $x64_nupkg_unzipped_directory -NoNewWindow -Wait
+
+ $merged_nuget_without_pdb = [System.IO.Path]::ChangeExtension($merged_nuget, '.nupkg')
+
+ # Now we combine the DLLs and PDBs together, put them back in a folder under $(Build.SourcesDirectory)
+ # We won't upload the unzipped folder. We will just feed it to BinSkim.
+ 7z x -o$(Build.SourcesDirectory)\unzipped $merged_nuget
+ 7z -y x -o$(Build.SourcesDirectory)\unzipped $merged_nuget_without_pdb
+
+ workingDirectory: $(Build.BinariesDirectory)\nuget-artifact-x64
+
+ - script: |
+ dir $(Build.SourcesDirectory)\unzipped\runtimes\win-x64\_native
\ No newline at end of file
diff --git a/.pipelines/nuget_config/x64/packages.config b/.pipelines/nuget_config/x64/packages.config
new file mode 100644
index 0000000000000..73538d46659e5
--- /dev/null
+++ b/.pipelines/nuget_config/x64/packages.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.pipelines/nuget_config/x86/packages.config b/.pipelines/nuget_config/x86/packages.config
new file mode 100644
index 0000000000000..030c67af70145
--- /dev/null
+++ b/.pipelines/nuget_config/x86/packages.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.pipelines/windowsai-steps.yml b/.pipelines/windowsai-steps.yml
new file mode 100644
index 0000000000000..bed9c9a2f4a15
--- /dev/null
+++ b/.pipelines/windowsai-steps.yml
@@ -0,0 +1,176 @@
+parameters:
+- name: BuildArch
+ displayName: BuildArch
+ type: string
+ default: 'x64'
+
+- name: Runtime
+ displayName: MSVC Runtime, should be 'dynamic' or 'static'.
+ type: string
+ default: 'dynamic'
+
+- name: PythonPackageName
+ displayName: PythonPackageName on nuget.org to use
+ type: string
+ default: 'python'
+
+jobs:
+- job: Windows_Packaging_${{ parameters.BuildArch }}_${{ parameters.Runtime }}
+ pool:
+ type: windows
+
+ variables:
+ ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
+ ob_sdl_binskim_break: true
+ ob_sdl_binskim_scanOutputDirectoryOnly: true
+ steps:
+ - template: ../tools/ci_build/github/azure-pipelines/templates/telemetry-steps.yml@self
+
+ - task: NuGetCommand@2
+ displayName: 'NuGet restore'
+ inputs:
+ feedsToUse: config
+ nugetConfigPath: NuGet.config
+ restoreDirectory: '$(Build.BinariesDirectory)'
+ ${{ if eq(parameters.BuildArch, 'x64') }}:
+ restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x64\packages.config
+ ${{ if eq(parameters.BuildArch, 'x86') }}:
+ restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x86\packages.config
+ ${{ if eq(parameters.BuildArch, 'arm') }}:
+ restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x64\packages.config
+ ${{ if eq(parameters.BuildArch, 'arm64') }}:
+ restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x64\packages.config
+
+ - script: |
+ @echo off
+ set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
+ for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do (
+ set vslatest="%%i"
+ if exist "%%i\Common7\Tools\vsdevcmd.bat" (
+ set vsdevcmd="%%i\Common7\Tools\vsdevcmd.bat"
+ )
+ )
+
+ @echo vslatest %vslatest%
+ @echo vsdevcmd %vsdevcmd%
+
+ @echo ##vso[task.setvariable variable=vslatest]%vslatest%
+ @echo ##vso[task.setvariable variable=vsdevcmd]%vsdevcmd% -arch=${{ parameters.BuildArch }}
+ displayName: 'locate vsdevcmd via vswhere'
+
+ - powershell: |
+ Write-Host "##vso[task.setvariable variable=BuildFlags]"
+ Write-Host "##vso[task.setvariable variable=ArtifactName]Microsoft.AI.MachineLearning.${{ parameters.BuildArch }}"
+ displayName: Initialize build flags
+
+ - powershell: |
+ Write-Host "##vso[task.setvariable variable=BuildFlags]$(BuildFlags) --${{ parameters.BuildArch }}"
+ displayName: Add cross compilation flags for ARM
+ condition: and(ne('${{ parameters.BuildArch }}', 'x64'), ne('${{ parameters.BuildArch }}', 'x86'))
+
+ - powershell: |
+ Write-Host "##vso[task.setvariable variable=BuildFlags]$(BuildFlags) --enable_msvc_static_runtime"
+ Write-Host "##vso[task.setvariable variable=ArtifactName]$(ArtifactName).StaticRuntime"
+ displayName: Add static runtime flags
+ condition: eq('${{ parameters.Runtime }}', 'static')
+
+ # must call vsdevcmd first to add cmake to PATH
+ - script: |
+ curl -O -L https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-windows-x86_64.zip
+ 7z x cmake-3.22.2-windows-x86_64.zip
+ set PYTHONHOME=$(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.7.9\tools
+ set PYTHONPATH=$(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.7.9\tools
+ $(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.7.9\tools\python.exe "$(Build.SourcesDirectory)\tools\ci_build\build.py" --build_dir $(Build.BinariesDirectory) --build_shared_lib --enable_onnx_tests --ms_experimental --use_dml --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --use_telemetry --disable_rtti --enable_wcos $(BuildFlags) --cmake_extra_defines CMAKE_SYSTEM_VERSION=10.0.19041.0 --cmake_path $(Build.BinariesDirectory)\cmake-3.22.2-windows-x86_64\bin\cmake.exe --ctest_path $(Build.BinariesDirectory)\cmake-3.22.2-windows-x86_64\bin\ctest.exe
+ workingDirectory: '$(Build.BinariesDirectory)'
+ displayName: 'Generate cmake config'
+
+ - task: VSBuild@1
+ displayName: 'Build'
+ inputs:
+ solution: '$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.sln'
+ ${{ if ne(parameters.BuildArch, 'x86') }}:
+ platform: ${{ parameters.BuildArch }}
+ ${{ if eq(parameters.BuildArch, 'x86') }}:
+ platform: 'Win32'
+ configuration: RelWithDebInfo
+ msbuildArchitecture: ${{ parameters.BuildArch }}
+ maximumCpuCount: true
+ logProjectEvents: true
+ workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo'
+ createLogFile: true
+
+ - ${{ if eq(parameters.Runtime, 'dynamic') }}:
+ - script: |
+ xcopy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\winml_test_api.exe $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\winml_test_scenario.exe $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\winml\test\api\models\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\winml\test\scenario\cppwinrt\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\winml\test\scenario\models\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\winml\test\common\testdata\squeezenet\* $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\winml\test\collateral\models\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
+ xcopy $(Build.SourcesDirectory)\winml\test\collateral\models\ModelSubdirectory $(Build.ArtifactStagingDirectory)\test_artifact\ModelSubdirectory\ /i
+ copy $(Build.SourcesDirectory)\winml\test\collateral\images\*.png $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\winml\test\collateral\images\*.jpg $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\onnxruntime\test\testdata\sequence_length.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
+ copy $(Build.SourcesDirectory)\onnxruntime\test\testdata\sequence_construct.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
+ displayName: 'Copy WinML test collateral to artifact directory'
+
+
+ - ${{ if eq(parameters.BuildArch, 'x64') }}:
+ - script: |
+ call $(vsdevcmd)
+ msbuild Microsoft.AI.MachineLearning.Interop.csproj /p:Configuration=RelWithDebInfo /p:Platform="Any CPU" /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) -restore
+ workingDirectory: '$(Build.SourcesDirectory)\csharp\src\Microsoft.AI.MachineLearning.Interop'
+ displayName: 'Build Microsoft.AI.MachineLearning.Interop.dll'
+
+ - task: onebranch.pipeline.signing@1
+ inputs:
+ command: 'sign'
+ signing_profile: 'external_distribution'
+ files_to_sign: '**/*.exe;**/*.dll'
+ search_root: '$(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo'
+ displayName: 'Sign runtime DLLs'
+
+ - ${{ if eq(parameters.BuildArch, 'x64') }}:
+ - script: |
+ call $(vsdevcmd)
+ msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory)
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
+ workingDirectory: '$(Build.SourcesDirectory)\csharp'
+ displayName: 'Create NuGet Package'
+
+ - ${{ if eq(parameters.BuildArch, 'x86') }}:
+ - script: |
+ call $(vsdevcmd)
+ msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=x86
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
+ workingDirectory: '$(Build.SourcesDirectory)\csharp'
+ displayName: 'Create NuGet Package'
+
+ - ${{ if eq(parameters.BuildArch, 'arm64') }}:
+ - script: |
+ call $(vsdevcmd)
+ msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm64 /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
+ workingDirectory: '$(Build.SourcesDirectory)\csharp'
+ displayName: 'Create NuGet Package'
+
+ - ${{ if eq(parameters.BuildArch, 'arm') }}:
+ - script: |
+ call $(vsdevcmd)
+ msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
+ copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
+ workingDirectory: '$(Build.SourcesDirectory)\csharp'
+ displayName: 'Create NuGet Package'
+
+ - task: onebranch.pipeline.signing@1
+ inputs:
+ command: 'sign'
+ signing_profile: 'external_distribution'
+ files_to_sign: '**/*.exe;**/*.dll'
+ search_root: '$(Build.ArtifactStagingDirectory)\test_artifact'
+ displayName: 'Sign test_artifact'
diff --git a/CITATION.cff b/CITATION.cff
new file mode 100644
index 0000000000000..2a9c47093aa03
--- /dev/null
+++ b/CITATION.cff
@@ -0,0 +1,15 @@
+cff-version: 1.2.0
+title: ONNX Runtime
+message: "Please use this information to cite ONNX Runtime in
+ research or other publications."
+authors:
+ - affiliation: Microsoft Corporation
+ given-names: ONNX Runtime developers
+title: "ONNX Runtime"
+date-released: 2018-11-29
+url: "https://onnxruntime.ai"
+repository-code: "https://github.com/microsoft/onnxruntime"
+license: "MIT License"
+keywords:
+ - deep learning
+ - machine learning
diff --git a/CODEOWNERS b/CODEOWNERS
index 59e103be91a39..43a1eda4115d5 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -1,14 +1,21 @@
# Python frontend owners
-orttraining/*.py @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-orttraining/orttraining/python/** @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-orttraining/orttraining/test/python/** @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-orttraining/pytorch_frontend_examples/** @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-onnxruntime/python/training/** @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-onnxruntime/test/python/onnxruntime_test_ort_trainer.py @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-onnxruntime/test/python/onnxruntime_test_ort_trainer_with_mixed_precision.py @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-onnxruntime/test/python/onnxruntime_test_training_unit_tests.py @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-onnxruntime/test/python/onnxruntime_test_training_unittest_utils.py @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
-samples/python/training/** @thiagocrepaldi @tlh20 @liqunfu @baijumeswani @SherlockNoMad @xadupre
+orttraining/*.py @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+orttraining/orttraining/python/** @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+orttraining/orttraining/test/python/** @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+orttraining/pytorch_frontend_examples/** @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+onnxruntime/python/training/** @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+onnxruntime/test/python/onnxruntime_test_ort_trainer.py @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+onnxruntime/test/python/onnxruntime_test_ort_trainer_with_mixed_precision.py @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+onnxruntime/test/python/onnxruntime_test_training_unit_tests.py @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+onnxruntime/test/python/onnxruntime_test_training_unittest_utils.py @thiagocrepaldi @tlh20 @baijumeswani @xadupre
+samples/python/training/** @thiagocrepaldi @tlh20 @baijumeswani @xadupre
# Mobile
-/onnxruntime/test/testdata/kernel_def_hashes/ @skottmckay @gwang-msft @YUNQIUGUO @edgchen1
+/onnxruntime/test/testdata/kernel_def_hashes/ @skottmckay @YUNQIUGUO @edgchen1
+/onnxruntime/core/framework/kernel_def_hash_helpers.* @skottmckay @YUNQIUGUO @edgchen1
+
+# Contrib Ops
+onnxruntime/core/graph/contrib_ops/nhwc_schema_defs.cc @zhanghuanrong @chenfucn @yufenglee @yihonglyu @snnn
+onnxruntime/core/graph/contrib_ops/nchwc_schema_defs.cc @zhanghuanrong @chenfucn @yufenglee @yihonglyu @snnn
+onnxruntime/core/graph/contrib_ops/quantization_defs.* @zhanghuanrong @chenfucn @yufenglee @yihonglyu @snnn
+onnxruntime/core/mlas/** @zhanghuanrong @chenfucn @yufenglee @yihonglyu @snnn
\ No newline at end of file
diff --git a/ORT_icon_for_light_bg.png b/ORT_icon_for_light_bg.png
new file mode 100644
index 0000000000000..c3182f9422a6d
Binary files /dev/null and b/ORT_icon_for_light_bg.png differ
diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt
index 0a0d490cbc8eb..2ff1385a8981c 100644
--- a/ThirdPartyNotices.txt
+++ b/ThirdPartyNotices.txt
@@ -4741,3 +4741,39 @@ has been taken from other projects or from the open internet. Every line of
code can be traced back to its original author, and all of those authors have
public domain dedications on file. So the SQLite code base is clean and is
uncontaminated with licensed code from other projects.
+
+_____
+
+google/XNNPACK
+
+BSD License
+
+For XNNPACK software
+
+Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
+Copyright 2019 Google LLC
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name Facebook nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/VERSION_NUMBER b/VERSION_NUMBER
index 81c871de46b3e..0eed1a29efd64 100644
--- a/VERSION_NUMBER
+++ b/VERSION_NUMBER
@@ -1 +1 @@
-1.10.0
+1.12.0
diff --git a/cgmanifests/cgmanifest.json b/cgmanifests/cgmanifest.json
index ea66f0fbf161a..379ff6921c568 100644
--- a/cgmanifests/cgmanifest.json
+++ b/cgmanifests/cgmanifest.json
@@ -1,5 +1,14 @@
{
"Registrations": [
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "215105818dfde3174fe799600bb0f3cae233d0bf",
+ "repositoryUrl": "https://github.com/abseil/abseil-cpp.git"
+ }
+ }
+ },
{
"component": {
"Type": "maven",
@@ -29,7 +38,78 @@
"git": {
"commitHash": "638d7d2407de27f98f542f61a37a33c90a2e75a9",
"repositoryUrl": "https://github.com/microsoft/onnxruntime-tvm.git"
- }
+ },
+ "comments": "needed for Nuphar EP"
+ }
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "ffd5f70370642c909222f9a4cae8400023dacbdc",
+ "repositoryUrl": "https://github.com/apache/tvm.git"
+ },
+ "comments": "needed for TVM EP"
+ }
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "cabe04d6d6b05356fa8f9741704924788f0dd762",
+ "repositoryUrl": "https://github.com/agauniyal/rang.git"
+ },
+ "comments": "dependency from tvm"
+ }
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "a3bcc6981d5dad3afb212689e2c7853d1b1ee45d",
+ "repositoryUrl": "https://github.com/NVIDIA/cutlass.git"
+ },
+ "comments": "dependency from tvm"
+ }
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "08f7c7e69f8ea61a0c4151359bc8023be8e9217b",
+ "repositoryUrl": "https://github.com/tlc-pack/libbacktrace.git"
+ },
+ "comments": "dependency from tvm"
+ }
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "36a91576edf633479c78649e050f18dd2ddc8103",
+ "repositoryUrl": "https://github.com/apache/incubator-tvm-vta.git"
+ },
+ "comments": "dependency from tvm"
+ }
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "111c9be5188f7350c2eac9ddaedd8cca3d7bf394",
+ "repositoryUrl": "https://github.com/kazuho/picojson.git"
+ },
+ "comments": "dependency from tvm"
+ }
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "b5e4186d7ab63458e79084842dced166be2ca5b5",
+ "repositoryUrl": "https://github.com/lammertb/libcrc.git"
+ },
+ "comments": "dependency from tvm"
}
},
{
@@ -493,6 +573,16 @@
"DownloadUrl": "http://security.ubuntu.com/ubuntu/pool/main/s/sqlite3/libsqlite3-dev_3.22.0-1ubuntu0.4_amd64.deb"
}
}
+ },
+ {
+ "component": {
+ "type": "git",
+ "git": {
+ "commitHash": "512d44b9aa22690fd7d7e665fcab9bdcb590f118",
+ "repositoryUrl": "https://github.com/google/XNNPACK.git"
+ },
+ "comments": "xnnpack"
+ }
}
],
"Version": 1
diff --git a/cgmanifests/generated/cgmanifest.json b/cgmanifests/generated/cgmanifest.json
index 8acfa446b87f1..9a2dd64722c74 100644
--- a/cgmanifests/generated/cgmanifest.json
+++ b/cgmanifests/generated/cgmanifest.json
@@ -110,16 +110,6 @@
"comments": "git submodule at cmake/external/SafeInt/safeint"
}
},
- {
- "component": {
- "type": "git",
- "git": {
- "commitHash": "523d5e03d86c26267ee6bdf17dd20f6ce6bdadd7",
- "repositoryUrl": "https://github.com/apple/coremltools.git"
- },
- "comments": "git submodule at cmake/external/coremltools"
- }
- },
{
"component": {
"type": "git",
@@ -174,7 +164,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "a3d65c80d32c3e584b7aab41d516a0043b2a5e84",
+ "commitHash": "3acac70a551c321574732e5bfd67930244bb7151",
"repositoryUrl": "https://github.com/emscripten-core/emsdk.git"
},
"comments": "git submodule at cmake/external/emsdk"
@@ -215,7 +205,7 @@
"type": "git",
"git": {
"commitHash": "db78ac1d7716f56fc9f1b030b715f872f93964e4",
- "repositoryUrl": "https://github.com/nlohmann/json"
+ "repositoryUrl": "https://github.com/nlohmann/json.git"
},
"comments": "git submodule at cmake/external/json"
}
@@ -234,7 +224,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "2d54553b7a78c7c35620b827e7e5ab2228ecb495",
+ "commitHash": "f412df7a2b64421e1f1d61fde6055a6ea288e8f5",
"repositoryUrl": "https://github.com/microsoft/mimalloc.git"
},
"comments": "git submodule at cmake/external/mimalloc"
@@ -255,7 +245,7 @@
"type": "git",
"git": {
"commitHash": "436617053d0f39a1019a371c3a9aa599b3cb2cea",
- "repositoryUrl": "https://github.com/google/nsync"
+ "repositoryUrl": "https://github.com/google/nsync.git"
},
"comments": "git submodule at cmake/external/nsync"
}
@@ -264,8 +254,8 @@
"component": {
"type": "git",
"git": {
- "commitHash": "be76ca7148396176784ba8733133b9fb1186ea0d",
- "repositoryUrl": "https://github.com/onnx/onnx"
+ "commitHash": "850a81b0b77786bf99ea90580242b084f86a6235",
+ "repositoryUrl": "https://github.com/onnx/onnx.git"
},
"comments": "git submodule at cmake/external/onnx"
}
@@ -294,7 +284,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "1f416bb462689f3ef9e3f1057a113d9c6aba6972",
+ "commitHash": "e9456d57605c883cdf985e634ab483e2c1500bb1",
"repositoryUrl": "https://github.com/onnx/onnx-tensorrt.git"
},
"comments": "git submodule at cmake/external/onnx-tensorrt"
@@ -304,7 +294,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "553df22c67bee5f0fe6599cff60f1afc6748c635",
+ "commitHash": "994c6181247d7b419b28889fc57d5817e2089419",
"repositoryUrl": "https://github.com/onnx/onnx.git"
},
"comments": "git submodule at cmake/external/onnx-tensorrt/third_party/onnx"
@@ -324,22 +314,12 @@
"component": {
"type": "git",
"git": {
- "commitHash": "09f082940113661256310e3f4811aa7261a9fa05",
+ "commitHash": "59a2ac2745d8a57ac94c6accced73620d59fb844",
"repositoryUrl": "https://github.com/pybind/pybind11.git"
},
"comments": "git submodule at cmake/external/onnx-tensorrt/third_party/onnx/third_party/pybind11"
}
},
- {
- "component": {
- "type": "git",
- "git": {
- "commitHash": "6a00cbc4a9b8e68b71caf7f774b3f9c753ae84d5",
- "repositoryUrl": "https://github.com/wjakob/clang-cindex-python3"
- },
- "comments": "git submodule at cmake/external/onnx-tensorrt/third_party/onnx/third_party/pybind11/tools/clang"
- }
- },
{
"component": {
"type": "git",
@@ -354,7 +334,7 @@
"component": {
"type": "git",
"git": {
- "commitHash": "2dc747c574b68a808ea4699d26942c8132fe2b09",
+ "commitHash": "0dab03ba7bc438d7ba3eac2b2c1eb39ed520f928",
"repositoryUrl": "https://github.com/protocolbuffers/protobuf.git"
},
"comments": "git submodule at cmake/external/protobuf"
@@ -410,62 +390,12 @@
"comments": "git submodule at cmake/external/tensorboard"
}
},
- {
- "component": {
- "type": "git",
- "git": {
- "commitHash": "9ec2b92d180dff8877e402018b97baa574031b8b",
- "repositoryUrl": "https://github.com/microsoft/onnxruntime-tvm.git"
- },
- "comments": "git submodule at cmake/external/tvm"
- }
- },
- {
- "component": {
- "type": "git",
- "git": {
- "commitHash": "b257a9221ee1e5180d994b3488ddcc259b0ac157",
- "repositoryUrl": "https://github.com/dmlc/HalideIR"
- },
- "comments": "git submodule at cmake/external/tvm/3rdparty/HalideIR"
- }
- },
- {
- "component": {
- "type": "git",
- "git": {
- "commitHash": "5c792cef3aee54ad8b7000111c9dc1797f327b59",
- "repositoryUrl": "https://github.com/dmlc/dlpack"
- },
- "comments": "git submodule at cmake/external/tvm/3rdparty/dlpack"
- }
- },
- {
- "component": {
- "type": "git",
- "git": {
- "commitHash": "d07fb7a443b5db8a89d65a15a024af6a425615a5",
- "repositoryUrl": "https://github.com/dmlc/dmlc-core"
- },
- "comments": "git submodule at cmake/external/tvm/3rdparty/dmlc-core"
- }
- },
- {
- "component": {
- "type": "git",
- "git": {
- "commitHash": "cabe04d6d6b05356fa8f9741704924788f0dd762",
- "repositoryUrl": "https://github.com/agauniyal/rang"
- },
- "comments": "git submodule at cmake/external/tvm/3rdparty/rang"
- }
- },
{
"component": {
"type": "git",
"git": {
"commitHash": "e8c599bca6c56c44b6730ad93f6abbc9ecd60fc1",
- "repositoryUrl": "https://github.com/microsoft/wil"
+ "repositoryUrl": "https://github.com/microsoft/wil.git"
},
"comments": "git submodule at cmake/external/wil"
}
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 0b09078e0eefe..1eb32aa04762d 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -22,6 +22,7 @@ set(CMAKE_C_STANDARD 99)
include(CheckCXXCompilerFlag)
include(CheckLanguage)
include(CMakeDependentOption)
+include(FetchContent)
set(CMAKE_CXX_STANDARD 17)
@@ -59,15 +60,14 @@ option(onnxruntime_BUILD_OBJC "Build Objective-C library" OFF)
option(onnxruntime_USE_PREINSTALLED_EIGEN "Use pre-installed EIGEN. Need to provide eigen_SOURCE_PATH if turn this on." OFF)
option(onnxruntime_BUILD_BENCHMARKS "Build ONNXRuntime micro-benchmarks" OFF)
-option(onnxruntime_USE_TVM "Build tvm for code-gen" OFF)
-option(onnxruntime_USE_LLVM "Build tvm with LLVM" OFF)
+option(onnxruntime_USE_NUPHAR_TVM "Build TVM for code generation for NUPHAR EP" OFF)
+option(onnxruntime_USE_LLVM "Build TVM with LLVM" OFF)
option(onnxruntime_BUILD_FOR_NATIVE_MACHINE "Enable this option for turning on optimization specific to this machine" OFF)
option(onnxruntime_USE_AVX "Use AVX instructions" OFF)
option(onnxruntime_USE_AVX2 "Use AVX2 instructions" OFF)
option(onnxruntime_USE_AVX512 "Use AVX512 instructions" OFF)
-option(onnxruntime_USE_OPENMP "Build with OpenMP support" OFF)
option(onnxruntime_BUILD_SHARED_LIB "Build a shared library" OFF)
option(onnxruntime_BUILD_APPLE_FRAMEWORK "Build a macOS/iOS framework" OFF)
option(onnxruntime_ENABLE_MICROSOFT_INTERNAL "Use this option to enable/disable microsoft internal only code" OFF)
@@ -97,12 +97,15 @@ option(onnxruntime_ARMNN_RELU_USE_CPU "Use the CPU implementation for the Relu o
option(onnxruntime_ARMNN_BN_USE_CPU "Use the CPU implementation for the Batch Normalization operator for the ArmNN EP" ON)
option(onnxruntime_ENABLE_INSTRUMENT "Enable Instrument with Event Tracing for Windows (ETW)" OFF)
option(onnxruntime_USE_TELEMETRY "Build with Telemetry" OFF)
+option(onnxruntime_USE_MIMALLOC "Override new/delete and arena allocator with mimalloc" OFF)
#The onnxruntime_PREFER_SYSTEM_LIB is mainly designed for package managers like apt/yum/vcpkg.
#Please note, by default Protobuf_USE_STATIC_LIBS is OFF but it's recommended to turn it ON on Windows. You should set it properly when onnxruntime_PREFER_SYSTEM_LIB is ON otherwise you'll hit linkage errors.
#If you have already installed protobuf(or the others) in your system at the default system paths(like /usr/include), then it's better to set onnxruntime_PREFER_SYSTEM_LIB ON. Otherwise onnxruntime may see two different protobuf versions and we won't know which one will be used, the worst case could be onnxruntime picked up header files from one of them but the binaries from the other one.
#It's default OFF because it's experimental now.
option(onnxruntime_PREFER_SYSTEM_LIB "Experimental: Build with the preinstalled libraries in your system" OFF)
option(onnxruntime_USE_ROCM "Build with AMD GPU support" OFF)
+option(onnxruntime_USE_TVM "Build with TVM support" OFF)
+option(onnxruntime_TVM_CUDA_RUNTIME "Build TVM with CUDA support" OFF)
# Options related to reducing the binary size produced by the build
option(onnxruntime_DISABLE_CONTRIB_OPS "Disable contrib ops" OFF)
@@ -118,9 +121,6 @@ option(onnxruntime_EXTENDED_MINIMAL_BUILD "onnxruntime_MINIMAL_BUILD with suppor
option(onnxruntime_MINIMAL_BUILD_CUSTOM_OPS "Add custom operator kernels support to a minimal build." OFF)
option(onnxruntime_REDUCED_OPS_BUILD "Reduced set of kernels are registered in build via modification of the kernel registration source files." OFF)
option(onnxruntime_DISABLE_EXTERNAL_INITIALIZERS "Don't allow models to load external data" OFF)
-cmake_dependent_option(onnxruntime_ENABLE_ORT_FORMAT_RUNTIME_GRAPH_OPTIMIZATION
- "Enable runtime graph optimization of ORT format models. Warning: Not yet ready for general use."
- OFF "NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_EXTENDED_MINIMAL_BUILD" OFF)
#A special option just for debugging and sanitize check. Please do not enable in option in retail builds.
#The option has no effect on Windows.
@@ -146,6 +146,7 @@ option(onnxruntime_USE_MPI "Build with MPI support" OFF)
# build WebAssembly
option(onnxruntime_BUILD_WEBASSEMBLY "Enable this option to create WebAssembly byte codes" OFF)
+option(onnxruntime_BUILD_WEBASSEMBLY_STATIC_LIB "Enable this option to create WebAssembly static library" OFF)
option(onnxruntime_ENABLE_WEBASSEMBLY_THREADS "Enable this option to create WebAssembly byte codes with multi-threads support" OFF)
option(onnxruntime_ENABLE_WEBASSEMBLY_EXCEPTION_CATCHING "Enable this option to turn on exception catching" OFF)
option(onnxruntime_ENABLE_WEBASSEMBLY_EXCEPTION_THROWING "Enable this option to turn on exception throwing even if the build disabled exceptions support" OFF)
@@ -283,25 +284,13 @@ if (onnxruntime_BUILD_CSHARP)
endif()
if (NOT WIN32)
- #TODO: On Linux we may try https://github.com/microsoft/TraceLogging
+ #TODO: On Linux we may try https://github.com/microsoft/TraceLogging.git
if (onnxruntime_ENABLE_INSTRUMENT)
message(WARNING "Instrument is only supported on Windows now")
set(onnxruntime_ENABLE_INSTRUMENT OFF)
endif()
endif()
-if (onnxruntime_USE_OPENMP)
- find_package(OpenMP)
- if (OPENMP_FOUND)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
- include_directories(${OpenMP_CXX_INCLUDE_DIR})
- else()
- message(WARNING "Flag --use_openmp is specified, but OpenMP is not found in current build environment. Setting it to OFF.")
- set(onnxruntime_USE_OPENMP OFF)
- endif()
-endif()
-
# 'extended' implies minimal.
if (onnxruntime_EXTENDED_MINIMAL_BUILD AND NOT onnxruntime_MINIMAL_BUILD)
set(onnxruntime_MINIMAL_BUILD ON)
@@ -314,9 +303,13 @@ if (NOT MSVC AND NOT onnxruntime_ENABLE_BITCODE)
string(APPEND CMAKE_C_FLAGS " -ffunction-sections -fdata-sections")
endif()
+if (onnxruntime_ENABLE_EAGER_MODE)
+ string(APPEND CMAKE_CXX_FLAGS " -D_GLIBCXX_USE_CXX11_ABI=${_GLIBCXX_USE_CXX11_ABI}")
+endif()
+
if (onnxruntime_BUILD_WEBASSEMBLY)
# Enable LTO for release single-thread build
- if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
+ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# NOTES:
# (1) LTO does not work for WebAssembly multi-thread. (segment fault in worker)
# (2) "-flto=thin" does not work correctly for wasm-ld.
@@ -357,8 +350,6 @@ if (onnxruntime_MINIMAL_BUILD)
add_compile_definitions(ORT_MINIMAL_BUILD_CUSTOM_OPS)
endif()
- set(onnxruntime_REDUCED_OPS_BUILD ON)
-
if (MSVC)
# turn on LTO (which adds some compiler flags and turns on LTCG) unless it's a Debug build to minimize binary size
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -385,10 +376,6 @@ if (onnxruntime_MINIMAL_BUILD)
endif()
endif()
-if (onnxruntime_ENABLE_ORT_FORMAT_RUNTIME_GRAPH_OPTIMIZATION)
- add_compile_definitions(ORT_ENABLE_ORT_FORMAT_RUNTIME_GRAPH_OPTIMIZATION)
-endif()
-
if (onnxruntime_ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_enabled OUTPUT ipo_output)
@@ -498,6 +485,14 @@ if (onnxruntime_CROSS_COMPILING)
endif()
endif()
+if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+ check_cxx_compiler_flag(-Wno-error HAS_NOERROR)
+ if (HAS_NOERROR)
+ string(APPEND CMAKE_CXX_FLAGS " -Wno-error=attributes")
+ string(APPEND CMAKE_C_FLAGS " -Wno-error=attributes")
+ endif()
+endif()
+
# Mark symbols to be invisible, for macOS/iOS target only
# Due to many dependencies have different symbol visibility settings, set global compile flags here.
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS")
@@ -506,8 +501,11 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS")
endforeach()
endif()
-#must after OpenMP settings
find_package(Threads)
+find_package(Patch)
+if(Patch_FOUND)
+ message("Patch found: ${Patch_EXECUTABLE}")
+endif()
macro(check_nvcc_compiler_flag _FLAG _RESULT)
execute_process(COMMAND ${onnxruntime_CUDA_HOME}/bin/nvcc "${_FLAG}" RESULT_VARIABLE NVCC_OUT ERROR_VARIABLE NVCC_ERROR)
@@ -818,7 +816,6 @@ if (onnxruntime_USE_CUDA AND "${onnxruntime_CUDNN_HOME}" STREQUAL "")
message(FATAL_ERROR "onnxruntime_CUDNN_HOME required for onnxruntime_USE_CUDA")
endif()
-
get_filename_component(ONNXRUNTIME_ROOT "${ONNXRUNTIME_ROOT}" ABSOLUTE)
get_filename_component(ORTTRAINING_ROOT "${ORTTRAINING_ROOT}" ABSOLUTE)
get_filename_component(REPO_ROOT "${REPO_ROOT}" ABSOLUTE)
@@ -880,8 +877,8 @@ else()
if (${onnxruntime_target_platform} MATCHES "^(ARM.*|arm.*)$" )
message(WARNING "Cpuinfo not included for compilation problems with Windows ARM.")
set(CPUINFO_SUPPORTED FALSE)
- elseif (WINDOWS_STORE OR (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib))
- message(WARNING "Cpuinfo not included in Windows Store or WCOS builds")
+ 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)$")
@@ -933,8 +930,9 @@ include(eigen)
#onnxruntime_EXTERNAL_LIBRARIES could contain onnx, onnx_proto,libprotobuf, cuda/cudnn,
# dnnl/mklml, onnxruntime_codegen_tvm, tvm and pthread
# pthread is always at the last
-set(onnxruntime_EXTERNAL_LIBRARIES onnx onnx_proto ${PROTOBUF_LIB} re2::re2)
-
+set(onnxruntime_EXTERNAL_LIBRARIES onnx onnx_proto ${PROTOBUF_LIB} re2::re2 absl::inlined_vector absl::flat_hash_set
+ absl::flat_hash_map absl::node_hash_set absl::node_hash_map absl::base absl::throw_delegate absl::raw_hash_set
+ absl::hash absl::city absl::low_level_hash absl::raw_logging_internal)
set(onnxruntime_LINK_DIRS )
if (onnxruntime_USE_CUDA)
@@ -964,11 +962,6 @@ if (WIN32)
# warning C4800: Implicit conversion from 'X' to bool. Possible information loss
if (onnxruntime_USE_OPENVINO OR onnxruntime_ENABLE_EAGER_MODE)
list(APPEND ORT_WARNING_FLAGS "/wd4800")
- else()
- list(APPEND ORT_WARNING_FLAGS "/w34800")
- endif()
- if (onnxruntime_USE_OPENMP)
- list(APPEND ORT_WARNING_FLAGS "/wd6993") # Code analysis ignores OpenMP constructs
endif()
# operator 'operator-name': deprecated between enumerations of different types
list(APPEND ORT_WARNING_FLAGS "/wd5054")
@@ -1031,6 +1024,7 @@ else()
check_cxx_compiler_flag(-Wdeprecated-anon-enum-enum-conversion HAS_DEPRECATED_ANON_ENUM_ENUM_CONVERSION)
check_cxx_compiler_flag(-Wundefined-var-template HAS_UNDEFINED_VAR_TEMPLATE)
check_cxx_compiler_flag(-Wformat-truncation HAS_FORMAT_TRUNCATION)
+ check_cxx_compiler_flag(-Wbitwise-instead-of-logical HAS_BITWISE_INSTEAD_OF_LOGICAL)
if (HAS_TAUTOLOGICAL_POINTER_COMPARE)
#we may have extra null pointer checkings in debug build, it's not an issue
@@ -1102,6 +1096,11 @@ if (onnxruntime_USE_NUPHAR)
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_NUPHAR=1)
list(APPEND ONNXRUNTIME_PROVIDER_NAMES nuphar)
endif()
+if (onnxruntime_USE_TVM)
+ list(APPEND ORT_PROVIDER_FLAGS -DUSE_TVM=1)
+ list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_TVM=1)
+ list(APPEND ONNXRUNTIME_PROVIDER_NAMES tvm)
+endif()
if (onnxruntime_USE_WINML)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_WINML=1)
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_WINML=1)
@@ -1122,7 +1121,6 @@ if (onnxruntime_USE_MIGRAPHX)
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_MIGRAPHX=1)
list(APPEND ONNXRUNTIME_PROVIDER_NAMES migraphx)
endif()
-
if (onnxruntime_USE_ARMNN)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_ARMNN=1)
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_ARMNN=1)
@@ -1139,6 +1137,7 @@ if (onnxruntime_USE_COREML)
list(APPEND ONNXRUNTIME_PROVIDER_NAMES coreml)
endif()
function(onnxruntime_set_compile_flags target_name)
+ target_compile_definitions(${target_name} PUBLIC EIGEN_USE_THREADS)
if (MSVC)
target_compile_definitions(${target_name} PUBLIC -DPLATFORM_WINDOWS -DNOGDI -DNOMINMAX -D_USE_MATH_DEFINES -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
if (onnxruntime_ENABLE_MEMLEAK_CHECKER)
@@ -1149,8 +1148,8 @@ function(onnxruntime_set_compile_flags target_name)
set_target_properties(${target_name}
PROPERTIES VS_GLOBAL_CAExcludePath "${ORT_BINARY_DIR};${ORT_SOURCE_DIR}")
if (onnxruntime_ENABLE_STATIC_ANALYSIS)
- target_compile_options(${target_name} PRIVATE "$<$>:/analyze:stacksize 131072>")
- target_compile_options(${target_name} PRIVATE "$<$>:/analyze:external->")
+ target_compile_options(${target_name} PRIVATE "$<$:SHELL:--compiler-options /analyze>" "$<$>:/analyze>")
+ target_compile_options(${target_name} PRIVATE "$<$:SHELL:--compiler-options /analyze:external->" "$<$>:/analyze:external->")
endif()
else()
# Enable warning
@@ -1197,12 +1196,21 @@ function(onnxruntime_configure_target target_name)
target_link_directories(${target_name} PRIVATE ${onnxruntime_LINK_DIRS})
onnxruntime_set_compile_flags(${target_name})
onnxruntime_set_source_file_properties(${target_name})
- target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})
+ #Uncomment the following three lines to reproduce static analysis errors locally
+ #if(WIN32 AND onnxruntime_ENABLE_STATIC_ANALYSIS)
+ # set_target_properties(${target_name} PROPERTIES VS_USER_PROPS ${PROJECT_SOURCE_DIR}/EnableVisualStudioCodeAnalysis.props)
+ #endif()
+ target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${abseil_cpp_SOURCE_DIR})
if (onnxruntime_ENABLE_LTO)
set_target_properties(${target_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
set_target_properties(${target_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
set_target_properties(${target_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE)
endif()
+
+ # Keep BinSkim happy
+ if(MSVC AND NOT onnxruntime_target_platform MATCHES "ARM")
+ target_link_options(${target_name} PRIVATE "/CETCOMPAT")
+ endif()
endfunction()
function(onnxruntime_add_shared_library target_name)
@@ -1211,7 +1219,7 @@ function(onnxruntime_add_shared_library target_name)
endfunction()
function(onnxruntime_add_static_library target_name)
- add_library(${target_name} ${ARGN})
+ add_library(${target_name} STATIC ${ARGN})
onnxruntime_configure_target(${target_name})
endfunction()
@@ -1225,15 +1233,15 @@ function(onnxruntime_add_shared_library_module target_name)
endif()
onnxruntime_configure_target(${target_name})
- if (onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY)
+ if (MSVC AND onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY)
target_link_options(${target_name} PRIVATE /SAFESEH)
endif()
endfunction()
-function(onnxruntime_add_executable target_name)
+function(onnxruntime_add_executable target_name)
add_executable(${target_name} ${ARGN})
onnxruntime_configure_target(${target_name})
- if (onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY)
+ if (MSVC AND onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY)
target_link_options(${target_name} PRIVATE /SAFESEH)
endif()
endfunction()
@@ -1325,32 +1333,101 @@ if (onnxruntime_USE_DNNL)
include(dnnl)
endif()
-# TVM
-if (onnxruntime_USE_TVM)
+# NUPHAR EP
+if (onnxruntime_USE_NUPHAR_TVM)
+ if (NOT TARGET tvm)
+ message(STATUS "Include TVM(*).")
+ include(tvm)
+ endif()
if (onnxruntime_USE_CUDA)
- set(USE_CUDA ON)
+ set(USE_CUDA ON CACHE BOOL "Only defined for TVM")
endif()
if (onnxruntime_USE_LLVM)
- set(USE_LLVM ON)
- add_definitions(-DUSE_TVM_WITH_LLVM)
- endif()
- if (onnxruntime_USE_OPENMP)
- set(USE_OPENMP "gnu")
+ set(USE_LLVM ON CACHE BOOL "Only defined for TVM")
+ add_definitions(-DUSE_NUPHAR_TVM_WITH_LLVM)
endif()
- add_subdirectory(${PROJECT_SOURCE_DIR}/external/tvm EXCLUDE_FROM_ALL)
- set_target_properties(tvm PROPERTIES FOLDER "External/tvm")
- set_target_properties(tvm_topi PROPERTIES FOLDER "External/tvm")
- set_target_properties(tvm_runtime PROPERTIES FOLDER "External/tvm")
+ message(STATUS "TVM BEFORE USE_LLVM=${USE_LLVM} USE_OPENMP=${USE_OPENMP} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} USE_CUDA=${USE_CUDA} USE_GTEST=${USE_GTEST} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
+ message(STATUS "tvm_SOURCE_DIR=${tvm_SOURCE_DIR}")
+ message(STATUS "tvm_BINARY_DIR=${tvm_BINARY_DIR}")
+ add_subdirectory(${tvm_SOURCE_DIR} ${tvm_BINARY_DIR} EXCLUDE_FROM_ALL)
+ message(STATUS "TVM AFTER USE_LLVM=${USE_LLVM} USE_OPENMP=${USE_OPENMP} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} USE_CUDA=${USE_CUDA} USE_GTEST=${USE_GTEST} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
- set(TVM_INCLUDES ${PROJECT_SOURCE_DIR}/external/tvm/include
- ${PROJECT_SOURCE_DIR}/external/tvm/3rdparty/dmlc-core/include
- ${PROJECT_SOURCE_DIR}/external/tvm/3rdparty/dlpack/include
+ set_target_properties(tvm PROPERTIES FOLDER ${tvm_SOURCE_DIR})
+ set_target_properties(tvm_topi PROPERTIES FOLDER ${tvm_SOURCE_DIR})
+ set_target_properties(tvm_runtime PROPERTIES FOLDER ${tvm_SOURCE_DIR})
+
+ set(TVM_INCLUDES ${tvm_SOURCE_DIR}/include
+ ${tvm_SOURCE_DIR}/3rdparty/dmlc-core/include
+ ${tvm_SOURCE_DIR}/3rdparty/dlpack/include
$
$)
- add_definitions(-DUSE_TVM)
+
+ add_definitions(-DUSE_NUPHAR_TVM)
set(onnxruntime_tvm_libs onnxruntime_codegen_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_DEPENDENCIES tvm)
+
+ if (WIN32 AND MSVC)
+ # wd4100: identifier' : unreferenced formal parameter
+ # wd4244: conversion from 'int' to 'char', possible loss of data
+ # wd4251: class X needs to have dll-interface to be used by clients of class Y
+ # wd4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
+ # wd4275: non dll-interface class X used as base for dll-interface class Y
+ # wd4389: signed/unsigned mismatch
+ # wd4456: declaration of X hides previous local declaration
+ set(DISABLED_WARNINGS_FOR_TVM "/wd4100" "/wd4244" "/wd4251" "/wd4267" "/wd4275" "/wd4389" "/wd4456")
+ else()
+ set(DISABLED_WARNINGS_FOR_TVM "-Wno-error=ignored-qualifiers" "-Wno-unused-parameter" "-Wno-ignored-qualifiers")
+ list(APPEND DISABLED_WARNINGS_FOR_TVM "-Wno-error=unused-parameter")
+ if (HAS_CATCH_VALUE)
+ #TODO: send a PR to TVM and fix it
+ list(APPEND DISABLED_WARNINGS_FOR_TVM "-Wno-error=catch-value")
+ endif()
+ endif()
+
+endif(onnxruntime_USE_NUPHAR_TVM)
+
+# TVM EP
+if (onnxruntime_USE_TVM)
+ if (NOT TARGET tvm)
+ message(STATUS "Include TVM(*).")
+ include(tvm)
+ endif()
+
+ if (onnxruntime_USE_LLVM)
+ set(USE_LLVM ON CACHE BOOL "Only defined for TVM")
+ endif()
+
+ if (onnxruntime_TVM_CUDA_RUNTIME)
+ set(USE_CUDA ON CACHE BOOL "Only defined for TVM" FORCE)
+ endif()
+
+ # TODO(vvchernov): customized tvm logger is hidden due to the issue on TVM side (https://github.com/apache/tvm/issues/10139)
+ # add_compile_definitions(TVM_LOG_CUSTOMIZE=1)
+ # add_library(tvm_custom_logger STATIC ${ONNXRUNTIME_ROOT}/core/providers/tvm/custom_logging.cc)
+
+ set(USE_OPENMP gnu CACHE STRING "Only defined for TVM")
+ add_subdirectory(${tvm_SOURCE_DIR} ${tvm_BINARY_DIR} EXCLUDE_FROM_ALL)
+
+ set_target_properties(tvm PROPERTIES FOLDER ${tvm_SOURCE_DIR})
+ # target_link_libraries(tvm PUBLIC tvm_custom_logger)
+
+ set(TVM_INCLUDES ${tvm_SOURCE_DIR}/include
+ ${tvm_SOURCE_DIR}/3rdparty/dmlc-core/include
+ ${tvm_SOURCE_DIR}/3rdparty/dlpack/include
+ $)
+
+ set(onnxruntime_tvm_libs onnxruntime_providers_tvm)
+
# needs to link with stdc++fs in Linux
if (UNIX)
if (NOT APPLE)
@@ -1624,6 +1701,16 @@ if (onnxruntime_USE_CUDA)
endif()
endif()
+if (onnxruntime_USE_TENSORRT)
+ # 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 ${FS_STDLIB})
+endif()
+
if (onnxruntime_USE_MIGRAPHX)
if (WIN32)
message(FATAL_ERROR "MIGraphX does not support build in Windows!")
@@ -1665,27 +1752,6 @@ if (onnxruntime_USE_ROCM)
add_definitions(-DROCM_VERSION=${ROCM_VERSION_DEV_INT})
endif()
-if (onnxruntime_USE_TVM)
- if (WIN32 AND MSVC)
- # wd4100: identifier' : unreferenced formal parameter
- # wd4244: conversion from 'int' to 'char', possible loss of data
- # wd4251: class X needs to have dll-interface to be used by clients of class Y
- # wd4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
- # wd4275: non dll-interface class X used as base for dll-interface class Y
- # wd4389: signed/unsigned mismatch
- # wd4456: declaration of X hides previous local declaration
- set(DISABLED_WARNINGS_FOR_TVM "/wd4100" "/wd4244" "/wd4251" "/wd4267" "/wd4275" "/wd4389" "/wd4456")
- else()
- set(DISABLED_WARNINGS_FOR_TVM "-Wno-error=ignored-qualifiers" "-Wno-unused-parameter" "-Wno-ignored-qualifiers")
- list(APPEND DISABLED_WARNINGS_FOR_TVM "-Wno-error=unused-parameter")
- if (HAS_CATCH_VALUE)
- #TODO: send a PR to TVM and fix it
- list(APPEND DISABLED_WARNINGS_FOR_TVM "-Wno-error=catch-value")
- endif()
- endif()
- include(onnxruntime_codegen.cmake)
-endif()
-
if (onnxruntime_ENABLE_MICROSOFT_INTERNAL)
add_definitions(-DMICROSOFT_INTERNAL)
endif()
@@ -1803,8 +1869,11 @@ if (onnxruntime_ENABLE_TRAINING)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES tensorboard)
endif()
-#names in this var must match the directory names under onnxruntime/core/providers
+
set(ONNXRUNTIME_TARGETS onnxruntime_common onnxruntime_graph onnxruntime_framework onnxruntime_util onnxruntime_providers onnxruntime_optimizer onnxruntime_session onnxruntime_mlas onnxruntime_flatbuffers)
+if (onnxruntime_USE_NUPHAR_TVM)
+ list(APPEND ONNXRUNTIME_TARGETS onnxruntime_codegen_tvm)
+endif()
if (onnxruntime_ENABLE_EAGER_MODE)
if (NOT onnxruntime_ENABLE_TRAINING OR NOT onnxruntime_ENABLE_PYTHON)
message(
@@ -1822,12 +1891,8 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Android")
list(APPEND onnxruntime_EXTERNAL_LIBRARIES log)
endif()
-if (onnxruntime_USE_OPENMP)
- list(APPEND onnxruntime_EXTERNAL_LIBRARIES OpenMP::OpenMP_CXX)
-endif()
-
if (WIN32)
- list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${SYS_PATH_LIB} Shlwapi)
+ list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${SYS_PATH_LIB})
list(APPEND onnxruntime_EXTERNAL_LIBRARIES debug Dbghelp)
else()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES nsync_cpp)
@@ -1835,25 +1900,19 @@ else()
endif()
if (WIN32)
- if (WINDOWS_STORE)
- # Setting WINAPI_FAMILY, WINVER and _WIN32_WINNT restrict the APIs exposed in Windows headers to those available
- # in store or desktop, and that support at least the version of Windows specified
- add_compile_definitions(WINAPI_FAMILY=2) # Windows Store app
- add_compile_definitions(WINVER=0x0A00 _WIN32_WINNT=0x0A00 NTDDI_VERSION=0x0A000000) # Support Windows 10 or newer
- # /ZW adds /FUplatform.winmd and /FUwindows.winmd. windows.winmd, in turn, overrides the include path for
- # the cppwinrt headers, which we set to use the WinML built ones.
- # Instead, we use /ZW:nostdlib and force include platform.winml only.
- add_compile_options("$<$:SHELL:/ZW:nostdlib /FUplatform.winmd>")
- get_filename_component(msvc_path "${CMAKE_C_COMPILER}/../../../.." ABSOLUTE)
- link_directories("${msvc_path}/lib/${onnxruntime_target_platform}/store")
- add_link_options(/APPCONTAINER)
+ add_compile_definitions(WINAPI_FAMILY=100) # Desktop app
+ if (onnxruntime_USE_WINML)
+ add_compile_definitions(WINVER=0x0602 _WIN32_WINNT=0x0602 NTDDI_VERSION=0x06020000) # Support Windows 8 and newer
else()
- add_compile_definitions(WINAPI_FAMILY=100) # Desktop app
- if (onnxruntime_USE_WINML)
- add_compile_definitions(WINVER=0x0602 _WIN32_WINNT=0x0602 NTDDI_VERSION=0x06020000) # Support Windows 7 and newer
- else()
- add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601 NTDDI_VERSION=0x06010000) # Support Windows 7 and newer
- endif()
+ add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601 NTDDI_VERSION=0x06010000) # Support Windows 7 and newer
+ endif()
+ if (NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
+ # On onecore, link to the onecore build of the MSVC runtime
+ get_filename_component(msvc_path "${CMAKE_C_COMPILER}/../../../.." ABSOLUTE)
+ link_directories(BEFORE "${msvc_path}/lib/onecore/${onnxruntime_target_platform}")
+ # The .lib files in the MSVC runtime have a DEFAULITLIB entry for onecore.lib, which in turn links to reverse forwarders.
+ # We ignore that entry and use onecore_apiset.lib instead, since system components must not rely on reverse forwarders.
+ add_link_options("/NODEFAULTLIB:onecore.lib")
endif()
endif()
@@ -1939,16 +1998,6 @@ if (onnxruntime_BUILD_WEBASSEMBLY)
include(onnxruntime_webassembly.cmake)
endif()
-if (WINDOWS_STORE)
- target_link_options(onnxruntime PRIVATE /DYNAMICBASE /NXCOMPAT /APPCONTAINER)
- target_link_options(winml_dll PRIVATE /DYNAMICBASE /NXCOMPAT /APPCONTAINER)
-
- if (onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_BUILD_WEBASSEMBLY)
- target_link_options(onnxruntime PRIVATE /SAFESEH)
- target_link_options(winml_dll PRIVATE /SAFESEH)
- endif()
-endif()
-
if (UNIX)
option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
else()
diff --git a/cmake/EnableVisualStudioCodeAnalysis.props b/cmake/EnableVisualStudioCodeAnalysis.props
new file mode 100644
index 0000000000000..44f93c37bfda9
--- /dev/null
+++ b/cmake/EnableVisualStudioCodeAnalysis.props
@@ -0,0 +1,12 @@
+
+
+
+ $(MSBuildThisFileDirectory)Sdl.ruleset
+
+ $(SolutionDir);$(MSBuildThisFileDirectory)
+ true
+
+
diff --git a/cmake/Sdl.ruleset b/cmake/Sdl.ruleset
new file mode 100644
index 0000000000000..e993ad8a210a1
--- /dev/null
+++ b/cmake/Sdl.ruleset
@@ -0,0 +1,308 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cmake/external/abseil-cpp.cmake b/cmake/external/abseil-cpp.cmake
new file mode 100644
index 0000000000000..98276ef4af4fc
--- /dev/null
+++ b/cmake/external/abseil-cpp.cmake
@@ -0,0 +1,29 @@
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+
+include(FetchContent)
+
+# Pass to build
+set(ABSL_PROPAGATE_CXX_STD 1)
+set(BUILD_TESTING 0)
+
+if(Patch_FOUND)
+ set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/Fix_Nvidia_Build_Break.patch)
+else()
+ set(ABSL_PATCH_COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/abseil/Fix_Nvidia_Build_Break.patch)
+endif()
+
+FetchContent_Declare(
+ abseil_cpp
+ PREFIX "${CMAKE_CURRENT_BINARY_DIR}/abseil-cpp"
+ BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/abseil-cpp"
+ URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.zip
+ PATCH_COMMAND ${ABSL_PATCH_COMMAND}
+)
+
+FetchContent_MakeAvailable(abseil_cpp)
+FetchContent_GetProperties(abseil_cpp SOURCE_DIR)
+
+
+
+
diff --git a/cmake/external/coremltools b/cmake/external/coremltools
deleted file mode 160000
index 523d5e03d86c2..0000000000000
--- a/cmake/external/coremltools
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 523d5e03d86c26267ee6bdf17dd20f6ce6bdadd7
diff --git a/cmake/external/dnnl.cmake b/cmake/external/dnnl.cmake
index 6a51a3d5dd51c..6770e66a295fe 100644
--- a/cmake/external/dnnl.cmake
+++ b/cmake/external/dnnl.cmake
@@ -1,8 +1,8 @@
include (ExternalProject)
-set(DNNL_URL https://github.com/oneapi-src/onednn)
+set(DNNL_URL https://github.com/oneapi-src/onednn.git)
# If DNNL_TAG is updated, check if MKLML_VERSION and platform.cmake.patch need to be updated.
-set(DNNL_TAG v2.3)
+set(DNNL_TAG v2.4.4)
if(WIN32)
set(DNNL_SHARED_LIB dnnl.dll)
diff --git a/cmake/external/emsdk b/cmake/external/emsdk
index a3d65c80d32c3..fc645b7626ebf 160000
--- a/cmake/external/emsdk
+++ b/cmake/external/emsdk
@@ -1 +1 @@
-Subproject commit a3d65c80d32c3e584b7aab41d516a0043b2a5e84
+Subproject commit fc645b7626ebf86530dbd82fbece74d457e7ae07
diff --git a/cmake/external/mimalloc b/cmake/external/mimalloc
index 2d54553b7a78c..f412df7a2b644 160000
--- a/cmake/external/mimalloc
+++ b/cmake/external/mimalloc
@@ -1 +1 @@
-Subproject commit 2d54553b7a78c7c35620b827e7e5ab2228ecb495
+Subproject commit f412df7a2b64421e1f1d61fde6055a6ea288e8f5
diff --git a/cmake/external/mimalloc.cmake b/cmake/external/mimalloc.cmake
index 77ca987b0c0b0..346e04f4d782b 100644
--- a/cmake/external/mimalloc.cmake
+++ b/cmake/external/mimalloc.cmake
@@ -1,15 +1,11 @@
set(mimalloc_root_dir ${PROJECT_SOURCE_DIR}/external/mimalloc)
-if(onnxruntime_USE_MIMALLOC_STL_ALLOCATOR)
- add_definitions(-DUSE_MIMALLOC_STL_ALLOCATOR) # used in ONNXRuntime
-endif()
-if(onnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR)
- add_definitions(-DUSE_MIMALLOC_ARENA_ALLOCATOR) # used in ONNXRuntime
-endif()
+add_definitions(-DUSE_MIMALLOC)
include_directories(${mimalloc_root_dir}/include)
option(MI_OVERRIDE "" OFF)
option(MI_BUILD_TESTS "" OFF)
+option(MI_DEBUG_FULL "" OFF)
add_subdirectory(${mimalloc_root_dir} EXCLUDE_FROM_ALL)
set_target_properties(mimalloc-static PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/cmake/external/onnx b/cmake/external/onnx
index be76ca7148396..850a81b0b7778 160000
--- a/cmake/external/onnx
+++ b/cmake/external/onnx
@@ -1 +1 @@
-Subproject commit be76ca7148396176784ba8733133b9fb1186ea0d
+Subproject commit 850a81b0b77786bf99ea90580242b084f86a6235
diff --git a/cmake/external/onnx-tensorrt b/cmake/external/onnx-tensorrt
index 1f416bb462689..4f54a1950e117 160000
--- a/cmake/external/onnx-tensorrt
+++ b/cmake/external/onnx-tensorrt
@@ -1 +1 @@
-Subproject commit 1f416bb462689f3ef9e3f1057a113d9c6aba6972
+Subproject commit 4f54a1950e1174dca490900eb7b07cc374f53d41
diff --git a/cmake/external/onnx_minimal.cmake b/cmake/external/onnx_minimal.cmake
index 33df1f5a31671..c42f431ea9920 100644
--- a/cmake/external/onnx_minimal.cmake
+++ b/cmake/external/onnx_minimal.cmake
@@ -31,10 +31,10 @@ else()
if(HAS_UNUSED_BUT_SET_VARIABLE)
target_compile_options(onnx_proto PRIVATE "-Wno-unused-but-set-variable")
- endif()
+ endif()
endif()
-# For reference, this would be the full ONNX source include. We only need data_type_utils.* in this build.
+# For reference, this would be the full ONNX source include. We only need data_type_utils in this build.
# file(GLOB_RECURSE onnx_src CONFIGURE_DEPENDS
# "${ONNX_SOURCE_ROOT}/onnx/*.h"
# "${ONNX_SOURCE_ROOT}/onnx/*.cc"
@@ -46,10 +46,11 @@ endif()
# "${ONNX_SOURCE_ROOT}/onnx/test/*"
# "${ONNX_SOURCE_ROOT}/onnx/cpp2py_export.cc"
# )
-# list(REMOVE_ITEM onnx_src ${onnx_exclude_src})
-file(GLOB onnx_src CONFIGURE_DEPENDS
-"${ONNX_SOURCE_ROOT}/onnx/common/common.h"
-"${ONNX_SOURCE_ROOT}/onnx/defs/data_type_utils.*"
+# list(REMOVE_ITEM onnx_src ${onnx_exclude_src})
+set(onnx_src
+ "${ONNX_SOURCE_ROOT}/onnx/common/common.h"
+ "${ONNX_SOURCE_ROOT}/onnx/defs/data_type_utils.h"
+ "${ONNX_SOURCE_ROOT}/onnx/defs/data_type_utils.cc"
)
add_library(onnx ${onnx_src})
@@ -75,7 +76,7 @@ if (WIN32)
/EHsc # exception handling - C++ may throw, extern "C" will not
)
endif()
-
+
target_compile_options(onnx_proto PRIVATE
/wd4244 # 'argument' conversion from 'google::protobuf::int64' to 'int', possible loss of data
)
diff --git a/cmake/external/protobuf b/cmake/external/protobuf
index 2dc747c574b68..0dab03ba7bc43 160000
--- a/cmake/external/protobuf
+++ b/cmake/external/protobuf
@@ -1 +1 @@
-Subproject commit 2dc747c574b68a808ea4699d26942c8132fe2b09
+Subproject commit 0dab03ba7bc438d7ba3eac2b2c1eb39ed520f928
diff --git a/cmake/external/tvm b/cmake/external/tvm
deleted file mode 160000
index 9ec2b92d180df..0000000000000
--- a/cmake/external/tvm
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 9ec2b92d180dff8877e402018b97baa574031b8b
diff --git a/cmake/external/tvm.cmake b/cmake/external/tvm.cmake
new file mode 100644
index 0000000000000..3f425a0938e2f
--- /dev/null
+++ b/cmake/external/tvm.cmake
@@ -0,0 +1,36 @@
+if (onnxruntime_USE_TVM)
+ message(STATUS "onnxruntime_USE_TVM: Fetch tvm for TVM EP")
+
+ FetchContent_Declare(
+ tvm
+ GIT_REPOSITORY https://github.com/apache/tvm.git
+ GIT_TAG ffd5f70370642c909222f9a4cae8400023dacbdc
+ )
+
+ FetchContent_GetProperties(tvm)
+ if(NOT tvm_POPULATED)
+ FetchContent_Populate(tvm)
+ file(CREATE_LINK ${tvm_BINARY_DIR} ${tvm_SOURCE_DIR}/build SYMBOLIC)
+ endif()
+
+ set(tvm_INCLUDE_DIRS ${tvm_SOURCE_DIR}/include)
+
+endif()
+
+if (onnxruntime_USE_NUPHAR)
+ message(STATUS "onnxruntime_USE_NUPHAR: Fetch onnxruntime-tvm for NUPHAR EP")
+
+ FetchContent_Declare(
+ tvm
+ GIT_REPOSITORY https://github.com/microsoft/onnxruntime-tvm.git
+ GIT_TAG 9ec2b92d180dff8877e402018b97baa574031b8b
+ )
+
+ FetchContent_GetProperties(tvm)
+ if(NOT tvm_POPULATED)
+ FetchContent_Populate(tvm)
+ endif()
+
+ set(tvm_INCLUDE_DIRS ${tvm_SOURCE_DIR}/include)
+
+endif()
\ No newline at end of file
diff --git a/cmake/external/zlib.cmake b/cmake/external/zlib.cmake
index 02014170157f0..b7fcd22c7d240 100644
--- a/cmake/external/zlib.cmake
+++ b/cmake/external/zlib.cmake
@@ -1,7 +1,7 @@
include (ExternalProject)
set(zlib_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/zlib_archive)
-set(ZLIB_URL https://github.com/madler/zlib)
+set(ZLIB_URL https://github.com/madler/zlib.git)
set(ZLIB_BUILD ${CMAKE_CURRENT_BINARY_DIR}/zlib/src/zlib)
set(ZLIB_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/zlib/install)
set(ZLIB_TAG 50893291621658f355bc5b4d450a8d06a563053d)
diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake
index 5b123ed1fff95..2331b21de7480 100644
--- a/cmake/onnxruntime.cmake
+++ b/cmake/onnxruntime.cmake
@@ -7,7 +7,7 @@ if(UNIX)
set(OUTPUT_STYLE xcode)
else()
set(OUTPUT_STYLE gcc)
- endif()
+ endif()
else()
set(SYMBOL_FILE ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime_dll.def)
set(OUTPUT_STYLE vc)
@@ -157,6 +157,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND onnxruntime_BUILD_JAVA)
endforeach()
endif()
+# This list is a reversed topological ordering of library dependencies.
+# Earlier entries may depend on later ones. Later ones should not depend on earlier ones.
set(onnxruntime_INTERNAL_LIBRARIES
onnxruntime_session
${onnxruntime_libs}
@@ -164,9 +166,9 @@ set(onnxruntime_INTERNAL_LIBRARIES
${PROVIDERS_ARMNN}
${PROVIDERS_COREML}
${PROVIDERS_DML}
- ${PROVIDERS_MIGRAPHX}
${PROVIDERS_NNAPI}
${PROVIDERS_NUPHAR}
+ ${PROVIDERS_TVM}
${PROVIDERS_RKNPU}
${PROVIDERS_ROCM}
${PROVIDERS_VITISAI}
@@ -174,10 +176,10 @@ set(onnxruntime_INTERNAL_LIBRARIES
${onnxruntime_winml}
onnxruntime_optimizer
onnxruntime_providers
- onnxruntime_util
${onnxruntime_tvm_libs}
onnxruntime_framework
onnxruntime_graph
+ onnxruntime_util
${ONNXRUNTIME_MLAS_LIBS}
onnxruntime_common
onnxruntime_flatbuffers
@@ -211,8 +213,39 @@ install(TARGETS onnxruntime
set_target_properties(onnxruntime PROPERTIES FOLDER "ONNXRuntime")
-if (WINDOWS_STORE)
- target_link_options(onnxruntime PRIVATE /DELAYLOAD:api-ms-win-core-libraryloader-l1-2-1.dll)
+if (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)
+ # Workaround STL bug https://github.com/microsoft/STL/issues/434#issuecomment-921321254
+ # Note that the workaround makes std::system_error crash before Windows 10
+
+ # The linker warns "LNK4199: /DELAYLOAD:api-ms-win-core-heapl2-1-0.dll ignored; no imports found from api-ms-win-core-heapl2-1-0.dll"
+ # when you're not using imports directly, even though the import exists in the STL and the DLL would have been linked without DELAYLOAD
+ target_link_options(onnxruntime PRIVATE /DELAYLOAD:api-ms-win-core-heapl2-1-0.dll /ignore:4199)
+endif()
+
+if (winml_is_inbox)
+ # Apply linking flags required by inbox static analysis tools
+ target_link_options(onnxruntime PRIVATE ${os_component_link_flags_list})
+ # Link *_x64/*_arm64 DLLs for the ARM64X forwarder
+ function(duplicate_shared_library target new_target)
+ get_target_property(sources ${target} SOURCES)
+ get_target_property(compile_definitions ${target} COMPILE_DEFINITIONS)
+ get_target_property(compile_options ${target} COMPILE_OPTIONS)
+ get_target_property(include_directories ${target} INCLUDE_DIRECTORIES)
+ get_target_property(link_libraries ${target} LINK_LIBRARIES)
+ get_target_property(link_flags ${target} LINK_FLAGS)
+ get_target_property(link_options ${target} LINK_OPTIONS)
+ add_library(${new_target} SHARED ${sources})
+ add_dependencies(${target} ${new_target})
+ target_compile_definitions(${new_target} PRIVATE ${compile_definitions})
+ target_compile_options(${new_target} PRIVATE ${compile_options})
+ target_include_directories(${new_target} PRIVATE ${include_directories})
+ target_link_libraries(${new_target} PRIVATE ${link_libraries})
+ set_property(TARGET ${new_target} PROPERTY LINK_FLAGS "${link_flags}")
+ target_link_options(${new_target} PRIVATE ${link_options})
+ endfunction()
+ if (WAI_ARCH STREQUAL x64 OR WAI_ARCH STREQUAL arm64)
+ duplicate_shared_library(onnxruntime onnxruntime_${WAI_ARCH})
+ endif()
endif()
# Assemble the Apple static framework (iOS and macOS)
diff --git a/cmake/onnxruntime_codegen.cmake b/cmake/onnxruntime_codegen_tvm.cmake
similarity index 100%
rename from cmake/onnxruntime_codegen.cmake
rename to cmake/onnxruntime_codegen_tvm.cmake
diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake
index 8425e70df0dbe..d32db62ca56d0 100644
--- a/cmake/onnxruntime_common.cmake
+++ b/cmake/onnxruntime_common.cmake
@@ -75,6 +75,14 @@ file(GLOB onnxruntime_common_src CONFIGURE_DEPENDS
${onnxruntime_common_src_patterns}
)
+# Remove new/delete intercept. To deal with memory leaks
+# Use either non-mimalloc build OR use mimalloc built-in features.
+if(WIN32 AND onnxruntime_USE_MIMALLOC)
+ list(REMOVE_ITEM onnxruntime_common_src
+ "${ONNXRUNTIME_ROOT}/core/platform/windows/debug_alloc.cc"
+ "${ONNXRUNTIME_ROOT}/core/platform/windows/debug_alloc.h")
+endif()
+
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_common_src})
onnxruntime_add_static_library(onnxruntime_common ${onnxruntime_common_src})
@@ -83,20 +91,25 @@ if (onnxruntime_USE_TELEMETRY)
set_target_properties(onnxruntime_common PROPERTIES COMPILE_FLAGS "/FI${ONNXRUNTIME_INCLUDE_DIR}/core/platform/windows/TraceLoggingConfigPrivate.h")
endif()
-if (onnxruntime_USE_MIMALLOC_STL_ALLOCATOR OR onnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR)
+if (onnxruntime_USE_MIMALLOC)
+ if(NOT WIN32)
+ message(FATAL_ERROR "Currently do not support MIMALLOC in GPU builds")
+ endif()
if(onnxruntime_USE_CUDA OR onnxruntime_USE_OPENVINO)
- message(WARNING "Ignoring directive to use mimalloc on unimplemented targets")
- elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
- # Some of the non-windows targets see strange runtime failures
- message(WARNING "Ignoring request to link to mimalloc - only windows supported")
+ message(WARNING "Currently do not support MIMALLOC in GPU builds")
else()
include(external/mimalloc.cmake)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES mimalloc-static)
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES mimalloc-static)
- target_link_libraries(onnxruntime_common mimalloc-static)
+ set(onnxruntime_mimalloc_shim_src "${ONNXRUNTIME_ROOT}/core/platform/windows/mimalloc/mimalloc_overloads.cc")
+ add_library(onnxruntime_mimalloc_shim ${onnxruntime_mimalloc_shim_src})
+ target_link_libraries(onnxruntime_mimalloc_shim mimalloc-static)
+ target_link_libraries(onnxruntime_common onnxruntime_mimalloc_shim)
endif()
endif()
+include(external/abseil-cpp.cmake)
+
onnxruntime_add_include_to_target(onnxruntime_common date_interface wil)
target_include_directories(onnxruntime_common
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS}
@@ -110,20 +123,12 @@ if(NOT WIN32)
target_include_directories(onnxruntime_common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external/nsync/public")
endif()
-if(NOT onnxruntime_USE_OPENMP)
- target_compile_definitions(onnxruntime_common PUBLIC EIGEN_USE_THREADS)
-endif()
add_dependencies(onnxruntime_common ${onnxruntime_EXTERNAL_DEPENDENCIES})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/common DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
set_target_properties(onnxruntime_common PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(onnxruntime_common PROPERTIES FOLDER "ONNXRuntime")
-if(WIN32)
- # Add Code Analysis properties to enable C++ Core checks. Have to do it via a props file include.
- set_target_properties(onnxruntime_common PROPERTIES VS_USER_PROPS ${PROJECT_SOURCE_DIR}/EnableVisualStudioCodeAnalysis.props)
-endif()
-
# check if we need to link against librt on Linux
include(CheckLibraryExists)
include(CheckFunctionExists)
@@ -201,7 +206,7 @@ endif()
if (ARM64 OR ARM OR X86 OR X64 OR X86_64)
- if(WINDOWS_STORE OR (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib) OR ((ARM64 OR ARM) AND MSVC))
+ if((WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib) OR ((ARM64 OR ARM) AND MSVC))
# msvc compiler report syntax error with cpuinfo arm source files
# and cpuinfo does not have code for getting arm uarch info under windows
else()
diff --git a/cmake/onnxruntime_config.h.in b/cmake/onnxruntime_config.h.in
index e31a1ee7665d1..d7cf7fa75cc77 100644
--- a/cmake/onnxruntime_config.h.in
+++ b/cmake/onnxruntime_config.h.in
@@ -19,4 +19,5 @@
#cmakedefine HAS_MAYBE_UNINITIALIZED
#cmakedefine HAS_DEPRECATED_DECLARATIONS
#cmakedefine HAS_FORMAT_TRUNCATION
+#cmakedefine HAS_BITWISE_INSTEAD_OF_LOGICAL
#cmakedefine ORT_VERSION "@ORT_VERSION@"
diff --git a/cmake/onnxruntime_csharp.cmake b/cmake/onnxruntime_csharp.cmake
index 9db3cff3ef4d9..f0eecab652d36 100644
--- a/cmake/onnxruntime_csharp.cmake
+++ b/cmake/onnxruntime_csharp.cmake
@@ -34,6 +34,10 @@ if (onnxruntime_USE_NUPHAR)
STRING(APPEND CSHARP_PREPROCESSOR_DEFINES "USE_NUPHAR;")
endif()
+if (onnxruntime_USE_TVM)
+ STRING(APPEND CSHARP_PREPROCESSOR_DEFINES "USE_TVM,")
+endif()
+
if (onnxruntime_USE_OPENVINO)
STRING(APPEND CSHARP_PREPROCESSOR_DEFINES "USE_OPENVINO;")
endif()
diff --git a/cmake/onnxruntime_eager.cmake b/cmake/onnxruntime_eager.cmake
index 88d05a2f14347..d8a1e8322775a 100644
--- a/cmake/onnxruntime_eager.cmake
+++ b/cmake/onnxruntime_eager.cmake
@@ -8,7 +8,7 @@ file(GLOB onnxruntime_eager_srcs CONFIGURE_DEPENDS
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_eager_srcs})
-add_library(onnxruntime_eager ${onnxruntime_eager_srcs})
+onnxruntime_add_static_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 /wd4458")
set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_customops.g.cpp" PROPERTIES COMPILE_FLAGS "/wd4100")
diff --git a/cmake/onnxruntime_flatbuffers.cmake b/cmake/onnxruntime_flatbuffers.cmake
index bcb196bcd8cd9..49302e92f5a66 100644
--- a/cmake/onnxruntime_flatbuffers.cmake
+++ b/cmake/onnxruntime_flatbuffers.cmake
@@ -21,16 +21,3 @@ set_target_properties(onnxruntime_flatbuffers PROPERTIES FOLDER "ONNXRuntime")
if (FLATBUFFERS_BUILD_FLATC)
add_dependencies(onnxruntime_flatbuffers flatc)
endif()
-
-if (WINDOWS_STORE)
- function(target_force_include target scope file)
- if (MSVC)
- target_compile_options(${target} ${scope} "/FI${file}")
- else()
- target_compile_options(${target} ${scope} -include "${file}")
- endif()
- endfunction()
-
- target_force_include(flatbuffers PRIVATE uwp_stubs.h)
- target_force_include(flatc PRIVATE uwp_stubs.h)
-endif()
diff --git a/cmake/onnxruntime_framework.cmake b/cmake/onnxruntime_framework.cmake
index dee3ff2bdae34..5b6681fd20daa 100644
--- a/cmake/onnxruntime_framework.cmake
+++ b/cmake/onnxruntime_framework.cmake
@@ -53,7 +53,7 @@ if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
onnxruntime_add_include_to_target(onnxruntime_framework Python::Module)
target_include_directories(onnxruntime_framework PRIVATE ${PROJECT_SOURCE_DIR}/external/dlpack/include)
endif()
- if (onnxruntime_USE_NCCL OR onnxruntime_USE_MPI)
+ if (onnxruntime_USE_NCCL OR onnxruntime_USE_MPI)
target_include_directories(onnxruntime_framework PUBLIC ${MPI_CXX_INCLUDE_DIRS})
endif()
endif()
@@ -63,6 +63,15 @@ if (onnxruntime_ENABLE_TRAINING)
target_include_directories(onnxruntime_framework PRIVATE ${DLPACK_INCLUDE_DIR})
endif()
onnxruntime_add_include_to_target(onnxruntime_framework onnxruntime_common onnx onnx_proto ${PROTOBUF_LIB} flatbuffers)
+
+if (onnxruntime_USE_MIMALLOC)
+ target_link_libraries(onnxruntime_framework mimalloc-static)
+endif()
+
+if (onnxruntime_BUILD_WEBASSEMBLY)
+ target_link_libraries(onnxruntime_framework absl::raw_hash_set absl::hash absl::city)
+endif()
+
set_target_properties(onnxruntime_framework PROPERTIES FOLDER "ONNXRuntime")
# need onnx to build to create headers that this project includes
add_dependencies(onnxruntime_framework ${onnxruntime_EXTERNAL_DEPENDENCIES})
@@ -86,4 +95,8 @@ if (onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS_ENABLE_DUMP_TO_SQLDB)
target_compile_definitions(onnxruntime_framework PRIVATE DEBUG_NODE_INPUTS_OUTPUTS_ENABLE_DUMP_TO_SQLDB)
endif()
+if (WIN32)
+ target_compile_definitions(onnxruntime_framework PRIVATE _SCL_SECURE_NO_WARNINGS)
+endif()
+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/framework DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
diff --git a/cmake/onnxruntime_graph.cmake b/cmake/onnxruntime_graph.cmake
index dde1fbd138544..d98cee372c5aa 100644
--- a/cmake/onnxruntime_graph.cmake
+++ b/cmake/onnxruntime_graph.cmake
@@ -17,6 +17,7 @@ if (onnxruntime_MINIMAL_BUILD)
"${ONNXRUNTIME_ROOT}/core/graph/schema_registry.cc"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*defs.h"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*defs.cc"
+ "${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/onnx_deprecated_operators.cc"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/onnx_function_util.h"
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/onnx_function_util.cc"
)
@@ -120,8 +121,5 @@ if (WIN32)
target_compile_options(onnxruntime_graph PRIVATE
/EHsc # exception handling - C++ may throw, extern "C" will not
)
- endif()
-
- # Add Code Analysis properties to enable C++ Core checks. Have to do it via a props file include.
- set_target_properties(onnxruntime_graph PROPERTIES VS_USER_PROPS ${PROJECT_SOURCE_DIR}/EnableVisualStudioCodeAnalysis.props)
+ endif()
endif()
diff --git a/cmake/onnxruntime_java.cmake b/cmake/onnxruntime_java.cmake
index 8057fa3ada7d1..d7b47f699a193 100644
--- a/cmake/onnxruntime_java.cmake
+++ b/cmake/onnxruntime_java.cmake
@@ -62,7 +62,6 @@ file(GLOB onnxruntime4j_native_src
onnxruntime_add_shared_library_module(onnxruntime4j_jni ${onnxruntime4j_native_src})
set_property(TARGET onnxruntime4j_jni PROPERTY CXX_STANDARD 11)
-
# depend on java sources. if they change, the JNI should recompile
add_dependencies(onnxruntime4j_jni onnxruntime4j)
onnxruntime_add_include_to_target(onnxruntime4j_jni onnxruntime_session)
@@ -95,6 +94,8 @@ if(APPLE)
endif()
if(JNI_ARCH STREQUAL "x86_64")
set(JNI_ARCH x64)
+ elseif(JNI_ARCH STREQUAL "arm64")
+ set(JNI_ARCH aarch64)
endif()
elseif (CMAKE_SYSTEM_NAME STREQUAL "Android")
set(JNI_ARCH ${ANDROID_ABI})
diff --git a/cmake/onnxruntime_mlas.cmake b/cmake/onnxruntime_mlas.cmake
index b13f13de8d0bd..0de18d3e6d3e9 100644
--- a/cmake/onnxruntime_mlas.cmake
+++ b/cmake/onnxruntime_mlas.cmake
@@ -47,7 +47,13 @@ function(setup_mlas_source_for_windows)
)
set(mlas_platform_preprocess_srcs
- ${MLAS_SRC_DIR}/arm64/DepthwiseConvsymKernelNeon.asm
+ ${MLAS_SRC_DIR}/arm64/ConvSymS8KernelDot.asm
+ ${MLAS_SRC_DIR}/arm64/ConvSymS8KernelDotLd64.asm
+ ${MLAS_SRC_DIR}/arm64/ConvSymU8KernelDot.asm
+ ${MLAS_SRC_DIR}/arm64/ConvSymS8KernelNeon.asm
+ ${MLAS_SRC_DIR}/arm64/ConvSymU8KernelNeon.asm
+ ${MLAS_SRC_DIR}/arm64/DepthwiseQConvSymS8KernelNeon.asm
+ ${MLAS_SRC_DIR}/arm64/DepthwiseQConvSymU8KernelNeon.asm
${MLAS_SRC_DIR}/arm64/DepthwiseQConvKernelSize9Neon.asm
${MLAS_SRC_DIR}/arm64/QgemmU8X8KernelNeon.asm
${MLAS_SRC_DIR}/arm64/QgemmS8S8KernelNeon.asm
@@ -55,6 +61,9 @@ function(setup_mlas_source_for_windows)
${MLAS_SRC_DIR}/arm64/QgemmS8S8KernelSdot.asm
${MLAS_SRC_DIR}/arm64/SgemmKernelNeon.asm
${MLAS_SRC_DIR}/arm64/SgemvKernelNeon.asm
+ ${MLAS_SRC_DIR}/arm64/SymQgemmS8KernelNeon.asm
+ ${MLAS_SRC_DIR}/arm64/SymQgemmS8KernelSDot.asm
+ ${MLAS_SRC_DIR}/arm64/SymQgemmS8KernelSDotLd64.asm
)
else()
target_sources(onnxruntime_mlas PRIVATE
@@ -174,7 +183,7 @@ if (onnxruntime_BUILD_WEBASSEMBLY)
)
else()
file(GLOB_RECURSE mlas_platform_srcs
- "${MLAS_SRC_DIR}/wasm/*.cpp"
+ "${MLAS_SRC_DIR}/scalar/*.cpp"
)
endif()
target_sources(onnxruntime_mlas PRIVATE ${mlas_platform_srcs})
@@ -268,7 +277,13 @@ else()
if(ARM64 AND MLAS_SOURCE_IS_NOT_SET )
enable_language(ASM)
set(mlas_platform_srcs
- ${MLAS_SRC_DIR}/aarch64/DepthwiseConvSymKernelNeon.S
+ ${MLAS_SRC_DIR}/aarch64/ConvSymS8KernelDot.S
+ ${MLAS_SRC_DIR}/aarch64/ConvSymS8KernelDotLd64.S
+ ${MLAS_SRC_DIR}/aarch64/ConvSymU8KernelDot.S
+ ${MLAS_SRC_DIR}/aarch64/ConvSymS8KernelNeon.S
+ ${MLAS_SRC_DIR}/aarch64/ConvSymU8KernelNeon.S
+ ${MLAS_SRC_DIR}/aarch64/DepthwiseQConvSymS8KernelNeon.S
+ ${MLAS_SRC_DIR}/aarch64/DepthwiseQConvSymU8KernelNeon.S
${MLAS_SRC_DIR}/aarch64/DepthwiseQConvKernelSize9Neon.S
${MLAS_SRC_DIR}/aarch64/QgemmU8X8KernelNeon.S
${MLAS_SRC_DIR}/aarch64/QgemmS8S8KernelNeon.S
@@ -276,6 +291,9 @@ else()
${MLAS_SRC_DIR}/aarch64/QgemmS8S8KernelSdot.S
${MLAS_SRC_DIR}/aarch64/SgemmKernelNeon.S
${MLAS_SRC_DIR}/aarch64/SgemvKernelNeon.S
+ ${MLAS_SRC_DIR}/aarch64/SymQgemmS8KernelNeon.S
+ ${MLAS_SRC_DIR}/aarch64/SymQgemmS8KernelSdot.S
+ ${MLAS_SRC_DIR}/aarch64/SymQgemmS8KernelSdotLd64.S
${MLAS_SRC_DIR}/qgemm_kernel_neon.cpp
${MLAS_SRC_DIR}/qgemm_kernel_udot.cpp
${MLAS_SRC_DIR}/qgemm_kernel_sdot.cpp
@@ -294,8 +312,19 @@ else()
${MLAS_SRC_DIR}/power/SgemmKernelPower.cpp
${MLAS_SRC_DIR}/dgemm.cpp
${MLAS_SRC_DIR}/power/DgemmKernelPower.cpp
+ ${MLAS_SRC_DIR}/power/QuantizePower.cpp
)
set_source_files_properties(${MLAS_SRC_DIR}/power/SgemmKernelPower.cpp PROPERTIES COMPILE_FLAGS "-DSINGLE")
+
+ check_cxx_compiler_flag("-mcpu=power9" HAS_POWER9)
+ if (HAS_POWER9)
+ set(mlas_platform_srcs
+ ${mlas_platform_srcs}
+ ${MLAS_SRC_DIR}/power/QuantizePowerVSX.cpp
+ )
+ set_source_files_properties(${MLAS_SRC_DIR}/power/QuantizePowerVSX.cpp PROPERTIES COMPILE_FLAGS "-mcpu=power9")
+ endif()
+
check_cxx_compiler_flag("-mcpu=power10" HAS_POWER10)
if(HAS_POWER10)
set(CMAKE_REQUIRED_FLAGS "-mcpu=power10")
@@ -320,19 +349,22 @@ else()
)
if (HAS_P10_RUNTIME)
set_source_files_properties(${MLAS_SRC_DIR}/platform.cpp PROPERTIES COMPILE_FLAGS "-DPOWER10")
+ set_source_files_properties(${MLAS_SRC_DIR}/qgemm.cpp PROPERTIES COMPILE_FLAGS "-DPOWER10")
endif()
set(mlas_platform_srcs_power10
${MLAS_SRC_DIR}/power/SgemmKernelPOWER10.cpp
${MLAS_SRC_DIR}/power/DgemmKernelPOWER10.cpp
+ ${MLAS_SRC_DIR}/power/qgemm_kernel_power10.cpp
)
set_source_files_properties(${MLAS_SRC_DIR}/power/SgemmKernelPOWER10.cpp PROPERTIES COMPILE_FLAGS "-O2 -mcpu=power10 -DSINGLE")
set_source_files_properties(${MLAS_SRC_DIR}/power/DgemmKernelPOWER10.cpp PROPERTIES COMPILE_FLAGS "-O2 -mcpu=power10")
+ set_source_files_properties(${MLAS_SRC_DIR}/power/qgemm_kernel_power10.cpp PROPERTIES COMPILE_FLAGS "-O3 -mcpu=power10")
set(mlas_platform_srcs
${mlas_platform_srcs}
${mlas_platform_srcs_power10}
)
endif()
- endif()
+ endif()
if(NOT ONNXRUNTIME_MLAS_MULTI_ARCH)
set(MLAS_SOURCE_IS_NOT_SET 0)
endif()
@@ -355,6 +387,16 @@ else()
${mlas_platform_srcs_sse2}
${mlas_platform_srcs_avx}
)
+
+ # In r23, NDK remove __x86.get_pc_thunk.* from libatomic. Add our own
+ # implementation to avoid external dependency.
+ if(ANDROID)
+ set(mlas_platform_srcs
+ ${mlas_platform_srcs}
+ ${MLAS_SRC_DIR}/x86/x86.get_pc_thunk.S
+ )
+ endif()
+
if(NOT ONNXRUNTIME_MLAS_MULTI_ARCH)
set(MLAS_SOURCE_IS_NOT_SET 0)
endif()
@@ -448,9 +490,12 @@ else()
list(APPEND ONNXRUNTIME_MLAS_LIBS onnxruntime_mlas_x86_64)
set(mlas_platform_srcs )
else()
- set(MLAS_SOURCE_IS_NOT_SET 1)
+ set(MLAS_SOURCE_IS_NOT_SET 0)
endif()
-
+ endif()
+ if(NOT ONNXRUNTIME_MLAS_MULTI_ARCH AND MLAS_SOURCE_IS_NOT_SET)
+ file(GLOB_RECURSE mlas_platform_srcs
+ "${MLAS_SRC_DIR}/scalar/*.cpp")
endif()
target_sources(onnxruntime_mlas PRIVATE ${mlas_platform_srcs})
endif()
@@ -461,4 +506,7 @@ endforeach()
set_target_properties(onnxruntime_mlas PROPERTIES FOLDER "ONNXRuntime")
if (WIN32)
target_compile_options(onnxruntime_mlas PRIVATE "/wd6385" "/wd4127")
+ if (onnxruntime_ENABLE_STATIC_ANALYSIS)
+ target_compile_options(onnxruntime_mlas PRIVATE "/analyze:stacksize 131072")
+ endif()
endif()
diff --git a/cmake/onnxruntime_optimizer.cmake b/cmake/onnxruntime_optimizer.cmake
index 9afa2c2e486e1..d86ffa0c105f0 100644
--- a/cmake/onnxruntime_optimizer.cmake
+++ b/cmake/onnxruntime_optimizer.cmake
@@ -11,16 +11,45 @@ if (onnxruntime_MINIMAL_BUILD)
"${ONNXRUNTIME_ROOT}/core/optimizer/graph_transformer.cc"
)
- if (onnxruntime_ENABLE_ORT_FORMAT_RUNTIME_GRAPH_OPTIMIZATION)
+ if (onnxruntime_EXTENDED_MINIMAL_BUILD)
list(APPEND onnxruntime_optimizer_src_patterns
- "${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.h"
- "${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.cc"
- "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_util.h"
+ "${ONNXRUNTIME_INCLUDE_DIR}/core/optimizer/graph_transformer_utils.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/conv_activation_fusion.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/conv_activation_fusion.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/graph_transformer_utils.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/initializer.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/initializer.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/nhwc_transformer.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/nhwc_transformer.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_final_cleanup.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_final_cleanup.h"
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_util.cc"
- "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.h"
- "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.cc"
- "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.h"
- "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_util.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/qdq_actions.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/qdq_selector_action_transformer.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/qdq_selector_action_transformer.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/qdq_selectors.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/qdq_selectors.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/shared/utils.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/shared/utils.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/actions.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/actions.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/helpers.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/helpers.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/helpers.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/helpers.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/selector_action_transformer_apply_contexts.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/selector_action_transformer.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/selector_action_transformer.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/optimizer_api_impl.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/optimizer_api.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/optimizer_utils.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/ort_transpose_optimizer.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/ort_transpose_optimizer.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/transpose_optimizer.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/utils.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/utils.h"
)
endif()
else()
@@ -32,18 +61,13 @@ else()
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/*.cc"
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.h"
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/*.cc"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/shared/utils.h"
+ "${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/selectors_actions/shared/utils.cc"
"${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.h"
"${ONNXRUNTIME_ROOT}/core/optimizer/selectors_actions/*.cc"
"${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/*.h"
"${ONNXRUNTIME_ROOT}/core/optimizer/transpose_optimizer/*.cc"
)
-
- if (onnxruntime_ENABLE_ORT_FORMAT_RUNTIME_GRAPH_OPTIMIZATION)
- list(APPEND onnxruntime_optimizer_src_patterns
- "${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.h"
- "${ONNXRUNTIME_ROOT}/core/optimizer/ort_format_runtime_optimization/utils.cc"
- )
- endif()
endif()
if (onnxruntime_ENABLE_TRAINING)
diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake
index 61ae5d785cb36..cefaab16dce65 100644
--- a/cmake/onnxruntime_providers.cmake
+++ b/cmake/onnxruntime_providers.cmake
@@ -1,6 +1,64 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
+# Reduced ops build helpers
+
+# In a reduced ops build, the reduction is performed by updating source files.
+# Rather than modifying the source files directly, updated versions will be
+# saved to another location in the build directory: ${op_reduction_root}.
+set(op_reduction_root "${CMAKE_BINARY_DIR}/op_reduction.generated")
+
+# This helper function replaces the relevant original source files with their
+# updated, reduced ops versions in `all_srcs`.
+function(substitute_op_reduction_srcs all_srcs)
+ # files that are potentially updated in a reduced ops build
+ set(original_srcs
+ "${ONNXRUNTIME_ROOT}/contrib_ops/cpu/cpu_contrib_kernels.cc"
+ "${ONNXRUNTIME_ROOT}/contrib_ops/cuda/cuda_contrib_kernels.cc"
+ "${ONNXRUNTIME_ROOT}/core/providers/cpu/cpu_execution_provider.cc"
+ "${ONNXRUNTIME_ROOT}/core/providers/cuda/cuda_execution_provider.cc"
+ "${ONNXRUNTIME_ROOT}/core/providers/op_kernel_type_control_overrides.inc"
+ "${ORTTRAINING_SOURCE_DIR}/training_ops/cpu/cpu_training_kernels.cc"
+ "${ORTTRAINING_SOURCE_DIR}/training_ops/cuda/cuda_training_kernels.cc"
+ )
+
+ set(replacement_srcs)
+
+ foreach(original_src ${original_srcs})
+ string(FIND "${${all_srcs}}" "${original_src}" idx)
+ if(idx EQUAL "-1")
+ continue()
+ endif()
+
+ file(RELATIVE_PATH src_relative_path "${REPO_ROOT}" "${original_src}")
+ set(replacement_src "${op_reduction_root}/${src_relative_path}")
+
+ message("File '${original_src}' substituted with reduced op version '${replacement_src}'.")
+
+ string(REPLACE "${original_src}" "${replacement_src}" ${all_srcs} "${${all_srcs}}")
+
+ list(APPEND replacement_srcs "${replacement_src}")
+ endforeach()
+
+ if(replacement_srcs)
+ source_group(TREE "${op_reduction_root}" PREFIX "op_reduction.generated" FILES ${replacement_srcs})
+ endif()
+
+ set(${all_srcs} "${${all_srcs}}" PARENT_SCOPE)
+endfunction()
+
+# This helper function adds reduced ops build-specific include directories to
+# `target`.
+function(add_op_reduction_include_dirs target)
+ set(op_reduction_include_dirs "${op_reduction_root}/onnxruntime")
+ if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
+ list(APPEND op_reduction_include_dirs "${op_reduction_root}/orttraining")
+ endif()
+ # add include directories BEFORE so they are searched first, giving op reduction file paths precedence
+ target_include_directories(${target} BEFORE PRIVATE ${op_reduction_include_dirs})
+endfunction()
+
+
file(GLOB_RECURSE onnxruntime_providers_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/cpu/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/cpu/*.cc"
@@ -45,7 +103,6 @@ file(GLOB_RECURSE onnxruntime_rocm_generated_contrib_ops_cu_srcs CONFIGURE_DEPEN
"${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime/contrib_ops/rocm/*.cuh"
)
-
file(GLOB onnxruntime_providers_common_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/*.cc"
@@ -92,6 +149,10 @@ endif()
if(onnxruntime_USE_ROCM)
set(PROVIDERS_ROCM onnxruntime_providers_rocm)
endif()
+if (onnxruntime_USE_TVM)
+ set(PROVIDERS_TVM onnxruntime_providers_tvm)
+endif()
+
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_common_srcs} ${onnxruntime_providers_srcs})
@@ -167,7 +228,17 @@ if (onnxruntime_ENABLE_TRAINING)
list(APPEND onnxruntime_providers_src ${onnxruntime_providers_dlpack_srcs})
endif()
+if (onnxruntime_REDUCED_OPS_BUILD)
+ substitute_op_reduction_srcs(onnxruntime_providers_src)
+endif()
onnxruntime_add_static_library(onnxruntime_providers ${onnxruntime_providers_src})
+if (onnxruntime_REDUCED_OPS_BUILD)
+ add_op_reduction_include_dirs(onnxruntime_providers)
+endif()
+
+if (HAS_BITWISE_INSTEAD_OF_LOGICAL)
+ target_compile_options(onnxruntime_providers PRIVATE "-Wno-bitwise-instead-of-logical")
+endif()
if (MSVC)
target_compile_options(onnxruntime_providers PRIVATE "/bigobj")
@@ -314,7 +385,13 @@ if (onnxruntime_USE_CUDA)
list(APPEND onnxruntime_providers_cuda_src ${onnxruntime_cuda_training_ops_cc_srcs} ${onnxruntime_cuda_training_ops_cu_srcs})
endif()
+ if (onnxruntime_REDUCED_OPS_BUILD)
+ substitute_op_reduction_srcs(onnxruntime_providers_cuda_src)
+ endif()
onnxruntime_add_shared_library_module(onnxruntime_providers_cuda ${onnxruntime_providers_cuda_src})
+ if (onnxruntime_REDUCED_OPS_BUILD)
+ add_op_reduction_include_dirs(onnxruntime_providers_cuda)
+ endif()
#target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$:SHELL:-Xcompiler \"/analyze:stacksize 131072\">")
if (HAS_GUARD_CF)
@@ -353,7 +430,7 @@ if (onnxruntime_USE_CUDA)
endif()
add_dependencies(onnxruntime_providers_cuda onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES} ${onnxruntime_tvm_dependencies})
- target_link_libraries(onnxruntime_providers_cuda PRIVATE cublas cudnn curand cufft ${ONNXRUNTIME_PROVIDERS_SHARED})
+ target_link_libraries(onnxruntime_providers_cuda PRIVATE cublas cudnn curand cufft absl::raw_hash_set absl::hash absl::city absl::low_level_hash absl::throw_delegate ${ONNXRUNTIME_PROVIDERS_SHARED})
target_include_directories(onnxruntime_providers_cuda PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${onnxruntime_CUDNN_HOME}/include ${eigen_INCLUDE_DIRS} ${TVM_INCLUDES} PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
# ${CMAKE_CURRENT_BINARY_DIR} is so that #include "onnxruntime_config.h" inside tensor_shape.h is found
set_target_properties(onnxruntime_providers_cuda PROPERTIES LINKER_LANGUAGE CUDA)
@@ -388,7 +465,7 @@ if (onnxruntime_USE_CUDA)
if (WIN32)
# disable a warning from the CUDA headers about unreferenced local functions
#target_compile_options(onnxruntime_providers_cuda PRIVATE /wd4505)
- if (onnxruntime_USE_TVM)
+ if (onnxruntime_USE_NUPHAR_TVM)
target_compile_options(onnxruntime_providers_cuda PRIVATE ${DISABLED_WARNINGS_FOR_TVM})
endif()
set(onnxruntime_providers_cuda_static_library_flags
@@ -428,11 +505,15 @@ if (onnxruntime_USE_DNNL)
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_dnnl_cc_srcs})
onnxruntime_add_shared_library_module(onnxruntime_providers_dnnl ${onnxruntime_providers_dnnl_cc_srcs})
target_link_directories(onnxruntime_providers_dnnl PRIVATE ${DNNL_LIB_DIR})
+ if (MSVC AND onnxruntime_ENABLE_STATIC_ANALYSIS)
+ # dnnl_convgrad.cc(47,0): Warning C6262: Function uses '38816' bytes of stack: exceeds /analyze:stacksize '16384'. Consider moving some data to heap.
+ target_compile_options(onnxruntime_providers_dnnl PRIVATE "/analyze:stacksize 131072")
+ endif()
add_dependencies(onnxruntime_providers_dnnl onnxruntime_providers_shared project_dnnl ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnxruntime_providers_dnnl PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} ${DNNL_INCLUDE_DIR} ${DNNL_OCL_INCLUDE_DIR})
# ${CMAKE_CURRENT_BINARY_DIR} is so that #include "onnxruntime_config.h" inside tensor_shape.h is found
- target_link_libraries(onnxruntime_providers_dnnl PRIVATE dnnl ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11)
+ target_link_libraries(onnxruntime_providers_dnnl PRIVATE dnnl ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 absl::hash absl::raw_hash_set)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/providers/dnnl DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core/providers)
set_target_properties(onnxruntime_providers_dnnl PROPERTIES FOLDER "ONNXRuntime")
set_target_properties(onnxruntime_providers_dnnl PROPERTIES LINKER_LANGUAGE CXX)
@@ -477,13 +558,13 @@ if (onnxruntime_USE_TENSORRT)
if (WIN32)
add_definitions(-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING=1)
set(OLD_CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS})
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996 /wd4244 /wd4267 /wd4099 /wd4551 /wd4505 /wd4515 /wd4706 /wd4456 /wd4324 /wd4701 /wd4804 /wd4702 /wd4458 /wd4703")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4099 /wd4551 /wd4505 /wd4515 /wd4706 /wd4456 /wd4324 /wd4701 /wd4804 /wd4702 /wd4458 /wd4703")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4805")
endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -include algorithm")
set(PROTOBUF_LIBRARY libprotobuf)
- set(DISABLED_WARNINGS_FOR_TRT /wd4267 /wd4244 /wd4996 /wd4456)
+ set(DISABLED_WARNINGS_FOR_TRT /wd4456)
endif()
if ( CMAKE_COMPILER_IS_GNUCC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-missing-field-initializers")
@@ -519,7 +600,7 @@ if (onnxruntime_USE_TENSORRT)
onnxruntime_add_shared_library_module(onnxruntime_providers_tensorrt ${onnxruntime_providers_tensorrt_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_tensorrt onnxruntime_common onnx flatbuffers)
add_dependencies(onnxruntime_providers_tensorrt onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
- target_link_libraries(onnxruntime_providers_tensorrt PRIVATE ${onnxparser_link_libs} ${trt_link_libs} cudart ${ONNXRUNTIME_PROVIDERS_SHARED} ${PROTOBUF_LIB} flatbuffers)
+ target_link_libraries(onnxruntime_providers_tensorrt PRIVATE ${onnxparser_link_libs} ${trt_link_libs} cudart ${ONNXRUNTIME_PROVIDERS_SHARED} ${PROTOBUF_LIB} flatbuffers absl::hash absl::raw_hash_set)
target_include_directories(onnxruntime_providers_tensorrt PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${onnxruntime_CUDNN_HOME}/include ${eigen_INCLUDE_DIRS} PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
# ${CMAKE_CURRENT_BINARY_DIR} is so that #include "onnxruntime_config.h" inside tensor_shape.h is found
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/providers/tensorrt DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core/providers)
@@ -528,12 +609,15 @@ if (onnxruntime_USE_TENSORRT)
target_compile_definitions(onnxruntime_providers_tensorrt PRIVATE ONNXIFI_BUILD_LIBRARY=1)
target_compile_options(onnxruntime_providers_tensorrt PRIVATE ${DISABLED_WARNINGS_FOR_TRT})
if (WIN32)
- target_compile_options(onnxruntime_providers_tensorrt INTERFACE /wd4267 /wd4244 /wd4996 /wd4456)
+ target_compile_options(onnxruntime_providers_tensorrt INTERFACE /wd4456)
endif()
# Needed for the provider interface, as it includes training headers when training is enabled
if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
target_include_directories(onnxruntime_providers_tensorrt PRIVATE ${ORTTRAINING_ROOT})
+ if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
+ onnxruntime_add_include_to_target(onnxruntime_providers_tensorrt Python::Module)
+ endif()
endif()
if(APPLE)
@@ -558,8 +642,8 @@ endif()
if (onnxruntime_USE_NUPHAR)
add_definitions(-DUSE_NUPHAR=1)
- if (NOT onnxruntime_USE_TVM)
- message(FATAL_ERROR "onnxruntime_USE_TVM required for onnxruntime_USE_NUPHAR")
+ if (NOT onnxruntime_USE_NUPHAR_TVM)
+ message(FATAL_ERROR "onnxruntime_USE_NUPHAR_TVM required for onnxruntime_USE_NUPHAR")
endif()
if (NOT onnxruntime_USE_LLVM)
@@ -638,7 +722,7 @@ if (onnxruntime_USE_OPENVINO)
else()
list(APPEND OPENVINO_LIB_LIST ${InferenceEngine_LIBRARIES} ${NGRAPH_LIBRARIES} ngraph::onnx_importer ${PYTHON_LIBRARIES})
endif()
-
+
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_openvino_cc_srcs})
onnxruntime_add_shared_library_module(onnxruntime_providers_openvino ${onnxruntime_providers_openvino_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_openvino onnxruntime_common onnx)
@@ -650,7 +734,7 @@ if (onnxruntime_USE_OPENVINO)
endif()
add_dependencies(onnxruntime_providers_openvino onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnxruntime_providers_openvino SYSTEM PUBLIC ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${OPENVINO_INCLUDE_DIR_LIST} ${PYTHON_INCLUDE_DIRS} $ENV{OPENCL_INCS})
- target_link_libraries(onnxruntime_providers_openvino ${ONNXRUNTIME_PROVIDERS_SHARED} ${OPENVINO_LIB_LIST})
+ target_link_libraries(onnxruntime_providers_openvino ${ONNXRUNTIME_PROVIDERS_SHARED} ${OPENVINO_LIB_LIST} absl::raw_hash_set absl::hash)
if(MSVC)
target_compile_options(onnxruntime_providers_openvino PUBLIC /wd4099 /wd4275 /wd4100 /wd4005 /wd4244 /wd4267)
@@ -686,7 +770,7 @@ if (onnxruntime_USE_COREML)
# Compile CoreML proto definition to ${CMAKE_CURRENT_BINARY_DIR}/coreml
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
- set(COREML_PROTO_ROOT ${PROJECT_SOURCE_DIR}/external/coremltools/mlmodel/format)
+ set(COREML_PROTO_ROOT ${PROJECT_SOURCE_DIR}/../onnxruntime/core/providers/coreml/mlmodel_format)
file(GLOB coreml_proto_srcs
"${COREML_PROTO_ROOT}/*.proto"
)
@@ -794,6 +878,8 @@ if (onnxruntime_USE_NNAPI_BUILTIN)
file(GLOB_RECURSE onnxruntime_providers_shared_utils_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.h"
"${ONNXRUNTIME_ROOT}/core/providers/shared/utils/utils.cc"
+ "${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.h"
+ "${ONNXRUNTIME_ROOT}/core/providers/shared/node_unit/node_unit.cc"
)
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
@@ -904,11 +990,7 @@ if (onnxruntime_USE_DML)
target_add_dml(onnxruntime_providers_dml)
target_link_libraries(onnxruntime_providers_dml PRIVATE d3d12.lib dxgi.lib)
- if (WINDOWS_STORE)
- target_link_libraries(onnxruntime_providers_dml PRIVATE dloadhelper.lib)
- else()
- target_link_libraries(onnxruntime_providers_dml PRIVATE delayimp.lib)
- endif()
+ target_link_libraries(onnxruntime_providers_dml PRIVATE delayimp.lib)
set(onnxruntime_DELAYLOAD_FLAGS "${onnxruntime_DELAYLOAD_FLAGS} /DELAYLOAD:DirectML.dll /DELAYLOAD:d3d12.dll /DELAYLOAD:dxgi.dll /DELAYLOAD:api-ms-win-core-com-l1-1-0.dll /DELAYLOAD:shlwapi.dll /DELAYLOAD:oleaut32.dll /ignore:4199")
@@ -926,6 +1008,23 @@ if (onnxruntime_USE_DML)
endif()
if (onnxruntime_USE_MIGRAPHX)
+ add_definitions(-DUSE_MIGRAPHX=1)
+ set(BUILD_LIBRARY_ONLY 1)
+ add_definitions("-DONNX_ML=1")
+ add_definitions("-DONNX_NAMESPACE=onnx")
+ include_directories(${PROJECT_SOURCE_DIR}/external/protobuf ${PROJECT_SOURCE_DIR}/external/eigen)
+ set(MIGRAPHX_ROOT ${onnxruntime_MIGRAPHX_HOME})
+ include_directories(${ONNXRUNTIME_ROOT}/../cmake/external/onnx)
+ set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+ if ( CMAKE_COMPILER_IS_GNUCC )
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-missing-field-initializers")
+ endif()
+ set(CXX_VERSION_DEFINED TRUE)
+ set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
+ if ( CMAKE_COMPILER_IS_GNUCC )
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
+ endif()
+
# Add search paths for default rocm installation
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hcc /opt/rocm/hip /opt/rocm)
@@ -937,18 +1036,28 @@ if (onnxruntime_USE_MIGRAPHX)
file(GLOB_RECURSE onnxruntime_providers_migraphx_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/migraphx/*.h"
"${ONNXRUNTIME_ROOT}/core/providers/migraphx/*.cc"
+ "${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.h"
+ "${ONNXRUNTIME_ROOT}/core/providers/shared_library/*.cc"
)
-
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_migraphx_cc_srcs})
- onnxruntime_add_static_library(onnxruntime_providers_migraphx ${onnxruntime_providers_migraphx_cc_srcs})
- target_link_libraries(onnxruntime_providers_migraphx PRIVATE ${migraphx_libs})
- set_target_properties(onnxruntime_providers_migraphx PROPERTIES FOLDER "ONNXRuntime")
- target_compile_options(onnxruntime_providers_migraphx PRIVATE -Wno-error=sign-compare)
- target_include_directories(onnxruntime_providers_migraphx PRIVATE ${ONNXRUNTIME_ROOT})
- onnxruntime_add_include_to_target(onnxruntime_providers_migraphx onnxruntime_common onnxruntime_framework onnx flatbuffers)
- add_dependencies(onnxruntime_providers_migraphx ${onnxruntime_EXTERNAL_DEPENDENCIES})
+ onnxruntime_add_shared_library_module(onnxruntime_providers_migraphx ${onnxruntime_providers_migraphx_cc_srcs})
+ onnxruntime_add_include_to_target(onnxruntime_providers_migraphx onnxruntime_common onnx flatbuffers)
+ add_dependencies(onnxruntime_providers_migraphx onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
+ target_link_libraries(onnxruntime_providers_migraphx PRIVATE ${migraphx_libs} ${ONNXRUNTIME_PROVIDERS_SHARED} onnx flatbuffers)
+ target_include_directories(onnxruntime_providers_migraphx PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/providers/migraphx DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core/providers)
set_target_properties(onnxruntime_providers_migraphx PROPERTIES LINKER_LANGUAGE CXX)
+ set_target_properties(onnxruntime_providers_migraphx PROPERTIES FOLDER "ONNXRuntime")
+ target_compile_definitions(onnxruntime_providers_migraphx PRIVATE ONNXIFI_BUILD_LIBRARY=1)
+ target_compile_options(onnxruntime_providers_migraphx PRIVATE -Wno-error=sign-compare)
+ set_property(TARGET onnxruntime_providers_migraphx APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
+ set_property(TARGET onnxruntime_providers_migraphx APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/migraphx/version_script.lds -Xlinker --gc-sections")
+ target_link_libraries(onnxruntime_providers_migraphx PRIVATE nsync_cpp stdc++fs)
+
+ install(TARGETS onnxruntime_providers_migraphx
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if (onnxruntime_USE_ACL)
@@ -1113,7 +1222,7 @@ if (onnxruntime_USE_ROCM)
endif()
add_dependencies(onnxruntime_providers_rocm onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
- target_link_libraries(onnxruntime_providers_rocm PRIVATE ${ONNXRUNTIME_ROCM_LIBS} ${ONNXRUNTIME_PROVIDERS_SHARED})
+ target_link_libraries(onnxruntime_providers_rocm PRIVATE ${ONNXRUNTIME_ROCM_LIBS} ${ONNXRUNTIME_PROVIDERS_SHARED} absl::hash absl::raw_hash_set absl::throw_delegate)
# During transition to separate hipFFT repo, put hipfft/include early
target_include_directories(onnxruntime_providers_rocm PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${eigen_INCLUDE_DIRS} PUBLIC ${onnxruntime_ROCM_HOME}/hipfft/include ${onnxruntime_ROCM_HOME}/include ${onnxruntime_ROCM_HOME}/hipcub/include ${onnxruntime_ROCM_HOME}/hiprand/include ${onnxruntime_ROCM_HOME}/rocrand/include)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/providers/rocm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core/providers)
@@ -1146,3 +1255,40 @@ if (onnxruntime_USE_ROCM)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
+
+if (onnxruntime_USE_TVM)
+ add_definitions(-DUSE_TVM=1)
+
+ file (GLOB_RECURSE onnxruntime_providers_tvm_cc_srcs CONFIGURE_DEPENDS
+ "${ONNXRUNTIME_ROOT}/core/providers/tvm/*.h"
+ "${ONNXRUNTIME_ROOT}/core/providers/tvm/*.cc"
+ )
+ source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_providers_tvm_cc_srcs})
+ onnxruntime_add_static_library(onnxruntime_providers_tvm ${onnxruntime_providers_tvm_cc_srcs})
+
+ if ( CMAKE_COMPILER_IS_GNUCC )
+ target_compile_options(onnxruntime_providers_tvm PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers)
+ endif()
+
+ target_include_directories(onnxruntime_providers_tvm PRIVATE
+ ${TVM_INCLUDES}
+ ${PYTHON_INLCUDE_DIRS})
+ onnxruntime_add_include_to_target(onnxruntime_providers_tvm onnxruntime_common onnx tvm)
+
+ add_dependencies(onnxruntime_providers_tvm ${onnxruntime_EXTERNAL_DEPENDENCIES})
+
+ target_link_libraries(onnxruntime_providers_tvm PRIVATE
+ onnx
+ tvm
+ onnxruntime_common
+ onnxruntime_framework
+ )
+
+ set_target_properties(onnxruntime_providers_tvm PROPERTIES FOLDER "ONNXRuntime")
+ set_target_properties(onnxruntime_providers_tvm PROPERTIES LINKER_LANGUAGE CXX)
+
+ target_compile_options(onnxruntime_providers_tvm PRIVATE -Wno-error=type-limits)
+ target_compile_definitions(onnxruntime_providers_tvm PUBLIC DMLC_USE_LOGGING_LIBRARY=)
+
+ install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/providers/tvm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core/providers)
+endif()
diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake
index 7c894556cf10f..002d8a05e5b4c 100644
--- a/cmake/onnxruntime_python.cmake
+++ b/cmake/onnxruntime_python.cmake
@@ -126,18 +126,19 @@ if (onnxruntime_ENABLE_EAGER_MODE)
set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_hooks.cpp" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_ops.cpp" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/eager/ort_util.cpp" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
+ set_source_files_properties("${ORTTRAINING_ROOT}/orttraining/python/orttraining_python_module.cc" PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
endif()
if (MSVC)
target_compile_options(onnxruntime_pybind11_state PRIVATE "/wd4100" "/wd4324" "/wd4458" "/wd4127" "/wd4193" "/wd4624" "/wd4702")
- target_compile_options(onnxruntime_pybind11_state PRIVATE "/bigobj" "/wd4275" "/wd4244" "/wd4267")
+ target_compile_options(onnxruntime_pybind11_state PRIVATE "/bigobj" "/wd4275" "/wd4244" "/wd4267" "/wd4067")
endif()
endif()
target_link_libraries(onnxruntime_pybind11_state PRIVATE
onnxruntime_session
${onnxruntime_libs}
- ${PROVIDERS_MIGRAPHX}
${PROVIDERS_NUPHAR}
+ ${PROVIDERS_TVM}
${PROVIDERS_VITISAI}
${PROVIDERS_NNAPI}
${PROVIDERS_COREML}
@@ -280,6 +281,12 @@ if (onnxruntime_ENABLE_TRAINING)
file(GLOB onnxruntime_python_amp_srcs CONFIGURE_DEPENDS
"${ORTTRAINING_SOURCE_DIR}/python/training/amp/*.py"
)
+ file(GLOB onnxruntime_python_experimental_srcs CONFIGURE_DEPENDS
+ "${ORTTRAINING_SOURCE_DIR}/python/training/experimental/*.py"
+ )
+ file(GLOB onnxruntime_python_gradient_graph_srcs CONFIGURE_DEPENDS
+ "${ORTTRAINING_SOURCE_DIR}/python/training/experimental/gradient_graph/*.py"
+ )
file(GLOB onnxruntime_python_optim_srcs CONFIGURE_DEPENDS
"${ORTTRAINING_SOURCE_DIR}/python/training/optim/*.py"
)
@@ -310,6 +317,9 @@ if (onnxruntime_ENABLE_TRAINING)
file(GLOB onnxruntime_python_ortmodule_torch_cpp_ext_fused_ops_srcs CONFIGURE_DEPENDS
"${ORTTRAINING_SOURCE_DIR}/python/training/ortmodule/torch_cpp_extensions/cuda/fused_ops/*"
)
+ file(GLOB onnxruntime_python_utils_data_srcs CONFIGURE_DEPENDS
+ "${ORTTRAINING_SOURCE_DIR}/python/training/utils/data/*"
+ )
else()
file(GLOB onnxruntime_python_capi_training_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/python/training/*.py"
@@ -365,13 +375,32 @@ file(GLOB onnxruntime_python_datasets_data CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/python/datasets/*.onnx"
)
-# Files needed to convert ONNX model to ORT format
-set(onnxruntime_ort_format_model_conversion_srcs
+# ORT Mobile helpers to convert ONNX model to ORT format, analyze model for suitability in mobile scenarios,
+# and assist with export from PyTorch.
+set(onnxruntime_mobile_util_srcs
+ ${REPO_ROOT}/tools/python/util/check_onnx_model_mobile_usability.py
${REPO_ROOT}/tools/python/util/convert_onnx_models_to_ort.py
+ ${REPO_ROOT}/tools/python/util/file_utils.py
${REPO_ROOT}/tools/python/util/logger.py
+ ${REPO_ROOT}/tools/python/util/make_dynamic_shape_fixed.py
+ ${REPO_ROOT}/tools/python/util/onnx_model_utils.py
+ ${REPO_ROOT}/tools/python/util/optimize_onnx_model.py
+ ${REPO_ROOT}/tools/python/util/pytorch_export_helpers.py
+ ${REPO_ROOT}/tools/python/util/reduced_build_config_parser.py
+ ${REPO_ROOT}/tools/python/util/update_onnx_opset.py
)
file(GLOB onnxruntime_ort_format_model_srcs CONFIGURE_DEPENDS
- ${REPO_ROOT}/tools/python/util/ort_format_model/*.py)
+ ${REPO_ROOT}/tools/python/util/ort_format_model/*.py
+)
+file(GLOB onnxruntime_mobile_helpers_srcs CONFIGURE_DEPENDS
+ ${REPO_ROOT}/tools/python/util/mobile_helpers/*.py
+ ${REPO_ROOT}/tools/ci_build/github/android/mobile_package.required_operators.config
+ ${REPO_ROOT}/tools/ci_build/github/android/nnapi_supported_ops.md
+ ${REPO_ROOT}/tools/ci_build/github/apple/coreml_supported_ops.md
+)
+file(GLOB onnxruntime_qdq_helper_srcs CONFIGURE_DEPENDS
+ ${REPO_ROOT}/tools/python/util/qdq_helpers/*.py
+)
set(build_output_target onnxruntime_common)
if(NOT onnxruntime_ENABLE_STATIC_ANALYSIS)
@@ -382,6 +411,8 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/capi/training
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/datasets
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/tools
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/tools/mobile_helpers
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/tools/qdq_helpers
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/tools/ort_format_model
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/tools/ort_format_model/ort_flatbuffers_py
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/transformers
@@ -432,8 +463,21 @@ add_custom_command(
${onnxruntime_python_tools_srcs}
$/onnxruntime/tools/
COMMAND ${CMAKE_COMMAND} -E copy
- ${onnxruntime_ort_format_model_conversion_srcs}
+ ${onnxruntime_mobile_util_srcs}
$/onnxruntime/tools/
+ # append the /tools/python/utils imports to the __init__.py that came from /onnxruntime/tools.
+ # we're aggregating scripts from two different locations, and only include selected functionality from
+ # /tools/python/util. due to that we take the full __init__.py from /onnxruntime/tools and append
+ # the required content from /tools/python/util/__init__append.py.
+ COMMAND ${CMAKE_COMMAND} -E cat
+ ${REPO_ROOT}/tools/python/util/__init__append.py >>
+ $/onnxruntime/tools/__init__.py
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_qdq_helper_srcs}
+ $/onnxruntime/tools/qdq_helpers/
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_mobile_helpers_srcs}
+ $/onnxruntime/tools/mobile_helpers/
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_ort_format_model_srcs}
$/onnxruntime/tools/ort_format_model/
@@ -530,6 +574,8 @@ if (onnxruntime_ENABLE_TRAINING)
TARGET onnxruntime_pybind11_state POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/amp
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/experimental
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/experimental/gradient_graph
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/optim
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/ortmodule
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/ortmodule/experimental
@@ -540,6 +586,7 @@ if (onnxruntime_ENABLE_TRAINING)
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/ortmodule/torch_cpp_extensions/cpu/torch_interop_utils
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/ortmodule/torch_cpp_extensions/cuda/torch_gpu_allocator
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/ortmodule/torch_cpp_extensions/cuda/fused_ops
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/training/utils/data/
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_capi_training_srcs}
$/onnxruntime/capi/training/
@@ -549,6 +596,12 @@ if (onnxruntime_ENABLE_TRAINING)
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_amp_srcs}
$/onnxruntime/training/amp/
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_python_experimental_srcs}
+ $/onnxruntime/training/experimental/
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_python_gradient_graph_srcs}
+ $/onnxruntime/training/experimental/gradient_graph/
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_optim_srcs}
$/onnxruntime/training/optim/
@@ -579,6 +632,9 @@ if (onnxruntime_ENABLE_TRAINING)
COMMAND ${CMAKE_COMMAND} -E copy
${onnxruntime_python_ortmodule_torch_cpp_ext_fused_ops_srcs}
$/onnxruntime/training/ortmodule/torch_cpp_extensions/cuda/fused_ops/
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_python_utils_data_srcs}
+ $/onnxruntime/training/utils/data/
)
endif()
@@ -602,6 +658,16 @@ if (onnxruntime_USE_TENSORRT)
)
endif()
+if (onnxruntime_USE_MIGRAPHX)
+ add_custom_command(
+ TARGET onnxruntime_pybind11_state POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy
+ $
+ $
+ $/onnxruntime/capi/
+ )
+endif()
+
if (onnxruntime_USE_OPENVINO)
add_custom_command(
TARGET onnxruntime_pybind11_state POST_BUILD
@@ -632,19 +698,16 @@ if (onnxruntime_USE_ROCM)
)
endif()
-if (onnxruntime_USE_TVM)
+if (onnxruntime_USE_NUPHAR)
add_custom_command(
TARGET onnxruntime_pybind11_state POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$
$/onnxruntime/capi/
)
-endif()
-
-if (onnxruntime_USE_NUPHAR)
file(GLOB onnxruntime_python_nuphar_python_srcs CONFIGURE_DEPENDS
- "${ONNXRUNTIME_ROOT}/core/providers/nuphar/scripts/*"
- )
+ "${ONNXRUNTIME_ROOT}/core/providers/nuphar/scripts/*"
+ )
add_custom_command(
TARGET onnxruntime_pybind11_state POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/nuphar
@@ -654,6 +717,37 @@ if (onnxruntime_USE_NUPHAR)
)
endif()
+if (onnxruntime_USE_TVM)
+ file(GLOB onnxruntime_python_providers_tvm_srcs CONFIGURE_DEPENDS
+ "${ONNXRUNTIME_ROOT}/python/providers/tvm/*.py"
+ )
+ add_custom_command(
+ TARGET onnxruntime_pybind11_state POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/providers
+ COMMAND ${CMAKE_COMMAND} -E make_directory $/onnxruntime/providers/tvm
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${onnxruntime_python_providers_tvm_srcs}
+ $/onnxruntime/providers/tvm
+ COMMAND ${CMAKE_COMMAND} -E copy
+ $
+ $/onnxruntime/capi/
+ )
+
+ add_custom_command(
+ TARGET onnxruntime_pybind11_state POST_BUILD
+ WORKING_DIRECTORY ${tvm_SOURCE_DIR}/python
+ COMMAND ${Python_EXECUTABLE} setup.py bdist_wheel
+ )
+
+ add_custom_command(
+ TARGET onnxruntime_pybind11_state POST_BUILD
+ COMMAND ${Python_EXECUTABLE}
+ $/onnxruntime/providers/tvm/extend_python_file.py
+ --target_file $/onnxruntime/capi/_ld_preload.py
+ )
+
+endif()
+
if (onnxruntime_USE_DML)
add_custom_command(
TARGET onnxruntime_pybind11_state POST_BUILD
diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake
index 6bdb2d03c9265..4fdb54c32d2d4 100644
--- a/cmake/onnxruntime_unittests.cmake
+++ b/cmake/onnxruntime_unittests.cmake
@@ -9,13 +9,13 @@ set(TEST_INC_DIR ${ONNXRUNTIME_ROOT})
if (onnxruntime_ENABLE_TRAINING)
list(APPEND TEST_INC_DIR ${ORTTRAINING_ROOT})
endif()
-if (onnxruntime_USE_TVM)
+if (onnxruntime_USE_NUPHAR_TVM)
list(APPEND TEST_INC_DIR ${TVM_INCLUDES})
endif()
set(disabled_warnings)
function(AddTest)
- cmake_parse_arguments(_UT "DYN" "TARGET" "LIBS;SOURCES;DEPENDS" ${ARGN})
+ cmake_parse_arguments(_UT "DYN" "TARGET" "LIBS;SOURCES;DEPENDS;TEST_ARGS" ${ARGN})
list(REMOVE_DUPLICATES _UT_SOURCES)
if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
@@ -81,6 +81,12 @@ function(AddTest)
# Lot of such things came from gtest
target_compile_options(${_UT_TARGET} PRIVATE "$<$:-Xcompiler /wd6326>"
"$<$>:/wd6326>")
+ # Raw new and delete. A lot of such things came from googletest.
+ target_compile_options(${_UT_TARGET} PRIVATE "$<$:-Xcompiler /wd26409>"
+ "$<$>:/wd26409>")
+ # "Global initializer calls a non-constexpr function."
+ target_compile_options(${_UT_TARGET} PRIVATE "$<$:-Xcompiler /wd26426>"
+ "$<$>:/wd26426>")
endif()
target_compile_options(${_UT_TARGET} PRIVATE ${disabled_warnings})
else()
@@ -90,7 +96,7 @@ function(AddTest)
target_compile_options(${_UT_TARGET} PRIVATE "-Wno-error=uninitialized")
endif()
- set(TEST_ARGS)
+ set(TEST_ARGS ${_UT_TEST_ARGS})
if (onnxruntime_GENERATE_TEST_REPORTS)
# generate a report file next to the test program
if (onnxruntime_BUILD_WEBASSEMBLY)
@@ -230,6 +236,12 @@ else() # minimal and/or reduced ops build
endif()
endif()
+if((NOT onnxruntime_MINIMAL_BUILD OR onnxruntime_EXTENDED_MINIMAL_BUILD)
+ AND NOT onnxruntime_REDUCED_OPS_BUILD)
+ list(APPEND onnxruntime_test_optimizer_src
+ "${TEST_SRC_DIR}/optimizer/runtime_optimization/graph_runtime_optimization_test.cc")
+endif()
+
file(GLOB onnxruntime_test_training_src
"${ORTTRAINING_SOURCE_DIR}/test/model/*.cc"
"${ORTTRAINING_SOURCE_DIR}/test/gradient/*.cc"
@@ -418,6 +430,10 @@ endif()
set (onnxruntime_test_providers_dependencies ${onnxruntime_EXTERNAL_DEPENDENCIES})
+if(onnxruntime_USE_CUDA)
+ list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_cuda)
+endif()
+
if(onnxruntime_USE_NNAPI_BUILTIN)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nnapi)
endif()
@@ -431,7 +447,8 @@ if(onnxruntime_USE_DML)
endif()
if(onnxruntime_USE_MIGRAPHX)
- list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_migraphx)
+ list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_migraphx)
+ list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_migraphx onnxruntime_providers_shared)
endif()
if(onnxruntime_USE_ROCM)
@@ -446,12 +463,12 @@ if(onnxruntime_USE_COREML)
endif()
endif()
-file(GLOB_RECURSE onnxruntime_test_tvm_src CONFIGURE_DEPENDS
- "${TEST_SRC_DIR}/tvm/*.h"
- "${TEST_SRC_DIR}/tvm/*.cc"
+if(onnxruntime_USE_NUPHAR)
+ file(GLOB_RECURSE onnxruntime_test_nuphar_src CONFIGURE_DEPENDS
+ "${TEST_SRC_DIR}/nuphar_tvm/*.h"
+ "${TEST_SRC_DIR}/nuphar_tvm/*.cc"
)
-if(onnxruntime_USE_NUPHAR)
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/framework/nuphar/*)
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_nuphar)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nuphar)
@@ -474,8 +491,7 @@ set(ONNXRUNTIME_TEST_LIBS
onnxruntime_session
${ONNXRUNTIME_INTEROP_TEST_LIBS}
${onnxruntime_libs}
- # CUDA, ROCM, TENSORRT, DNNL, and OpenVINO are dynamically loaded at runtime
- ${PROVIDERS_MIGRAPHX}
+ # CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime
${PROVIDERS_NUPHAR}
${PROVIDERS_NNAPI}
${PROVIDERS_RKNPU}
@@ -483,6 +499,7 @@ set(ONNXRUNTIME_TEST_LIBS
${PROVIDERS_ACL}
${PROVIDERS_ARMNN}
${PROVIDERS_COREML}
+ # ${PROVIDERS_TVM}
onnxruntime_optimizer
onnxruntime_providers
onnxruntime_util
@@ -506,10 +523,18 @@ set(onnxruntime_test_providers_libs
if(onnxruntime_USE_TENSORRT)
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/tensorrt/*)
+ list(APPEND onnxruntime_test_framework_src_patterns "${ONNXRUNTIME_ROOT}/core/providers/tensorrt/tensorrt_execution_provider_utils.h")
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_tensorrt)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_tensorrt onnxruntime_providers_shared)
endif()
+if(onnxruntime_USE_MIGRAPHX)
+ list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/migraphx/*)
+ list(APPEND onnxruntime_test_framework_src_patterns "${ONNXRUNTIME_ROOT}/core/providers/migraphx/migraphx_execution_provider_utils.h")
+ list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_migraphx)
+ list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_migraphx onnxruntime_providers_shared)
+endif()
+
if(onnxruntime_USE_NNAPI_BUILTIN)
list(APPEND onnxruntime_test_framework_src_patterns ${TEST_SRC_DIR}/providers/nnapi/*)
list(APPEND onnxruntime_test_framework_libs onnxruntime_providers_nnapi)
@@ -537,9 +562,17 @@ if(onnxruntime_USE_COREML)
endif()
endif()
+if (onnxruntime_USE_TVM)
+ file (GLOB_RECURSE onnxruntime_test_tvm_src CONFIGURE_DEPENDS
+ "${TEST_SRC_DIR}/tvm/*.h"
+ "${TEST_SRC_DIR}/tvm/*.cc"
+ )
+
+ list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_tvm)
+endif()
if(WIN32)
- if (onnxruntime_USE_TVM)
+ if (onnxruntime_USE_NUPHAR_TVM)
list(APPEND disabled_warnings ${DISABLED_WARNINGS_FOR_TVM})
endif()
endif()
@@ -623,9 +656,14 @@ if (onnxruntime_ENABLE_TRAINING)
list(APPEND all_tests ${onnxruntime_test_training_src})
endif()
+if (onnxruntime_USE_NUPHAR)
+ list(APPEND all_tests ${onnxruntime_test_nuphar_src})
+endif()
+
if (onnxruntime_USE_TVM)
- list(APPEND all_tests ${onnxruntime_test_tvm_src})
+ list(APPEND all_tests ${onnxruntime_test_tvm_src})
endif()
+
if (onnxruntime_USE_OPENVINO)
list(APPEND all_tests ${onnxruntime_test_openvino_src})
endif()
@@ -638,15 +676,7 @@ if(WIN32)
endif()
if (onnxruntime_BUILD_WEBASSEMBLY)
- if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
- # WebAssembly threading support in node is an experimental feature yet
- # and that makes some intensive threadpool tests fail randomly.
- # Will enable this test when node.js releases a stable version supporting multi-threads.
- list(REMOVE_ITEM all_tests
- "${TEST_SRC_DIR}/platform/threadpool_test.cc"
- "${TEST_SRC_DIR}/providers/cpu/nn/string_normalizer_test.cc"
- )
- else()
+ if (NOT onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
list(REMOVE_ITEM all_tests
"${TEST_SRC_DIR}/framework/execution_frame_test.cc"
"${TEST_SRC_DIR}/framework/inference_session_test.cc"
@@ -659,6 +689,17 @@ if (onnxruntime_BUILD_WEBASSEMBLY)
endif()
endif()
+set(test_all_args)
+if (onnxruntime_USE_TENSORRT)
+ # TRT EP CI takes much longer time when updating to TRT 8.2
+ # So, we only run trt ep and exclude other eps to reduce CI test time.
+ #
+ # The test names of model tests were using sequential number in the past.
+ # This PR https://github.com/microsoft/onnxruntime/pull/10220 (Please see ExpandModelName function in model_tests.cc for more details)
+ # made test name contain the "ep" and "model path" information, so we can easily filter the tests using cuda ep or other ep with *cpu__* or *xxx__*.
+ list(APPEND test_all_args "--gtest_filter=-*cpu__*:*cuda__*" )
+endif ()
+
AddTest(
TARGET onnxruntime_test_all
SOURCES ${all_tests} ${onnxruntime_unittest_main_src}
@@ -666,8 +707,14 @@ AddTest(
onnx_test_runner_common ${onnxruntime_test_providers_libs} ${onnxruntime_test_common_libs}
onnx_test_data_proto nlohmann_json::nlohmann_json
DEPENDS ${all_dependencies}
+ TEST_ARGS ${test_all_args}
)
-if(NOT MSVC)
+if (MSVC)
+ # The warning means the type of two integral values around a binary operator is narrow than their result.
+ # If we promote the two input values first, it could be more tolerant to integer overflow.
+ # However, this is test code. We are less concerned.
+ target_compile_options(onnxruntime_test_all PRIVATE "/wd26451")
+else()
target_compile_options(onnxruntime_test_all PRIVATE "-Wno-parentheses")
endif()
# the default logger tests conflict with the need to have an overall default logger
@@ -687,6 +734,7 @@ if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
target_link_libraries(onnxruntime_test_all PRIVATE onnxruntime_language_interop onnxruntime_pyop)
endif()
if (onnxruntime_USE_ROCM)
+ target_compile_options(onnxruntime_test_all PRIVATE -D__HIP_PLATFORM_HCC__=1)
target_include_directories(onnxruntime_test_all PRIVATE ${onnxruntime_ROCM_HOME}/hipfft/include ${onnxruntime_ROCM_HOME}/include ${onnxruntime_ROCM_HOME}/hiprand/include ${onnxruntime_ROCM_HOME}/rocrand/include ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/onnxruntime ${CMAKE_CURRENT_BINARY_DIR}/amdgpu/orttraining)
endif()
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
@@ -707,12 +755,11 @@ add_dependencies(onnx_test_data_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDEN
#onnx_proto target should mark this definition as public, instead of private
target_compile_definitions(onnx_test_data_proto PRIVATE "-DONNX_API=")
if(WIN32)
- target_compile_options(onnx_test_data_proto PRIVATE "/wd4125" "/wd4456" "/wd4100" "/wd4267" "/wd6011" "/wd6387" "/wd28182")
+ target_compile_options(onnx_test_data_proto PRIVATE "/wd4100" "/wd4125" "/wd4127" "/wd4267" "/wd4456" "/wd4800" "/wd6011" "/wd6387" "/wd28182")
else()
#Once we upgrade protobuf to 3.17.3+, we can remove this
target_compile_options(onnx_test_data_proto PRIVATE "-Wno-unused-parameter")
endif()
-add_dependencies(onnx_test_data_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
onnxruntime_add_include_to_target(onnx_test_data_proto onnx_proto)
target_include_directories(onnx_test_data_proto PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(onnx_test_data_proto PROPERTIES FOLDER "ONNXRuntimeTest")
@@ -750,7 +797,7 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
)
endif()
if(WIN32)
- if (onnxruntime_USE_TVM)
+ if (onnxruntime_USE_NUPHAR_TVM)
add_custom_command(
TARGET ${test_data_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $ $
@@ -789,6 +836,13 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
)
endif()
+if (onnxruntime_BUILD_WEBASSEMBLY)
+ if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
+ set_target_properties(onnx_test_runner PROPERTIES LINK_FLAGS "-s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1 -s USE_PTHREADS=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})
target_include_directories(onnx_test_runner PRIVATE ${ONNXRUNTIME_ROOT})
@@ -800,7 +854,7 @@ if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
endif()
set_target_properties(onnx_test_runner PROPERTIES FOLDER "ONNXRuntimeTest")
-if (onnxruntime_USE_TVM)
+if (onnxruntime_USE_NUPHAR_TVM)
if (WIN32)
target_link_options(onnx_test_runner PRIVATE "/STACK:4000000")
endif()
@@ -832,6 +886,17 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
if(WIN32)
target_compile_options(onnxruntime_benchmark PRIVATE "$<$:-Xcompiler /wd4141>"
"$<$>:/wd4141>")
+ # Avoid using new and delete. But this is a benchmark program, it's ok if it has a chance to leak.
+ target_compile_options(onnxruntime_benchmark PRIVATE "$<$:-Xcompiler /wd26409>"
+ "$<$>:/wd26409>")
+ target_compile_options(onnxruntime_benchmark PRIVATE "$<$:-Xcompiler /wd26400>"
+ "$<$>:/wd26400>")
+ target_compile_options(onnxruntime_benchmark PRIVATE "$<$:-Xcompiler /wd26814>"
+ "$<$>:/wd26814>")
+ target_compile_options(onnxruntime_benchmark PRIVATE "$<$:-Xcompiler /wd26814>"
+ "$<$>:/wd26497>")
+ target_compile_options(onnxruntime_benchmark PRIVATE "$<$:-Xcompiler /wd26426>"
+ "$<$>:/wd26426>")
target_compile_options(onnxruntime_benchmark PRIVATE "$<$:SHELL:--compiler-options /utf-8>"
"$<$>:/utf-8>")
endif()
@@ -844,7 +909,13 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
onnxruntime_add_executable(onnxruntime_mlas_benchmark ${MLAS_BENCH_SOURCE_FILES})
target_include_directories(onnxruntime_mlas_benchmark PRIVATE ${ONNXRUNTIME_ROOT}/core/mlas/inc)
target_link_libraries(onnxruntime_mlas_benchmark PRIVATE benchmark::benchmark onnxruntime_util onnxruntime_framework ${ONNXRUNTIME_MLAS_LIBS} onnxruntime_common ${CMAKE_DL_LIBS})
- if(NOT WIN32)
+ if(WIN32)
+ target_link_libraries(onnxruntime_mlas_benchmark PRIVATE debug Dbghelp)
+ # Avoid using new and delete. But this is a benchmark program, it's ok if it has a chance to leak.
+ target_compile_options(onnxruntime_mlas_benchmark PRIVATE /wd26409)
+ # "Global initializer calls a non-constexpr function." BENCHMARK_CAPTURE macro needs this.
+ target_compile_options(onnxruntime_mlas_benchmark PRIVATE /wd26426)
+ else()
target_link_libraries(onnxruntime_mlas_benchmark PRIVATE nsync_cpp ${CMAKE_DL_LIBS})
endif()
set_target_properties(onnxruntime_mlas_benchmark PROPERTIES FOLDER "ONNXRuntimeTest")
@@ -982,7 +1053,7 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
target_link_libraries(onnxruntime_perf_test PRIVATE onnxruntime_language_interop onnxruntime_pyop)
endif()
- if (onnxruntime_USE_TVM)
+ if (onnxruntime_USE_NUPHAR_TVM)
if (WIN32)
target_link_options(onnxruntime_perf_test PRIVATE "/STACK:4000000")
endif()
@@ -1086,10 +1157,14 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
)
onnxruntime_add_executable(onnxruntime_mlas_test ${onnxruntime_mlas_test_src})
if(MSVC)
+ target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:-Xcompiler /wd26409>"
+ "$<$>:/wd26409>")
target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:SHELL:--compiler-options /utf-8>"
"$<$>:/utf-8>")
target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:-Xcompiler /wd6326>"
"$<$>:/wd6326>")
+ target_compile_options(onnxruntime_mlas_test PRIVATE "$<$:-Xcompiler /wd26426>"
+ "$<$>:/wd26426>")
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set_target_properties(onnxruntime_mlas_test PROPERTIES
@@ -1105,9 +1180,6 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
list(APPEND onnxruntime_mlas_test_libs ${android_shared_libs})
endif()
- if (onnxruntime_USE_OPENMP)
- list(APPEND onnxruntime_mlas_test_libs OpenMP::OpenMP_CXX)
- endif()
list(APPEND onnxruntime_mlas_test_libs Threads::Threads)
target_link_libraries(onnxruntime_mlas_test PRIVATE ${onnxruntime_mlas_test_libs})
if(WIN32)
@@ -1126,7 +1198,16 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
endif()
endif()
-onnxruntime_add_shared_library_module(custom_op_library ${TEST_SRC_DIR}/testdata/custom_op_library/custom_op_library.cc)
+if (onnxruntime_USE_CUDA)
+ onnxruntime_add_shared_library_module(custom_op_library ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/cuda_ops.cu
+ ${TEST_SRC_DIR}/testdata/custom_op_library/custom_op_library.cc)
+ target_include_directories(custom_op_library PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
+ if (HAS_QSPECTRE)
+ target_compile_options(custom_op_library PRIVATE "$<$:SHELL:-Xcompiler /Qspectre>")
+ endif()
+else()
+ onnxruntime_add_shared_library_module(custom_op_library ${TEST_SRC_DIR}/testdata/custom_op_library/custom_op_library.cc)
+endif()
target_include_directories(custom_op_library PRIVATE ${REPO_ROOT}/include)
if(UNIX)
if (APPLE)
@@ -1136,6 +1217,10 @@ if(UNIX)
endif()
else()
set(ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG "-DEF:${TEST_SRC_DIR}/testdata/custom_op_library/custom_op_library.def")
+ if (NOT onnxruntime_USE_CUDA)
+ target_compile_options(custom_op_library PRIVATE "$<$:-Xcompiler /wd26409>"
+ "$<$>:/wd26409>")
+ endif()
endif()
set_property(TARGET custom_op_library APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG})
@@ -1186,8 +1271,8 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
)
onnxruntime_add_shared_library_module(test_execution_provider ${test_execution_provider_srcs})
- add_dependencies(test_execution_provider onnxruntime_providers_shared onnx)
- target_link_libraries(test_execution_provider PRIVATE onnxruntime_providers_shared)
+ add_dependencies(test_execution_provider onnxruntime_providers_shared onnx absl::raw_hash_set)
+ target_link_libraries(test_execution_provider PRIVATE onnxruntime_providers_shared absl::raw_hash_set)
target_include_directories(test_execution_provider PRIVATE $)
target_include_directories(test_execution_provider PRIVATE $)
target_include_directories(test_execution_provider PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${ORTTRAINING_ROOT})
diff --git a/cmake/onnxruntime_util.cmake b/cmake/onnxruntime_util.cmake
index 8449cf2e0f4e9..f62b288130a35 100644
--- a/cmake/onnxruntime_util.cmake
+++ b/cmake/onnxruntime_util.cmake
@@ -4,18 +4,13 @@
file(GLOB_RECURSE onnxruntime_util_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/util/*.h"
"${ONNXRUNTIME_ROOT}/core/util/*.cc"
- "${ONNXRUNTIME_ROOT}/core/profile/*.h"
- "${ONNXRUNTIME_ROOT}/core/profile/*.cc"
)
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_util_srcs})
onnxruntime_add_static_library(onnxruntime_util ${onnxruntime_util_srcs})
target_include_directories(onnxruntime_util PRIVATE ${ONNXRUNTIME_ROOT} PUBLIC ${eigen_INCLUDE_DIRS})
-if (onnxruntime_USE_CUDA)
- target_include_directories(onnxruntime_util PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
-endif()
-onnxruntime_add_include_to_target(onnxruntime_util onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB})
+onnxruntime_add_include_to_target(onnxruntime_util onnxruntime_common onnx onnx_proto ${PROTOBUF_LIB})
if(UNIX)
target_compile_options(onnxruntime_util PUBLIC "-Wno-error=comment")
endif()
@@ -24,5 +19,4 @@ set_target_properties(onnxruntime_util PROPERTIES FOLDER "ONNXRuntime")
add_dependencies(onnxruntime_util ${onnxruntime_EXTERNAL_DEPENDENCIES})
if (WIN32)
target_compile_definitions(onnxruntime_util PRIVATE _SCL_SECURE_NO_WARNINGS)
- target_compile_definitions(onnxruntime_framework PRIVATE _SCL_SECURE_NO_WARNINGS)
endif()
diff --git a/cmake/onnxruntime_webassembly.cmake b/cmake/onnxruntime_webassembly.cmake
index 588c1e9da9eeb..dba19904c649b 100644
--- a/cmake/onnxruntime_webassembly.cmake
+++ b/cmake/onnxruntime_webassembly.cmake
@@ -1,19 +1,89 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
-file(GLOB_RECURSE onnxruntime_webassembly_src CONFIGURE_DEPENDS
- "${ONNXRUNTIME_ROOT}/wasm/api.cc"
-)
+function(bundle_static_library bundled_target_name)
+ function(recursively_collect_dependencies input_target)
+ set(input_link_libraries LINK_LIBRARIES)
+ get_target_property(input_type ${input_target} TYPE)
+ if (${input_type} STREQUAL "INTERFACE_LIBRARY")
+ set(input_link_libraries INTERFACE_LINK_LIBRARIES)
+ endif()
+ get_target_property(public_dependencies ${input_target} ${input_link_libraries})
+ foreach(dependency IN LISTS public_dependencies)
+ if(TARGET ${dependency})
+ get_target_property(alias ${dependency} ALIASED_TARGET)
+ if (TARGET ${alias})
+ set(dependency ${alias})
+ endif()
+ get_target_property(type ${dependency} TYPE)
+ if (${type} STREQUAL "STATIC_LIBRARY")
+ list(APPEND static_libs ${dependency})
+ endif()
-source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_webassembly_src})
+ get_property(library_already_added GLOBAL PROPERTY ${target_name}_static_bundle_${dependency})
+ if (NOT library_already_added)
+ set_property(GLOBAL PROPERTY ${target_name}_static_bundle_${dependency} ON)
+ recursively_collect_dependencies(${dependency})
+ endif()
+ endif()
+ endforeach()
+ set(static_libs ${static_libs} PARENT_SCOPE)
+ endfunction()
-add_executable(onnxruntime_webassembly
- ${onnxruntime_webassembly_src}
-)
+ foreach(target_name IN ITEMS ${ARGN})
+ list(APPEND static_libs ${target_name})
+ recursively_collect_dependencies(${target_name})
+ endforeach()
+
+ list(REMOVE_DUPLICATES static_libs)
+
+ set(bundled_target_full_name
+ ${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${bundled_target_name}${CMAKE_STATIC_LIBRARY_SUFFIX})
+
+ file(WRITE ${CMAKE_BINARY_DIR}/${bundled_target_name}.ar.in
+ "CREATE ${bundled_target_full_name}\n" )
+
+ foreach(target IN LISTS static_libs)
+ file(APPEND ${CMAKE_BINARY_DIR}/${bundled_target_name}.ar.in
+ "ADDLIB $\n")
+ endforeach()
+
+ file(APPEND ${CMAKE_BINARY_DIR}/${bundled_target_name}.ar.in "SAVE\n")
+ file(APPEND ${CMAKE_BINARY_DIR}/${bundled_target_name}.ar.in "END\n")
+
+ file(GENERATE
+ OUTPUT ${CMAKE_BINARY_DIR}/${bundled_target_name}.ar
+ INPUT ${CMAKE_BINARY_DIR}/${bundled_target_name}.ar.in)
+
+ set(ar_tool ${CMAKE_AR})
+ if (CMAKE_INTERPROCEDURAL_OPTIMIZATION)
+ set(ar_tool ${CMAKE_CXX_COMPILER_AR})
+ endif()
+
+ add_custom_command(
+ COMMAND ${ar_tool} -M < ${CMAKE_BINARY_DIR}/${bundled_target_name}.ar
+ OUTPUT ${bundled_target_full_name}
+ COMMENT "Bundling ${bundled_target_name}"
+ VERBATIM)
+
+ add_custom_target(bundling_target ALL DEPENDS ${bundled_target_full_name})
+ foreach(target_name IN ITEMS ${ARGN})
+ add_dependencies(bundling_target ${target_name})
+ endforeach()
+
+ add_library(${bundled_target_name} STATIC IMPORTED)
+ foreach(target_name IN ITEMS ${ARGN})
+ set_target_properties(${bundled_target_name}
+ PROPERTIES
+ IMPORTED_LOCATION ${bundled_target_full_name}
+ INTERFACE_INCLUDE_DIRECTORIES $)
+ endforeach()
+ add_dependencies(${bundled_target_name} bundling_target)
+endfunction()
if (NOT onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
add_compile_definitions(
- MLAS_NO_ONNXRUNTIME_THREADPOOL
+ BUILD_MLAS_NO_ONNXRUNTIME
)
# Override re2 compiler options to remove -pthread
@@ -22,68 +92,143 @@ endif()
target_compile_options(onnx PRIVATE -Wno-unused-parameter -Wno-unused-variable)
-target_link_libraries(onnxruntime_webassembly PRIVATE
- nsync_cpp
- ${PROTOBUF_LIB}
- onnx
- onnx_proto
- onnxruntime_common
- onnxruntime_flatbuffers
- onnxruntime_framework
- onnxruntime_graph
- onnxruntime_mlas
- onnxruntime_optimizer
- onnxruntime_providers
- onnxruntime_session
- onnxruntime_util
- re2::re2
-)
-
-set(EXPORTED_RUNTIME_METHODS "['stackAlloc','stackRestore','stackSave','UTF8ToString','stringToUTF8','lengthBytesUTF8']")
-
-set_target_properties(onnxruntime_webassembly PROPERTIES LINK_FLAGS " \
- -s \"EXPORTED_RUNTIME_METHODS=${EXPORTED_RUNTIME_METHODS}\" \
- -s WASM=1 \
- -s NO_EXIT_RUNTIME=0 \
- -s ALLOW_MEMORY_GROWTH=1 \
- -s MODULARIZE=1 \
- -s EXPORT_ALL=0 \
- -s LLD_REPORT_UNDEFINED \
- -s VERBOSE=0 \
- -s NO_FILESYSTEM=1 \
- -s MALLOC=${onnxruntime_WEBASSEMBLY_MALLOC} \
- --closure 1 \
- --no-entry")
-
-if (CMAKE_BUILD_TYPE STREQUAL "Debug")
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=1 -s DEMANGLE_SUPPORT=1")
+if (onnxruntime_BUILD_WEBASSEMBLY_STATIC_LIB)
+ bundle_static_library(onnxruntime_webassembly
+ nsync_cpp
+ ${PROTOBUF_LIB}
+ onnx
+ onnx_proto
+ onnxruntime_common
+ onnxruntime_flatbuffers
+ onnxruntime_framework
+ onnxruntime_graph
+ onnxruntime_mlas
+ onnxruntime_optimizer
+ onnxruntime_providers
+ onnxruntime_session
+ onnxruntime_util
+ re2::re2
+ )
+
+ if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
+ bundle_static_library(onnxruntime_webassembly tensorboard)
+ endif()
+
+ if (onnxruntime_BUILD_UNIT_TESTS)
+ file(GLOB_RECURSE onnxruntime_webassembly_test_src CONFIGURE_DEPENDS
+ "${ONNXRUNTIME_ROOT}/test/wasm/test_main.cc"
+ "${ONNXRUNTIME_ROOT}/test/wasm/test_inference.cc"
+ )
+
+ source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_webassembly_test_src})
+
+ add_executable(onnxruntime_webassembly_test
+ ${onnxruntime_webassembly_test_src}
+ )
+
+ set_target_properties(onnxruntime_webassembly_test PROPERTIES LINK_FLAGS
+ "-s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['FS']\" --preload-file ${CMAKE_CURRENT_BINARY_DIR}/testdata@/testdata -s EXIT_RUNTIME=1"
+ )
+
+ target_link_libraries(onnxruntime_webassembly_test PUBLIC
+ onnxruntime_webassembly
+ GTest::gtest
+ )
+
+ find_program(NODE_EXECUTABLE node required)
+ if (NOT NODE_EXECUTABLE)
+ message(FATAL_ERROR "Node is required for a test")
+ endif()
+
+ add_test(NAME onnxruntime_webassembly_test
+ COMMAND ${NODE_EXECUTABLE} onnxruntime_webassembly_test.js
+ WORKING_DIRECTORY $
+ )
+ endif()
else()
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s SAFE_HEAP=0 -s STACK_OVERFLOW_CHECK=0 -s DEMANGLE_SUPPORT=0")
-endif()
+ file(GLOB_RECURSE onnxruntime_webassembly_src CONFIGURE_DEPENDS
+ "${ONNXRUNTIME_ROOT}/wasm/api.cc"
+ )
-# Set link flag to enable exceptions support, this will override default disabling exception throwing behavior when disable exceptions.
-if (onnxruntime_ENABLE_WEBASSEMBLY_EXCEPTION_THROWING)
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s DISABLE_EXCEPTION_THROWING=0")
-endif()
+ source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_webassembly_src})
-if (onnxruntime_ENABLE_WEBASSEMBLY_PROFILING)
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " --profiling --profiling-funcs")
-endif()
+ add_executable(onnxruntime_webassembly
+ ${onnxruntime_webassembly_src}
+ )
+
+ target_link_libraries(onnxruntime_webassembly PRIVATE
+ nsync_cpp
+ ${PROTOBUF_LIB}
+ onnx
+ onnx_proto
+ onnxruntime_common
+ onnxruntime_flatbuffers
+ onnxruntime_framework
+ onnxruntime_graph
+ onnxruntime_mlas
+ onnxruntime_optimizer
+ onnxruntime_providers
+ onnxruntime_session
+ onnxruntime_util
+ re2::re2
+ )
+
+ if (onnxruntime_ENABLE_TRAINING OR onnxruntime_ENABLE_TRAINING_OPS)
+ target_link_libraries(onnxruntime_webassembly PRIVATE tensorboard)
+ endif()
+
+ set(EXPORTED_RUNTIME_METHODS "['stackAlloc','stackRestore','stackSave','UTF8ToString','stringToUTF8','lengthBytesUTF8']")
-if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
- if (onnxruntime_ENABLE_WEBASSEMBLY_SIMD)
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasmSimdThreaded -s USE_PTHREADS=1")
- set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm-simd-threaded")
+ set_target_properties(onnxruntime_webassembly PROPERTIES LINK_FLAGS " \
+ -s \"EXPORTED_RUNTIME_METHODS=${EXPORTED_RUNTIME_METHODS}\" \
+ -s WASM=1 \
+ -s NO_EXIT_RUNTIME=0 \
+ -s ALLOW_MEMORY_GROWTH=1 \
+ -s MODULARIZE=1 \
+ -s EXPORT_ALL=0 \
+ -s LLD_REPORT_UNDEFINED \
+ -s VERBOSE=0 \
+ -s NO_FILESYSTEM=1 \
+ --closure 1 \
+ --no-entry")
+
+ if (onnxruntime_EMSCRIPTEN_SETTINGS)
+ foreach(setting IN LISTS onnxruntime_EMSCRIPTEN_SETTINGS)
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS
+ " -s ${setting}")
+ endforeach()
+ endif()
+
+ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=1 -s DEMANGLE_SUPPORT=1")
else()
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasmThreaded -s USE_PTHREADS=1")
- set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm-threaded")
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s SAFE_HEAP=0 -s STACK_OVERFLOW_CHECK=0 -s DEMANGLE_SUPPORT=0")
endif()
-else()
- if (onnxruntime_ENABLE_WEBASSEMBLY_SIMD)
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasmSimd")
- set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm-simd")
+
+ # Set link flag to enable exceptions support, this will override default disabling exception throwing behavior when disable exceptions.
+ if (onnxruntime_ENABLE_WEBASSEMBLY_EXCEPTION_THROWING)
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s DISABLE_EXCEPTION_THROWING=0")
+ endif()
+
+ if (onnxruntime_ENABLE_WEBASSEMBLY_PROFILING)
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " --profiling --profiling-funcs")
+ endif()
+
+ if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
+ if (onnxruntime_ENABLE_WEBASSEMBLY_SIMD)
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasmSimdThreaded -s USE_PTHREADS=1")
+ set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm-simd-threaded")
+ else()
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasmThreaded -s USE_PTHREADS=1")
+ set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm-threaded")
+ endif()
else()
- set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasm")
- set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm")
+ if (onnxruntime_ENABLE_WEBASSEMBLY_SIMD)
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasmSimd")
+ set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm-simd")
+ else()
+ set_property(TARGET onnxruntime_webassembly APPEND_STRING PROPERTY LINK_FLAGS " -s EXPORT_NAME=ortWasm")
+ set_target_properties(onnxruntime_webassembly PROPERTIES OUTPUT_NAME "ort-wasm")
+ endif()
endif()
endif()
diff --git a/cmake/patches/abseil/Fix_Nvidia_Build_Break.patch b/cmake/patches/abseil/Fix_Nvidia_Build_Break.patch
new file mode 100644
index 0000000000000..f8e4750cbccff
--- /dev/null
+++ b/cmake/patches/abseil/Fix_Nvidia_Build_Break.patch
@@ -0,0 +1,63 @@
+diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h
+index 1d7d6cd..f6a7a78 100644
+--- a/absl/container/internal/inlined_vector.h
++++ b/absl/container/internal/inlined_vector.h
+@@ -904,7 +904,7 @@ auto Storage::Swap(Storage* other_storage_ptr) -> void {
+ inlined_ptr->GetSize());
+ }
+ ABSL_INTERNAL_CATCH_ANY {
+- allocated_ptr->SetAllocation(
++ allocated_ptr->SetAllocation(Allocation
+ {allocated_storage_view.data, allocated_storage_view.capacity});
+ ABSL_INTERNAL_RETHROW;
+ }
+@@ -912,7 +912,7 @@ auto Storage::Swap(Storage* other_storage_ptr) -> void {
+ DestroyElements(inlined_ptr->GetAllocator(),
+ inlined_ptr->GetInlinedData(), inlined_ptr->GetSize());
+
+- inlined_ptr->SetAllocation(
++ inlined_ptr->SetAllocation(Allocation
+ {allocated_storage_view.data, allocated_storage_view.capacity});
+ }
+
+diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake
+index a4ab1aa..dfd13fd 100644
+--- a/absl/copts/GENERATED_AbseilCopts.cmake
++++ b/absl/copts/GENERATED_AbseilCopts.cmake
+@@ -129,8 +129,6 @@ list(APPEND ABSL_MSVC_FLAGS
+ "/wd4005"
+ "/wd4068"
+ "/wd4180"
+- "/wd4244"
+- "/wd4267"
+ "/wd4503"
+ "/wd4800"
+ )
+diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
+index a6efc98..8c4de8e 100644
+--- a/absl/copts/GENERATED_copts.bzl
++++ b/absl/copts/GENERATED_copts.bzl
+@@ -130,8 +130,6 @@ ABSL_MSVC_FLAGS = [
+ "/wd4005",
+ "/wd4068",
+ "/wd4180",
+- "/wd4244",
+- "/wd4267",
+ "/wd4503",
+ "/wd4800",
+ ]
+diff --git a/absl/copts/copts.py b/absl/copts/copts.py
+index 0d6c1ec..75fd935 100644
+--- a/absl/copts/copts.py
++++ b/absl/copts/copts.py
+@@ -132,10 +132,6 @@ COPT_VARS = {
+ "/wd4068", # unknown pragma
+ # qualifier applied to function type has no meaning; ignored
+ "/wd4180",
+- # conversion from 'type1' to 'type2', possible loss of data
+- "/wd4244",
+- # conversion from 'size_t' to 'type', possible loss of data
+- "/wd4267",
+ # The decorated name was longer than the compiler limit
+ "/wd4503",
+ # forcing value to bool 'true' or 'false' (performance warning)
diff --git a/cmake/store_toolchain.cmake b/cmake/store_toolchain.cmake
deleted file mode 100644
index ebdb88da7752c..0000000000000
--- a/cmake/store_toolchain.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-set(CMAKE_SYSTEM_NAME WindowsStore)
-set(CMAKE_SYSTEM_VERSION 10.0)
-if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
- set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
-endif()
diff --git a/cmake/target_delayload.cmake b/cmake/target_delayload.cmake
index c776b2529a2b9..53f252a3e71ac 100644
--- a/cmake/target_delayload.cmake
+++ b/cmake/target_delayload.cmake
@@ -9,9 +9,6 @@ function(target_delayload target_name)
foreach(lib ${ARGN})
target_link_options(${target_name} PRIVATE /DELAYLOAD:"${lib}")
endforeach()
- if (WINDOWS_STORE)
- target_link_libraries(${target_name} PRIVATE dloadhelper.lib)
- else()
- target_link_libraries(${target_name} PRIVATE delayimp.lib)
- endif()
+
+ target_link_libraries(${target_name} PRIVATE delayimp.lib)
endfunction()
diff --git a/cmake/winml_unittests.cmake b/cmake/winml_unittests.cmake
index f7da46124b879..6e14591224886 100644
--- a/cmake/winml_unittests.cmake
+++ b/cmake/winml_unittests.cmake
@@ -190,7 +190,7 @@ set_winml_target_properties(winml_google_test_lib)
set_winml_target_properties(winml_test_common)
get_winml_test_api_src(${WINML_TEST_SRC_DIR} winml_test_api_src)
-if (NOT WINDOWS_STORE AND NOT ${winml_is_inbox})
+if (NOT ${winml_is_inbox})
get_winml_test_api_redist_only_src(${WINML_TEST_SRC_DIR} winml_test_api_redist_only_src)
endif()
diff --git a/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml b/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml
index 62067797bcd6d..dc9c71d5cee34 100644
--- a/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml
+++ b/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml
@@ -7,7 +7,9 @@
-
+
+
+
diff --git a/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml.cs b/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml.cs
index 257bbd009ba86..749c1d518fe88 100644
--- a/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml.cs
+++ b/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Forms/MainPage.xaml.cs
@@ -1,4 +1,7 @@
using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Xamarin.Essentials;
using Xamarin.Forms;
namespace Microsoft.ML.OnnxRuntime.InferenceSample.Forms
@@ -10,7 +13,7 @@ public MainPage()
InitializeComponent();
// in general create the inference session (which loads and optimizes the model) once and not per inference
- // as it can be expensive and time consuming.
+ // as it can be expensive and time consuming.
inferenceSampleApi = new InferenceSampleApi();
}
@@ -18,34 +21,68 @@ protected override void OnAppearing()
{
base.OnAppearing();
- Console.WriteLine("Using API");
- inferenceSampleApi.Execute();
- Console.WriteLine("Done");
-
- // demonstrate a range of usages by recreating the inference session with different session options.
- Console.WriteLine("Using API (using default platform-specific session options)");
- inferenceSampleApi.CreateInferenceSession(SessionOptionsContainer.Create());
- inferenceSampleApi.Execute();
- Console.WriteLine("Done");
-
- Console.WriteLine("Using API (using named platform-specific session options)");
- inferenceSampleApi.CreateInferenceSession(SessionOptionsContainer.Create("ort_with_npu"));
- inferenceSampleApi.Execute();
- Console.WriteLine("Done");
-
- Console.WriteLine(
- "Using API (using default platform-specific session options via ApplyConfiguration extension)");
- inferenceSampleApi.CreateInferenceSession(new SessionOptions().ApplyConfiguration());
- inferenceSampleApi.Execute();
- Console.WriteLine("Done");
-
- Console.WriteLine(
- "Using API (using named platform-specific session options via ApplyConfiguration extension)");
- inferenceSampleApi.CreateInferenceSession(new SessionOptions().ApplyConfiguration("ort_with_npu"));
- inferenceSampleApi.Execute();
- Console.WriteLine("Done");
+ OutputLabel.Text = "Press 'Run Tests'.\n";
}
private readonly InferenceSampleApi inferenceSampleApi;
+
+ private async Task ExecuteTests()
+ {
+ Action