Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Split Onnxruntime Nuget GPU package #18819

Merged
merged 46 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
de152ed
use flexdownload
mszhanyi Dec 5, 2023
e0f8f6c
add dependency
mszhanyi Dec 7, 2023
e3806e2
mv CUDA runtime
mszhanyi Dec 8, 2023
d3e907f
runtime
mszhanyi Dec 11, 2023
8f2fa45
add new msbuild task
mszhanyi Dec 11, 2023
2e180d5
temp disable package validation
mszhanyi Dec 11, 2023
8f199e7
typo
mszhanyi Dec 11, 2023
2a69f77
readd dotnet6.0
mszhanyi Dec 12, 2023
a260de8
netcoreapp3.1
mszhanyi Dec 12, 2023
250464b
Merge branch 'main' of https://github.com/microsoft/onnxruntime into …
mszhanyi Dec 14, 2023
b17c277
validate package
mszhanyi Dec 14, 2023
2549187
validate package1
mszhanyi Dec 14, 2023
42fe4bc
update
mszhanyi Dec 14, 2023
315d1c7
update
mszhanyi Dec 14, 2023
37ce9ca
fix
mszhanyi Dec 14, 2023
d059354
add build_dir
mszhanyi Dec 14, 2023
d47c136
Merge branch 'main' of https://github.com/microsoft/onnxruntime into …
mszhanyi Dec 14, 2023
93b2490
rm useless change
mszhanyi Dec 15, 2023
332fce2
check gpu_dependent
mszhanyi Dec 15, 2023
168c8b7
lint runner
mszhanyi Dec 15, 2023
6deb08a
update
mszhanyi Dec 15, 2023
b1607b3
flex download
mszhanyi Dec 15, 2023
05565cb
update
mszhanyi Dec 15, 2023
ce99728
update props.xml
mszhanyi Dec 15, 2023
87cf991
update Onnxrunitme.CSharp.proj
mszhanyi Dec 16, 2023
79d3b00
Merge branch 'main' of https://github.com/microsoft/onnxruntime into …
mszhanyi Dec 16, 2023
4ef8654
rename as comments
mszhanyi Dec 19, 2023
8e31c6c
rename 2
mszhanyi Dec 19, 2023
7e9071c
headers
mszhanyi Dec 19, 2023
4a5c10f
lint
mszhanyi Dec 19, 2023
1879bd5
generate sub package in one proj file
mszhanyi Dec 19, 2023
9205851
some refactor
mszhanyi Dec 19, 2023
aebb1d4
refact csproj
mszhanyi Dec 20, 2023
9204bae
make GPU.windows and GPU.linux can work
mszhanyi Dec 20, 2023
a4d2886
minor fix
mszhanyi Dec 20, 2023
a3da35b
update validate
mszhanyi Dec 20, 2023
0c277f8
fix
mszhanyi Dec 20, 2023
2fbde0e
typo
mszhanyi Dec 21, 2023
11834ba
add tests for new Gpu.Windows and Gpu.Linux
mszhanyi Dec 21, 2023
857c62a
update
mszhanyi Dec 21, 2023
c1d02b3
update description
mszhanyi Dec 21, 2023
1618cf2
run gpu test with new package
mszhanyi Dec 21, 2023
78c0c55
Update tools/nuget/generate_nuspec_for_native_nuget.py
mszhanyi Dec 21, 2023
84e24c9
wording
mszhanyi Dec 22, 2023
b7d49e5
Merge branch 'zhanyi/nugetpackage' of https://github.com/microsoft/on…
mszhanyi Dec 22, 2023
6af5361
fix lint
mszhanyi Dec 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 41 additions & 19 deletions csharp/OnnxRuntime.CSharp.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ CMake creates a target to this project
<IsWindowsBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindowsBuild>
<IsLinuxBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinuxBuild>
<ExecutionProvider Condition=" '$(ExecutionProvider)' == '' ">None</ExecutionProvider>
<IsPlatformSpecificSubPackage Condition=" '$(IsPlatformSpecificSubPackage)' == '' ">false</IsPlatformSpecificSubPackage>
<NuSpecName Condition=" '$(NuSpecName)' == '' ">NativeNuget.nuspec</NuSpecName>

