From 755aaea9a6d8b11b21ece58be0224b3ca3b31cb8 Mon Sep 17 00:00:00 2001 From: Hector Li Date: Tue, 30 Apr 2024 22:12:53 -0700 Subject: [PATCH] Qnn nuget update (#20527) ### Description Update Qnn nuget package to include Qnn libs and license file --- cmake/onnxruntime_unittests.cmake | 6 ++++ .../qnn-ep-nuget-packaging-pipeline.yml | 32 ++++++++++++----- .../nuget/generate_nuspec_for_native_nuget.py | 34 +++++++++++++++++++ 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index 3b8c8189e40f9..66df1158ec98e 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -999,6 +999,12 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP) COMMAND ${CMAKE_COMMAND} -E copy ${QNN_LIB_FILES} $ ) endif() + if (EXISTS "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf") + add_custom_command( + TARGET ${test_data_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${onnxruntime_QNN_HOME}/Qualcomm AI Hub Proprietary License.pdf" $ + ) + endif() endif() if (onnxruntime_USE_DNNL) diff --git a/tools/ci_build/github/azure-pipelines/qnn-ep-nuget-packaging-pipeline.yml b/tools/ci_build/github/azure-pipelines/qnn-ep-nuget-packaging-pipeline.yml index 98322ce24f75f..cbd849127683e 100644 --- a/tools/ci_build/github/azure-pipelines/qnn-ep-nuget-packaging-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/qnn-ep-nuget-packaging-pipeline.yml @@ -160,6 +160,19 @@ jobs: workingFolder: '$(Build.BinariesDirectory)\Win_arm64\${{ parameters.build_config }}' createLogFile: true + + - task: VSBuild@1 + displayName: 'Build onnxruntime_test_all arm64 (to copy Qnn libs)' + inputs: + solution: '$(Build.BinariesDirectory)\Win_arm64\${{ parameters.build_config }}\onnxruntime_test_all.vcxproj' + platform: ARM64 + configuration: ${{ parameters.build_config }} + msbuildArchitecture: ARM64 + maximumCpuCount: true + logProjectEvents: true + workingFolder: '$(Build.BinariesDirectory)\Win_arm64\${{ parameters.build_config }}' + createLogFile: true + - template: templates/win-esrp-dll.yml parameters: FolderPath: '$(Build.BinariesDirectory)\Win_arm64\${{ parameters.build_config }}\${{ parameters.build_config }}' @@ -224,15 +237,18 @@ jobs: $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) - $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') + $x64_runtime_path_old = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x64', 'native') + $x64_runtime_path_new = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory, 'runtimes', 'win-x64', 'native') - New-Item -Path $arm64_runtime_path_new -ItemType Directory + New-Item -Path $x64_runtime_path_new -ItemType Directory - 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, 'onnx_test_runner.exe')) $arm64_runtime_path_new - Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'onnxruntime_perf_test.exe')) $arm64_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_runtime_path_old, 'onnxruntime.dll')) $x64_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_runtime_path_old, 'onnxruntime.lib')) $x64_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_runtime_path_old, 'onnx_test_runner.exe')) $x64_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_runtime_path_old, 'onnxruntime_perf_test.exe')) $x64_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_runtime_path_old, 'QnnCpu.dll')) $x64_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_runtime_path_old, 'QnnHtp.dll')) $x64_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_runtime_path_old, 'QnnSaver.dll')) $x64_runtime_path_new $merged_nuget_path = [System.IO.Path]::Combine($Env:BUILD_ARTIFACTSTAGINGDIRECTORY, 'merged') if (!(Test-Path $merged_nuget_path)) { @@ -249,7 +265,7 @@ jobs: $zip_tool = [System.IO.Path]::Combine($zip_tool_directory, 'zip.exe') Invoke-WebRequest http://stahlworks.com/dev/zip.exe -OutFile $zip_tool - Start-Process -FilePath $zip_tool -ArgumentList "-r $merged_nuget ." -WorkingDirectory $x64_nupkg_unzipped_directory -NoNewWindow -Wait + Start-Process -FilePath $zip_tool -ArgumentList "-r $merged_nuget ." -WorkingDirectory $arm64_nupkg_unzipped_directory -NoNewWindow -Wait workingDirectory: $(Build.BinariesDirectory) - template: templates/esrp_nuget.yml diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 39490add8addf..dcb54e1920f0f 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -565,6 +565,33 @@ def generate_files(line_list, args): "" ) + if is_qnn_package: + files_list.append("") + files_list.append("") + files_list.append("") + if args.target_architecture != "x64": + files_list.append( + "" + ) + files_list.append( + "" + ) + files_list.append( + "" + ) + files_list.append( + "" + ) + files_list.append( + "" + ) + files_list.append( + "" + ) + files_list.append( + "" + ) + is_ado_packaging_build = False # Process runtimes # Process onnxruntime import lib, dll, and pdb @@ -1138,6 +1165,13 @@ def generate_files(line_list, args): + os.path.join(args.sources_path, "ORT_icon_for_light_bg.png") + '" target="ORT_icon_for_light_bg.png" />' ) + if is_qnn_package: + files_list.append( + "' + ) files_list.append("") line_list += files_list