Skip to content

Commit 91fb865

Browse files
yf711jchen351mszhanyisnnnwangyems
authored
[ORT 1.18.1 Release] Cherry pick 1st round (#21105)
### Description <!-- Describe your changes. --> ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Jian Chen <[email protected]> Co-authored-by: Yi Zhang <[email protected]> Co-authored-by: Changming Sun <[email protected]> Co-authored-by: Ye Wang <[email protected]> Co-authored-by: Your Name <[email protected]>
1 parent 4573740 commit 91fb865

File tree

129 files changed

+1907
-2120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1907
-2120
lines changed

.pipelines/OneBranch.Nuget-WindowsAI-Pipeline.Official.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ extends:
173173
$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))
174174
[System.IO.Compression.ZipFile]::ExtractToDirectory($arm64_static_runtime_nuget_package, $arm64_static_runtime_nupkg_unzipped_directory)
175175
176-
176+
177177
178178
$x64_static_runtime_path_old = [System.IO.Path]::Combine($x64_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-x64', '_native')
179179
$x64_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x64', '_native', 'static')
@@ -185,7 +185,7 @@ extends:
185185
$arm64_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
186186
$arm64_static_runtime_path_old = [System.IO.Path]::Combine($arm64_static_runtime_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
187187
$arm64_static_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native', 'static')
188-
188+
189189
$uap_build_path_old = [System.IO.Path]::Combine($x64_static_runtime_nupkg_unzipped_directory, 'build', 'native')
190190
$uap_build_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'build', 'uap10.0')
191191
@@ -262,7 +262,7 @@ extends:
262262
$x86_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x86', '_native')
263263
$arm64_runtime_path_old = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
264264
$arm64_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', '_native')
265-
265+
266266
New-Item -Path $x86_runtime_path_new -ItemType Directory
267267
New-Item -Path $arm64_runtime_path_new -ItemType Directory
268268
@@ -293,12 +293,21 @@ extends:
293293
- script: |
294294
dir $(Build.SourcesDirectory)\unzipped\runtimes\win-x64\_native
295295
296-
- task: EsrpCodeSigning@2
296+
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
297297
displayName: "Sign Nuget package"
298298
inputs:
299-
ConnectedServiceName: 'OnnxRuntime CodeSign 20190817'
299+
ConnectedServiceName: 'OnnxrunTimeCodeSign_20240611'
300+
AppRegistrationClientId: '53d54d02-978d-4305-8572-583cf6711c4f'
301+
AppRegistrationTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
302+
AuthAKVName: 'buildkeyvault'
303+
AuthCertName: '53d54d02-SSL-AutoRotate'
304+
AuthSignCertName: '53d54d02-978d-4305-8572-583cf6711c4f'
305+
300306
FolderPath: $(Build.ArtifactStagingDirectory)
301307
Pattern: '*.nupkg'
308+
SessionTimeout: 90
309+
ServiceEndpointUrl: 'https://api.esrp.microsoft.com/api/v2'
310+
MaxConcurrency: 25
302311
signConfigType: inlineSignParams
303312
inlineOperation: |
304313
[
@@ -307,14 +316,14 @@ extends:
307316
"operationSetCode": "NuGetSign",
308317
"parameters": [ ],
309318
"toolName": "sign",
310-
"toolVersion": "1.0"
319+
"toolVersion": "6.2.9304.0"
311320
},
312321
{
313322
"keyCode": "CP-401405",
314323
"operationSetCode": "NuGetVerify",
315324
"parameters": [ ],
316325
"toolName": "sign",
317-
"toolVersion": "1.0"
326+
"toolVersion": "6.2.9304.0"
318327
}
319328
]
320329

cmake/CMakeLists.txt

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ if (NOT CMAKE_BUILD_TYPE)
5959
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo MinSizeRel." FORCE)
6060
endif()
6161

62-
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 8)
63-
message(FATAL_ERROR "GCC version must be greater than or equal to 8")
62+
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
63+
message(FATAL_ERROR "GCC version must be greater than or equal to 9")
6464
endif()
6565