<!-- include Xamarin/MAUI Android and iOS target frameworks? Command line property overrides this value. -->
<IncludeMobileTargets>true</IncludeMobileTargets>
Expand All @@ -45,6 +47,13 @@ CMake creates a target to this project
<PythonExe>python</PythonExe>
</PropertyGroup>

<PropertyGroup>
<!-- If we create multiple nuget packages in one job, major package and dependent packages version should be the same-->
<!-- CurrentDate and CurrentTime are only used for dev packages-->
<CurrentDate Condition="'$(CurrentDate)'==''">$([System.DateTime]::UtcNow.ToString(yyyyMMdd))</CurrentDate>
<CurrentTime Condition="'$(CurrentTime)'==''">$([System.DateTime]::UtcNow.ToString(hhmm))</CurrentTime>
</PropertyGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

<Target Name="Build">
Expand All @@ -58,7 +67,7 @@ CMake creates a target to this project
</Exec>
</Target>

<Target Name="ObtainPackageVersion" BeforeTargets="Build;CreatePackage;CreateWindowsAIPackage">
<Target Name="ObtainPackageVersion" BeforeTargets="Build;CreatePackage;CreateWindowsAIPackage;CreateNativePackage">
<ReadLinesFromFile File="..\VERSION_NUMBER">
<Output TaskParameter="Lines" ItemName="MajorVersionNumber"/>
</ReadLinesFromFile>
Expand All @@ -81,8 +90,6 @@ CMake creates a target to this project
<Output TaskParameter="AbsolutePaths" PropertyName="OnnxRuntimeSourceDirectoryAbs"/>
</ConvertToAbsolutePath>
<PropertyGroup>
<CurrentDate>$([System.DateTime]::UtcNow.ToString(yyyyMMdd))</CurrentDate>
<CurrentTime>$([System.DateTime]::UtcNow.ToString(hhmm))</CurrentTime>
<PackageVersion>@(MajorVersionNumber)</PackageVersion>
<PackageVersion>$(PackageVersion)$(ReleaseVersionSuffix)</PackageVersion>
<Version>$(PackageVersion)</Version>
Expand All @@ -91,23 +98,10 @@ CMake creates a target to this project
<Message Importance="High" Text="PackageVersion=$(PackageVersion)" />
</Target>

<Target Name="CreatePackage">
<!-- Validate no missing UnmanagedFunctionPointer attributes on delegates. -->
<Exec Condition="'$(IsWindowsBuild)' == 'true' AND $(OrtPackageId) == 'Microsoft.ML.OnnxRuntime'"
Command="$(PythonExe) tools/ValidateNativeDelegateAttributes.py"
ContinueOnError="False">
<Output TaskParameter="ConsoleOutput" PropertyName="GenerateNuspecOutput" />
</Exec>

<!-- Create Microsoft.ML.OnnxRuntime.Managed with the C# bindings using the C# project -->
<Message Importance="High" Text="Creating Microsoft.ML.OnnxRuntime.Managed nuget package..." />
<MSBuild Projects="src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj"
Targets="CopyMiscFiles;Pack"
Properties="NoBuild=true;Platform=AnyCPU;PackageVersion=$(PackageVersion);OrtPackageId=$(OrtPackageId);IncludeMobileTargets=$(IncludeMobileTargets)"/>

