Skip to content

Commit 2a76152

Browse files
Update build and README with relevant changes for ONNX Runtime 1.18.0 (#425)
1 parent ff7ee24 commit 2a76152

File tree

3 files changed

+85
-19
lines changed

3 files changed

+85
-19
lines changed

c_cxx/accuracy_tool/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if(QNN_SDK_ROOTDIR)
3232
endif()
3333

3434
if(NOT QNN_HEXAGON_ARCH_VERSION)
35-
set(QNN_HEXAGON_ARCH_VERSION "68")
35+
set(QNN_HEXAGON_ARCH_VERSION "73")
3636
message(WARNING "Assuming QNN Hexagon version ${QNN_HEXAGON_ARCH_VERSION}. Set with -DQNN_HEXAGON_ARCH_VERSION")
3737
endif()
3838

@@ -94,12 +94,13 @@ endfunction()
9494
# Windows might have an onnxruntime.dll in the system directory so it's more robust to manually copy the dlls to
9595
# the output dir.
9696
if(MSVC)
97-
target_copy_artifacts(accuracy_test "${ONNXRUNTIME_ROOTDIR}/bin/*.dll")
97+
target_copy_artifacts(accuracy_test "${ONNXRUNTIME_ROOTDIR}/bin/*")
9898
endif()
9999

100100
if(EXISTS "${QNN_SDK_ROOTDIR}")
101101
set(QNN_SDK_HEX_DIR "${QNN_SDK_ROOTDIR}/lib/hexagon-v${QNN_HEXAGON_ARCH_VERSION}/unsigned")
102102
target_copy_artifacts(accuracy_test "${QNN_SDK_HEX_DIR}/*.so")
103+
target_copy_artifacts(accuracy_test "${QNN_SDK_HEX_DIR}/*.cat")
103104

104105
if(WIN32)
105106
set(QNN_WIN_ARCH_DIR "x86_64-windows-msvc")

c_cxx/accuracy_tool/README.md

Lines changed: 77 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@
22
This tool measures the accuracy of a set of models on a given execution provider. The accuracy is computed by comparing with the expected results, which are either loaded from file or attained by running the model with the CPU execution provider.
33

44
## Build instructions on Windows
5-
Run the following commands in a terminal to generate a Visual Studio project and compile the tool. Make sure to specify the location of your ONNX Runtime installation. You can either [download an ONNX Runtime release package](https://github.com/microsoft/onnxruntime/releases/) or you can [build ONNX Runtime from source](https://www.onnxruntime.ai/docs/build/).
5+
### Using an ONNX Runtime NuGet package
6+
Download an ONNX Runtime NuGet package with the desired execution provider(s):
7+
- [Microsoft.ML.OnnxRuntime](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime)
8+
- [Microsoft.ML.OnnxRuntime.QNN](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.QNN)
9+
- [Microsoft.ML.OnnxRuntime.Gpu](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.Gpu)
10+
- Others: https://www.nuget.org/packages?q=Microsoft.ML.OnnxRuntime
11+
12+
Clone this onnxruntime-inference-examples repository:
13+
```shell
14+
git clone https://github.com/Microsoft/onnxruntime-inference-examples.git
15+
cd onnxruntime-inference-examples\c_cxx\accuracy_tool
16+
```
617

18+
Run `build.bat` with the path to the ONNX Runtime NuGet package as the first argument.
719
```shell
8-
$ build.bat 'C:\onnxruntime'
20+
$ build.bat .\microsoft.ml.onnxruntime.1.18.0.nupkg
921
```
1022

1123
Run the following command to open the solution file with Visual Studio.
@@ -20,20 +32,76 @@ Alternatively, you can directly run the executable from the terminal:
2032
.\build\Release\accuracy_test.exe --help
2133
```
2234

23-
### Building with QNN execution provider
24-
To test model accuracy with the QNN execution provider, provide the path to location of your Qualcomm AI Engine Direct SDK (QNN SDK) and, optionally, the hexagon architecture version (e.g., 68 or 73).
25-
The QNN SDK can be downloaded from https://qpm.qualcomm.com/main/tools/details/qualcomm_ai_engine_direct.
26-
Providing the QNN SDK path will ensure that the appropriate QNN SDK dynamic libraries (e.g., QnnHtp.dll) are automatically copied to the build directory.
35+
### Using an ONNX Runtime source build
36+
#### Build ONNX Runtime from source
37+
Refer to the documentation for [building ONNX Runtime from source](https://www.onnxruntime.ai/docs/build/) with the desired execution providers.
38+
39+
The following commands build ONNX Runtime from source with the CPU EP.
40+
41+
Clone the ONNX Runtime repository:
42+
```shell
43+
git clone --recursive https://github.com/Microsoft/onnxruntime.git
44+
cd onnxruntime
45+
```
2746

47+
Build ONNX Runtime from source. Replace `<ORT_INSTALL_DIR>` with your desired installation directory.
2848
```shell
29-
$ build.bat 'C:\onnxruntime' 'C:\Qualcomm\AIStack\QNN\2.17.0.231124' 68
49+
.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --skip_tests --cmake_extra_defines CMAKE_INSTALL_PREFIX=<ORT_INSTALL_DIR>
3050
```
3151

52+
Install ONNX Runtime to `<ORT_INSTALL_DIR>`:
53+
```shell
54+
cmake --install .\build\RelWithDebInfo --config RelWithDebInfo
55+
```
56+
57+
#### Build accuracy tool
58+
Clone this onnxruntime-inference-examples repository:
59+
```shell
60+
git clone https://github.com/Microsoft/onnxruntime-inference-examples.git
61+
cd onnxruntime-inference-examples\c_cxx\accuracy_tool
62+
```
3263

33-
Note that you can also provide a [NuGet package](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.QNN) as the first argument to `build.bat`:
64+
Run `build.bat` with the path to the ONNX Runtime installation directory as the first argument.
65+
```shell
66+
$ build.bat <ORT_INSTALL_DIR>
67+
```
68+
69+
Run the following command to open the solution file with Visual Studio.
70+
71+
```shell
72+
$ devenv .\build\onnxruntime_accuracy_test.sln
73+
```
74+
75+
Alternatively, you can directly run the executable from the terminal:
3476

3577
```shell
36-
$ build.bat '.\microsoft.ml.onnxruntime.qnn.1.16.0.nupkg' 'C:\Qualcomm\AIStack\QNN\2.17.0.231124' 68
78+
.\build\Release\accuracy_test.exe --help
79+
```
80+
81+
### Using an ONNX Runtime Github release package
82+
Download an ONNX Runtime release package from https://github.com/microsoft/onnxruntime/releases/ and extract it to your desired installation directory (`<ORT_INSTALL_DIR>`).
83+
84+
Clone this onnxruntime-inference-examples repository:
85+
```shell
86+
git clone https://github.com/Microsoft/onnxruntime-inference-examples.git
87+
cd onnxruntime-inference-examples\c_cxx\accuracy_tool
88+
```
89+
90+
Run `build.bat` with the path to the extracted ONNX Runtime installation directory as the first argument.
91+
```shell
92+
$ build.bat <ORT_INSTALL_DIR>
93+
```
94+
95+
Run the following command to open the solution file with Visual Studio.
96+
97+
```shell
98+
$ devenv .\build\onnxruntime_accuracy_test.sln
99+
```
100+
101+
Alternatively, you can directly run the executable from the terminal:
102+
103+
```shell
104+
.\build\Release\accuracy_test.exe --help
37105
```
38106

39107
## Setup test models and inputs

c_cxx/accuracy_tool/build.bat

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,14 @@ IF "%~x1" == ".nupkg" (
4848
mkdir _generated_onnxruntime_rootdir\bin 2>nul
4949
copy /y _ort_extracted_nuget\build\native\include\* _generated_onnxruntime_rootdir\include\
5050
IF "%PROCESSOR_ARCHITECTURE%" == "ARM64" (
51-
copy /y _ort_extracted_nuget\runtimes\win-arm64\native\*.lib _generated_onnxruntime_rootdir\lib\
52-
copy /y _ort_extracted_nuget\runtimes\win-arm64\native\*.dll _generated_onnxruntime_rootdir\lib\
53-
copy /y _ort_extracted_nuget\runtimes\win-arm64\native\*.dll _generated_onnxruntime_rootdir\bin\
54-
copy /y _ort_extracted_nuget\runtimes\win-arm64\native\*.exe _generated_onnxruntime_rootdir\bin\
51+
copy /y _ort_extracted_nuget\runtimes\win-arm64\native\* _generated_onnxruntime_rootdir\lib\
52+
copy /y _ort_extracted_nuget\runtimes\win-arm64\native\* _generated_onnxruntime_rootdir\bin\
5553
) ELSE (
56-
copy /y _ort_extracted_nuget\runtimes\win-x64\native\*.lib _generated_onnxruntime_rootdir\lib\
57-
copy /y _ort_extracted_nuget\runtimes\win-x64\native\*.dll _generated_onnxruntime_rootdir\lib\
58-
copy /y _ort_extracted_nuget\runtimes\win-x64\native\*.dll _generated_onnxruntime_rootdir\bin\
59-
copy /y _ort_extracted_nuget\runtimes\win-x64\native\*.exe _generated_onnxruntime_rootdir\bin\
54+
copy /y _ort_extracted_nuget\runtimes\win-x64\native\* _generated_onnxruntime_rootdir\lib\
55+
copy /y _ort_extracted_nuget\runtimes\win-x64\native\* _generated_onnxruntime_rootdir\bin\
6056
)
6157
copy /y _ort_extracted_nuget\*.txt _generated_onnxruntime_rootdir\
58+
copy /y _ort_extracted_nuget\*.pdf _generated_onnxruntime_rootdir\
6259
copy /y _ort_extracted_nuget\LICENSE _generated_onnxruntime_rootdir\
6360
copy /y _ort_extracted_nuget\README.md _generated_onnxruntime_rootdir\
6461
copy /y _ort_extracted_nuget\Privacy.md _generated_onnxruntime_rootdir\

0 commit comments

Comments
 (0)