Skip to content

Commit

Permalink
Qnn nuget update (#20527)
Browse files Browse the repository at this point in the history
### Description
Update Qnn nuget package to include Qnn libs and license file
  • Loading branch information
HectorSVC committed May 1, 2024
1 parent 91baeb8 commit 755aaea
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 8 deletions.
6 changes: 6 additions & 0 deletions cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,12 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
COMMAND ${CMAKE_COMMAND} -E copy ${QNN_LIB_FILES} $<TARGET_FILE_DIR:${test_data_target}>
)
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" $<TARGET_FILE_DIR:${test_data_target}>
)
endif()
endif()

if (onnxruntime_USE_DNNL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down Expand Up @@ -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)) {
Expand All @@ -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
Expand Down
34 changes: 34 additions & 0 deletions tools/nuget/generate_nuspec_for_native_nuget.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,33 @@ def generate_files(line_list, args):
"<file src=" + '"' + os.path.join(args.native_build_path, "onnxruntime_perf_test.exe") + runtimes + " />"
)

if is_qnn_package:
files_list.append("<file src=" + '"' + os.path.join(args.native_build_path, "QnnCpu.dll") + runtimes + " />")
files_list.append("<file src=" + '"' + os.path.join(args.native_build_path, "QnnHtp.dll") + runtimes + " />")
files_list.append("<file src=" + '"' + os.path.join(args.native_build_path, "QnnSaver.dll") + runtimes + " />")
if args.target_architecture != "x64":
files_list.append(
"<file src=" + '"' + os.path.join(args.native_build_path, "QnnSystem.dll") + runtimes + " />"
)
files_list.append(
"<file src=" + '"' + os.path.join(args.native_build_path, "QnnHtpPrepare.dll") + runtimes + " />"
)
files_list.append(
"<file src=" + '"' + os.path.join(args.native_build_path, "QnnHtpV73Stub.dll") + runtimes + " />"
)
files_list.append(
"<file src=" + '"' + os.path.join(args.native_build_path, "libQnnHtpV73Skel.so") + runtimes + " />"
)
files_list.append(
"<file src=" + '"' + os.path.join(args.native_build_path, "libqnnhtpv73.cat") + runtimes + " />"
)
files_list.append(
"<file src=" + '"' + os.path.join(args.native_build_path, "QnnHtpV68Stub.dll") + runtimes + " />"
)
files_list.append(
"<file src=" + '"' + os.path.join(args.native_build_path, "libQnnHtpV68Skel.so") + runtimes + " />"
)

is_ado_packaging_build = False
# Process runtimes
# Process onnxruntime import lib, dll, and pdb
Expand Down Expand Up @@ -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(
"<file src="
+ '"'
+ os.path.join(args.native_build_path, "Qualcomm AI Hub Proprietary License.pdf")
+ '" target="Qualcomm AI Hub Proprietary License.pdf" />'
)
files_list.append("</files>")

line_list += files_list
Expand Down

0 comments on commit 755aaea

Please sign in to comment.