<Target Name="CreateNativePackage">
<!-- Manually create the nuspec for the native Microsoft.ML.OnnxRuntime package -->
<Message Importance="High" Text="Generating nuspec for the native Microsoft.ML.OnnxRuntime nuget package..." />
mszhanyi marked this conversation as resolved.
Show resolved Hide resolved
<Exec Command="$(PythonExe) $(GenerateNuspecScript) --package_version $(PackageVersion) --package_name $(OrtPackageId) --target_architecture $(TargetArchitecture) --build_config $(Configuration) --native_build_path $(NativeBuildOutputDirAbs) --packages_path $(OnnxRuntimePackagesDirectoryAbs) --ort_build_path $(OnnxRuntimeBuildDirectoryAbs) --sources_path $(OnnxRuntimeSourceDirectoryAbs) --commit_id $(GitCommitHash) --is_release_build $(IsReleaseBuild) --execution_provider $(ExecutionProvider)"
<Exec Command="$(PythonExe) $(GenerateNuspecScript) --package_version $(PackageVersion) --package_name $(OrtPackageId) --target_architecture $(TargetArchitecture) --build_config $(Configuration) --native_build_path $(NativeBuildOutputDirAbs) --packages_path $(OnnxRuntimePackagesDirectoryAbs) --ort_build_path $(OnnxRuntimeBuildDirectoryAbs) --sources_path $(OnnxRuntimeSourceDirectoryAbs) --commit_id $(GitCommitHash) --is_release_build $(IsReleaseBuild) --execution_provider $(ExecutionProvider) --nuspec_name $(NuSpecName)"
ContinueOnError="False"
ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GenerateNuspecOutput" />
Expand All @@ -116,7 +110,7 @@ CMake creates a target to this project
<!-- run `nuget pack` on Windows or `dotnet pack` on Linux to create the native nupkg -->
<Message Importance="High" Text="Bundling native shared library artifacts into Microsoft.ML.OnnxRuntime nuget package..." />
<Exec Condition=" '$(IsWindowsBuild)' == 'true'"
Command="$(NugetExe) pack NativeNuget.nuspec"
Command="$(NugetExe) pack $(NuSpecName)"
WorkingDirectory="$(NativeBuildOutputDirAbs)"
ContinueOnError="False"
ConsoleToMSBuild="true">
Expand Down Expand Up @@ -144,6 +138,34 @@ CMake creates a target to this project
/>
</Target>

<Target Name="CreatePackage">
<!-- Validate no missing UnmanagedFunctionPointer attributes on delegates. -->
<Exec Condition="'$(IsWindowsBuild)' == 'true' AND $(OrtPackageId) == 'Microsoft.ML.OnnxRuntime'"
Command="$(PythonExe) tools/ValidateNativeDelegateAttributes.py"
ContinueOnError="False">
<Output TaskParameter="ConsoleOutput" PropertyName="GenerateNuspecOutput" />
</Exec>

<!-- Create Microsoft.ML.OnnxRuntime.Managed with the C# bindings using the C# project -->
<Message Condition="'$(IsPlatformSpecificSubPackage)'!='True'" Importance="High" Text="Creating Microsoft.ML.OnnxRuntime.Managed nuget package..." />
<MSBuild Condition="'$(IsPlatformSpecificSubPackage)'!='True'" Projects="src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj"
Targets="CopyMiscFiles;Pack"
Properties="NoBuild=true;Platform=AnyCPU;PackageVersion=$(PackageVersion);OrtPackageId=$(OrtPackageId);IncludeMobileTargets=$(IncludeMobileTargets)"/>

<MSBuild Projects ="$(MSBuildProjectFullPath)"
Targets ="CreateNativePackage" />

</Target>

<Target Name="CreateAllGpuPackages" AfterTargets="CreatePackage" Condition="'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Gpu'">
<MSBuild Projects ="$(MSBuildProjectFullPath)"
Properties="NuSpecName=NativeGpuWinNuget.nuspec;OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu.Windows"
Targets ="CreateNativePackage" />
<MSBuild Projects ="$(MSBuildProjectFullPath)"
Properties="NuSpecName=NativeGpuLinuxNuget.nuspec;OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu.Linux"
Targets ="CreateNativePackage" />
</Target>

<ItemGroup>
<LicenseFile Include="$(OnnxRuntimeSourceDirectory)\LICENSE"/>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PropertyGroup>
<EnginePlatform Condition="'$(Platform)' == 'Win32'">x86</EnginePlatform>
<EnginePlatform Condition="'$(Platform)' == 'ARM64'">arm64</EnginePlatform>
<EnginePlatform Condition="'$(Platform)' == 'ARM'">arm</EnginePlatform>
<EnginePlatform Condition="'$(Platform)' == 'ARM'">arm</EnginePlatform>
<EnginePlatform Condition="'$(Platform)' != 'Win32' AND '$(Platform)' != 'ARM64'">$(Platform)</EnginePlatform>
</PropertyGroup>

Expand All @@ -55,7 +55,8 @@
<ItemGroup>
<!-- x64 -->
<None Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x64\native\onnxruntime.dll"
Condition="'$(PlatformTarget)' == 'x64' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' != 'true')">
Condition="('$(PlatformTarget)' == 'x64' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' != 'true')) AND
Exists('$(MSBuildThisFileDirectory)..\..\runtimes\win-x64\native\onnxruntime.dll')">
<Link>onnxruntime.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
Expand Down Expand Up @@ -146,8 +147,8 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</None>
<!-- x86 -->