6666
# Options
@@ -1294,12 +1294,6 @@ if (onnxruntime_USE_TVM)
12941294
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES tvm)
12951295
endif()
12961296

1297-
# needs to link with stdc++fs in Linux
1298-
if (UNIX AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
1299-
set(FS_STDLIB stdc++fs)
1300-
endif()
1301-
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${FS_STDLIB})
1302-
13031297
# onnxruntime-extensions
13041298
if (onnxruntime_USE_EXTENSIONS)
13051299
include(extensions)
@@ -1468,16 +1462,6 @@ if (onnxruntime_USE_CUDA)
14681462
endif()
14691463
endif()
14701464

1471-
if (onnxruntime_USE_TENSORRT)
1472-
# needs to link with stdc++fs in Linux
1473-
if (UNIX)
1474-
if (NOT APPLE)
1475-
set(FS_STDLIB stdc++fs)
1476-
endif()
1477-
endif()
1478-
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${FS_STDLIB})
1479-
endif()
1480-
14811465
if (onnxruntime_USE_MIGRAPHX)
14821466
if (WIN32)
14831467
message(FATAL_ERROR "MIGraphX does not support build in Windows!")

cmake/onnxruntime_providers_migraphx.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
target_compile_options(onnxruntime_providers_migraphx PRIVATE -Wno-error=sign-compare)
5050
set_property(TARGET onnxruntime_providers_migraphx APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
5151
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")
52-
target_link_libraries(onnxruntime_providers_migraphx PRIVATE nsync::nsync_cpp stdc++fs)
52+
target_link_libraries(onnxruntime_providers_migraphx PRIVATE nsync::nsync_cpp)
5353

5454
include(CheckLibraryExists)
5555
check_library_exists(migraphx::c "migraphx_program_run_async" "/opt/rocm/migraphx/lib" HAS_STREAM_SYNC)

cmake/onnxruntime_providers_tensorrt.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
elseif(UNIX)
207207
set_property(TARGET onnxruntime_providers_tensorrt APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-deprecated-declarations")
208208
set_property(TARGET onnxruntime_providers_tensorrt APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/tensorrt/version_script.lds -Xlinker --gc-sections")
209-
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE nsync::nsync_cpp stdc++fs)
209+
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE nsync::nsync_cpp)
210210
elseif(WIN32)
211211
set_property(TARGET onnxruntime_providers_tensorrt APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${ONNXRUNTIME_ROOT}/core/providers/tensorrt/symbols.def")
212212
else()

java/build.gradle

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id 'signing'
55
id 'jacoco'
66
id "com.diffplug.spotless" version "6.25.0"
7+
id "net.linguica.maven-settings" version "0.5"
78
}
89

910
allprojects {
@@ -19,6 +20,12 @@ version = rootProject.file('../VERSION_NUMBER').text.trim()
1920
def cmakeBuildDir = System.properties['cmakeBuildDir']
2021
def useCUDA = System.properties['USE_CUDA']
2122
def useROCM = System.properties['USE_ROCM']
23+
24+
def adoArtifact = project.findProperty('adoArtifact')
25+
def adoAccessToken = project.findProperty('adoAccessToken')
26+
// Only publish to ADO feed if all two properties are set
27+
def publishToAdo = adoArtifact != null && adoAccessToken != null
28+
2229
boolean enableTrainingApis = (System.properties['ENABLE_TRAINING_APIS'] ?: "0") == "1"
2330
def cmakeJavaDir = "${cmakeBuildDir}/java"
2431
def cmakeNativeLibDir = "${cmakeJavaDir}/native-lib"
@@ -37,6 +44,11 @@ def trainingDescription = 'ONNX Runtime Training is a training and inference pac
3744
'(Open Neural Network Exchange) models. This package is targeted for Learning on The Edge aka On-Device Training ' +
3845
'See https://github.com/microsoft/onnxruntime-training-examples/tree/master/on_device_training for more details.'
3946

47+
// We need to have a custom settings.xml so codeql can bypass the need for settings.security.xml
48+
mavenSettings {
49+
userSettingsFileName = "${projectDir}/settings.xml"
50+
}
51+
4052
java {
4153
sourceCompatibility = JavaVersion.VERSION_1_8
4254
targetCompatibility = JavaVersion.VERSION_1_8
@@ -48,7 +60,8 @@ jar {
4860
}
4961

5062
// Add explicit sources jar with pom file.
51-
task sourcesJar(type: Jar, dependsOn: classes) {
63+
tasks.register('sourcesJar', Jar) {
64+
dependsOn classes
5265
archiveClassifier = "sources"
5366
from sourceSets.main.allSource
5467
into("META-INF/maven/$project.group/$mavenArtifactId") {
@@ -58,7 +71,8 @@ task sourcesJar(type: Jar, dependsOn: classes) {
5871
}
5972

6073
// Add explicit javadoc jar with pom file
61-
task javadocJar(type: Jar, dependsOn: javadoc) {
74+
tasks.register('javadocJar', Jar) {
75+
dependsOn javadoc
6276
archiveClassifier = "javadoc"
6377
from javadoc.destinationDir
6478
into("META-INF/maven/$project.group/$mavenArtifactId") {
@@ -82,7 +96,7 @@ spotless {
8296

8397
compileJava {
8498
dependsOn spotlessJava
85-
options.compilerArgs += ["-h", "${project.buildDir}/headers/"]
99+
options.compilerArgs += ["-h", "${layout.buildDirectory.get().toString()}/headers/"]
86100
if (!JavaVersion.current().isJava8()) {
87101
// Ensures only methods present in Java 8 are used
88102
options.compilerArgs.addAll(['--release', '8'])
@@ -128,7 +142,7 @@ if (cmakeBuildDir != null) {
128142
// generate tasks to be called from cmake
129143

130144
// Overwrite jar location
131-
task allJar(type: Jar) {
145+
tasks.register('allJar', Jar) {
132146
manifest {
133147
attributes('Automatic-Module-Name': project.group,
134148
'Implementation-Title': 'onnxruntime',
@@ -143,23 +157,20 @@ if (cmakeBuildDir != null) {
143157
from cmakeNativeLibDir
144158
}
145159

146-
task cmakeBuild(type: Copy) {
147-
from project.buildDir
160+
tasks.register('cmakeBuild', Copy) {
161+
from layout.buildDirectory.get()
148162
include 'libs/**'
149163
include 'docs/**'
150164
into cmakeBuildOutputDir
165+
dependsOn(allJar, sourcesJar, javadocJar, javadoc)
151166
}
152-
cmakeBuild.dependsOn allJar
153-
cmakeBuild.dependsOn sourcesJar
154-
cmakeBuild.dependsOn javadocJar
155-
cmakeBuild.dependsOn javadoc
156167

157-
task cmakeCheck(type: Copy) {
158-
from project.buildDir
168+
tasks.register('cmakeCheck', Copy) {
169+
from layout.buildDirectory.get()
159170
include 'reports/**'
160171
into cmakeBuildOutputDir
172+
dependsOn(check)
161173
}
162-
cmakeCheck.dependsOn check
163174
}
164175

165176
dependencies {
@@ -198,17 +209,22 @@ jacocoTestReport {
198209
reports {
199210
xml.required = true
200211
csv.required = true
201-
html.destination file("${buildDir}/jacocoHtml")
212+
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
202213
}
203214
}
204215

205216
publishing {
206217
publications {
207218
maven(MavenPublication) {
208219
groupId = project.group
209-
artifactId = mavenArtifactId
210-
211-
from components.java
220+
if(publishToAdo) {
221+
artifactId = 'onnxruntime_gpu'
222+
artifact (adoArtifact)
223+
} else {
224+
artifactId = mavenArtifactId
225+
from components.java
226+
}
227+
version = project.version
212228
pom {
213229
name = enableTrainingApis ? 'onnxruntime-training' : 'onnx-runtime'
214230
description = enableTrainingApis ? trainingDescription : defaultDescription
@@ -239,24 +255,41 @@ publishing {
239255
}
240256
}
241257
repositories {
242-
maven {
243-
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
244-
credentials {
245-
username mavenUser
246-
password mavenPwd
258+
if (publishToAdo) {
259+
maven {
260+
url "https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/${System.getenv('ADOFeedName')}/maven/v1"
261+
name System.getenv('ADOFeedName')
262+
authentication {
263+
basic(BasicAuthentication)
264+
}
265+
credentials {
266+
username 'aiinfra'
267+
password "${project.findProperty('adoAccessToken')}"
268+
}
269+
}
270+
} else {
271+
maven {
272+
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
273+
credentials {
274+
username mavenUser
275+
password mavenPwd
276+
}
247277
}
248278
}
249279
}
250280
}
251-
252281
// Generates a task signMavenPublication that will
253282
// build all artifacts.
254283
signing {
255284
// Queries env vars:
256285
// ORG_GRADLE_PROJECT_signingKey
257286
// ORG_GRADLE_PROJECT_signingPassword but can be changed to properties
258-
def signingKey = findProperty("signingKey")
259-
def signingPassword = findProperty("signingPassword")
260-
useInMemoryPgpKeys(signingKey, signingPassword)
261-
sign publishing.publications.maven
287+
def signingKey = findProperty("signingKey")
288+
def signingPassword = findProperty("signingPassword")
289+
// Skip signing if no key is provided
290+
if (signingKey != null && signingPassword != null) {
291+
useInMemoryPgpKeys(signingKey, signingPassword)
292+
sign publishing.publications.maven
293+
sign publishing.publications.mavenAdo
294+
}
262295
}

java/settings.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--The only purpose of this file is to let codeql bypass the need for settings.security.xml-->
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
5+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
6+
<servers>
7+
<!-- password is coming from cli -PadoAccessToken -->
8+
</servers>
9+
</settings>

onnxruntime/contrib_ops/cuda/quantization/moe_quantization.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ Status QMoE::ComputeInternal(OpKernelContext* context) const {
5454
const Tensor* fc3_scales_optional = context->Input<Tensor>(9);
5555
const Tensor* fc3_experts_bias_optional = context->Input<Tensor>(10);
5656

57+
#if defined(__GNUC__)
58+
#pragma GCC diagnostic push
59+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // Mute "maybe used uninitialized" warning for MoEParameters.
60+
#endif
61+
5762
MoEParameters moe_params;
5863
MoEQuantType quant_type = MoEQuantType::UINT4;
5964
ORT_RETURN_IF_ERROR(CheckInputs(moe_params, quant_type, input, router_probs, fc1_experts_weights,
@@ -135,6 +140,10 @@ Status QMoE::ComputeInternal(OpKernelContext* context) const {
135140
reinterpret_cast<int*>(expert_for_source_row.get()), static_cast<int>(moe_params.num_rows),
136141
static_cast<int>(moe_params.hidden_size), static_cast<int>(k_), Stream(context));
137142

143+
#if defined(__GNUC__)
144+
#pragma GCC diagnostic pop
145+
#endif
146+
138147
return Status::OK();
139148
}
140149

onnxruntime/core/providers/tensorrt/tensorrt_execution_provider_utils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
#include <sstream>
99
#include <iostream>
1010
#include <filesystem>
11-
#include <experimental/filesystem>
1211
#include "flatbuffers/idl.h"
1312
#include "ort_trt_int8_cal_table.fbs.h"
1413
#include <NvInferVersion.h>
1514
#include "core/providers/cuda/cuda_pch.h"
1615
#include "core/common/path_string.h"
1716
#include "core/framework/murmurhash3.h"
1817

19-
namespace fs = std::experimental::filesystem;
18+
namespace fs = std::filesystem;
2019

2120
namespace onnxruntime {
2221

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
optimum>=1.14.1
22
transformers>=4.33.2,<= 4.37.2
33
torch>=2.2.0
4-
onnx>=1.14.0
4+
onnx==1.16.0
55
datasets>=2.8.0
66
protobuf==3.20.2
77
psutil
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
onnx>=1.15.0
1+
onnx==1.16.0
22
transformers>=4.36.2
33
onnxscript>=0.1.0.dev20240126

0 commit comments

Comments
 (0)