<!-- x86 -->
<None Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\onnxruntime.dll"
Condition="('$(PlatformTarget)' == 'x86' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' == 'true'))">
<Link>onnxruntime.dll</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ IF NOT errorlevel 0 (
%dn% list test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj package
dir test\Microsoft.ML.OnnxRuntime.EndToEndTests\packages\

IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu" (
set gpu_package=F
IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu" set gpu_package=T
IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu.Windows" set gpu_package=T
IF %%gpu_package%%=="T" (
set TESTONGPU=ON
%dn% test -p:DefineConstants=USE_TENSORRT test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --filter TensorRT
%dn% test -p:DefineConstants=USE_TENSORRT test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --filter TensorRT

IF NOT errorlevel 0 (
@echo "Failed to build or execute the end-to-end test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,45 @@
set -x -e

pushd .
cd $BUILD_SOURCESDIRECTORY

Check notice on line 15 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L15 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:15:4: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)

echo "Current NuGet package version is $CurrentOnnxRuntimeVersion"

if [ $RunTestCsharp = "true" ]; then

Check notice on line 19 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L19 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:19:6: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
if [[ $IsMacOS == "True" || $IsMacOS == "true" ]]; then
# TODO(#12040): The test should figure out the opset version from the model file. Remove it from the path.
ONNX_DIR="${BUILD_SOURCESDIRECTORY}/cmake/external/onnx"
ONNX_VERSION_NUMBER=$(cat "${ONNX_DIR}/VERSION_NUMBER" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/')

Check notice on line 23 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L23 <ShellCheck.SC2002>

Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:23:31: info: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. (ShellCheck.SC2002)
OPSET_VERSION=$(grep "${ONNX_VERSION_NUMBER}" "${ONNX_DIR}/docs/Versioning.md" | sed -E "s/${ONNX_VERSION_NUMBER}\|[^|]+\|([0-9]+)\|.*/\1/")
mkdir -p "${BUILD_BINARIESDIRECTORY}/models"
ln -s "${ONNX_DIR}/onnx/backend/test/data/node" "${BUILD_BINARIESDIRECTORY}/models/opset${OPSET_VERSION}"
fi
# Run C# tests
dotnet restore $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj -s $LocalNuGetRepo -s https://api.nuget.org/v3/index.json

Check notice on line 29 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L29 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:29:18: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)

Check notice on line 29 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L29 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:29:142: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
if [ $? -ne 0 ]; then

Check notice on line 30 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L30 <ShellCheck.SC2181>

Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:30:8: info: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. (ShellCheck.SC2181)
echo "Failed to restore nuget packages for the test project"
exit 1
fi

if [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu" ]; then
if [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu" ] || [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu.Linux" ]; then

Check notice on line 35 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L35 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:35:8: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)

Check notice on line 35 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L35 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:35:61: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
export TESTONGPU=ON
dotnet test -p:DefineConstants=USE_CUDA $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed

Check notice on line 37 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L37 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:37:45: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
if [ $? -ne 0 ]; then

Check notice on line 38 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L38 <ShellCheck.SC2181>

Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:38:10: info: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. (ShellCheck.SC2181)
echo "Failed to build or execute the end-to-end test"
exit 1
fi
dotnet test -p:DefineConstants=USE_TENSORRT $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed

Check notice on line 42 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L42 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:42:49: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
elif [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.ROCm" ]; then

Check notice on line 43 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L43 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:43:11: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
export TESTONGPU=ON
dotnet test -p:DefineConstants=USE_ROCM $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed

Check notice on line 45 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L45 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:45:45: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
else
dotnet test $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed

Check notice on line 47 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L47 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:47:17: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
fi
if [ $? -ne 0 ]; then

Check notice on line 49 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L49 <ShellCheck.SC2181>

Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:49:8: info: Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. (ShellCheck.SC2181)
echo "Failed to build or execute the end-to-end test"
exit 1
fi
fi

cd $OldDir

Check warning on line 55 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L55 <ShellCheck.SC2154>

OldDir is referenced but not assigned.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:55:4: warning: OldDir is referenced but not assigned. (ShellCheck.SC2154)

Check notice on line 55 in csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh#L55 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh:55:4: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
popd
Original file line number Diff line number Diff line change
Expand Up @@ -708,39 +708,52 @@ stages:
variables:
breakCodesignValidationInjection: ${{ parameters.DoEsrp }}
ReleaseVersionSuffix: $[stageDependencies.Setup.Set_Variables.outputs['Set_Release_Version_Suffix.ReleaseVersionSuffix']]
BuildDate: $[format('{0:yyyyMMdd}', pipeline.startTime)]
BuildTime: $[format('{0:HHmm}', pipeline.startTime)]

steps:
- checkout: self
submodules: true
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact - NuGet'
inputs:
artifactName: 'onnxruntime-win-x64-cuda'
targetPath: '$(Build.BinariesDirectory)/nuget-artifact'

- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact - NuGet'
inputs:
artifactName: 'onnxruntime-win-x64-tensorrt'
targetPath: '$(Build.BinariesDirectory)/nuget-artifact'
- template: templates/flex-downloadPipelineArtifact.yml
parameters:
StepName: 'Download Pipeline Artifact - NuGet'
ArtifactName: 'onnxruntime-win-x64-cuda'
TargetPath: '$(Build.BinariesDirectory)/nuget-artifact'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact - NuGet'
inputs:
artifactName: 'onnxruntime-linux-x64-cuda'
targetPath: '$(Build.BinariesDirectory)/nuget-artifact'
- template: templates/flex-downloadPipelineArtifact.yml
parameters:
StepName: 'Download Pipeline Artifact - NuGet'
ArtifactName: 'onnxruntime-win-x64-tensorrt'
TargetPath: '$(Build.BinariesDirectory)/nuget-artifact'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact - NuGet'
inputs:
artifactName: 'onnxruntime-linux-x64-tensorrt'
targetPath: '$(Build.BinariesDirectory)/nuget-artifact'
- template: templates/flex-downloadPipelineArtifact.yml
parameters:
StepName: 'Download Pipeline Artifact - NuGet'
ArtifactName: 'onnxruntime-linux-x64-cuda'
TargetPath: '$(Build.BinariesDirectory)/nuget-artifact'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact - NuGet'
inputs:
artifactName: 'drop-extra'
targetPath: '$(Build.BinariesDirectory)/extra-artifact'
- template: templates/flex-downloadPipelineArtifact.yml
parameters:
StepName: 'Download Pipeline Artifact - NuGet'
ArtifactName: 'onnxruntime-linux-x64-tensorrt'
TargetPath: '$(Build.BinariesDirectory)/nuget-artifact'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

- template: templates/flex-downloadPipelineArtifact.yml
parameters:
StepName: 'Download Pipeline Artifact - NuGet'
ArtifactName: 'drop-extra'
TargetPath: '$(Build.BinariesDirectory)/extra-artifact'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

# Reconstruct the build dir
- task: PowerShell@2
Expand Down Expand Up @@ -797,12 +810,13 @@ stages:
DoEsrp: ${{ parameters.DoEsrp }}

- task: MSBuild@1
displayName: 'Build Nuget Packages'
displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu'
inputs:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj'
configuration: RelWithDebInfo
platform: 'Any CPU'
msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)'
msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }}
-p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime)'
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- task: BatchScript@1
Expand Down Expand Up @@ -842,8 +856,25 @@ stages:
parameters:
PackageType: 'nuget'
PackagePath: '$(Build.ArtifactStagingDirectory)'
PackageName: 'Microsoft.ML.OnnxRuntime.*nupkg'
PlatformsSupported: 'win-x64,linux-x64'
# 1* stands for version number. we use it to fileter Gpu.Windows and Gpu.Linux packages
PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.1*nupkg'
VerifyNugetSigning: false

- template: templates/validate-package.yml
parameters:
PackageType: 'nuget'
PackagePath: '$(Build.ArtifactStagingDirectory)'
PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Windows.*nupkg'
PlatformsSupported: 'win-x64'
VerifyNugetSigning: false

- template: templates/validate-package.yml
parameters:
PackageType: 'nuget'
PackagePath: '$(Build.ArtifactStagingDirectory)'
PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Linux.*nupkg'
PlatformsSupported: 'linux-x64'
VerifyNugetSigning: false

- task: PublishPipelineArtifact@0
Expand Down Expand Up @@ -1104,6 +1135,19 @@ stages:
ArtifactSuffix: 'GPU'
StageSuffix: 'GPU'
Skipx86Tests: 'true'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

- template: nuget/templates/test_win.yml
parameters:
AgentPool : 'onnxruntime-Win2022-GPU-T4'
NugetPackageName : 'Microsoft.ML.OnnxRuntime.Gpu.Windows'
ArtifactSuffix: 'GPU'
StageSuffix: 'GPU'
MoreSuffix: '_Windows'
Skipx86Tests: 'true'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

- template: nuget/templates/test_linux.yml
parameters:
Expand All @@ -1114,6 +1158,16 @@ stages:
SpecificArtifact: ${{ parameters.specificArtifact }}
BuildId: ${{ parameters.BuildId }}

- template: nuget/templates/test_linux.yml
parameters:
AgentPool : Onnxruntime-Linux-GPU
ArtifactSuffix: 'GPU'
StageSuffix: 'GPU'
MoreSuffix: '_Linux'
NugetPackageName : 'Microsoft.ML.OnnxRuntime.Gpu.Linux'
SpecificArtifact: ${{ parameters.specificArtifact }}
BuildId: ${{ parameters.BuildId }}

- template: nuget/templates/test_linux.yml
parameters:
AgentPool: AMD-GPU
Expand Down Expand Up @@ -1321,4 +1375,4 @@ stages:
displayName: 'Publish Pipeline NuGet Artifact'
inputs:
artifactName: 'drop-signed-nuget-dml'
targetPath: '$(Build.ArtifactStagingDirectory)'
targetPath: '$(Build.ArtifactStagingDirectory)'
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ stages:
StageSuffix: 'GPU'
Skipx86Tests: 'true'
CudaVersion: ${{ parameters.CudaVersion }}
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}
## Linux GPU Testing
- template: nuget/templates/test_linux.yml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ parameters:
ArtifactSuffix: ''
NugetPackageName : ''
StageSuffix: 'CPU'
MoreSuffix: ''
NativePackagePrefix: 'onnxruntime'
SpecificArtifact: false
CustomOpArtifactName: 'onnxruntime-linux-x64'
BuildId: '0'
CudaVersion: '11.8'
stages:
- stage: NuGet_Test_Linux_${{ parameters.StageSuffix }}
- stage: NuGet_Test_Linux_${{ parameters.StageSuffix }}${{ parameters.MoreSuffix }}
dependsOn:
- NuGet_Packaging_${{ parameters.StageSuffix }}
condition: succeeded()
Expand Down
18 changes: 12 additions & 6 deletions tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ parameters:
NugetPackageName : ''
ArtifactSuffix: ''
StageSuffix: 'CPU'
# More Suffix is used to differentiate testing for GPU and GPU-Windows/GPU-Linux packages
MoreSuffix: ''
# For inference packages, the test data artifact name is drop-extra and no suffix is required.
# For training packages, to differentiate the artifact name we add '-training' suffix. This needs to be passed from
# the parent pipeline.
TestDataArtifactSuffix: ''
Skipx86Tests: 'false'
CudaVersion: ''
SpecificArtifact: false
BuildId: ''

stages:
- stage: NuGet_Test_Win_${{ parameters.StageSuffix }}
- stage: NuGet_Test_Win_${{ parameters.StageSuffix }}${{ parameters.MoreSuffix }}
dependsOn:
- NuGet_Packaging_${{ parameters.StageSuffix }}
condition: succeeded()
Expand Down Expand Up @@ -58,11 +62,13 @@ stages:
arguments: 'amd64'
modifyEnvironment: true

- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact'
inputs:
artifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }}
targetPath: '$(Build.BinariesDirectory)\nuget-artifact'
- template: ../../templates/flex-downloadPipelineArtifact.yml
parameters:
StepName: 'Download Pipeline Artifact'
ArtifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }}
TargetPath: '$(Build.BinariesDirectory)\nuget-artifact'
SpecificArtifact: ${{ parameters.SpecificArtifact }}
BuildId: ${{ parameters.BuildId }}

- template: get-nuget-package-version-as-variable.yml
parameters:
Expand Down
Loading
Loading