Skip to content

Commit 1479df6

Browse files
committed
Fix debug symbols and exception handling
1 parent 0a4a4dd commit 1479df6

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

c_cxx/QNN_EP/mobilenetv2_classification/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ target_link_libraries(qnn_ep_sample ${ORT_LIBS})
2525

2626
if(MSVC)
2727
target_link_directories(qnn_ep_sample PRIVATE ${ONNXRUNTIME_BUILDDIR})
28+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
29+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
2830
else()
2931
target_link_directories(qnn_ep_sample PRIVATE ${ONNXRUNTIME_ROOTDIR}/build/Android/${CMAKE_BUILD_TYPE})
3032
endif()

c_cxx/QNN_EP/mobilenetv2_classification/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
#include <unordered_map>
1010
#include <memory>
1111
#include <algorithm>
12+
#include <stdexcept>
1213
#include <onnxruntime_cxx_api.h>
1314
#include "onnxruntime_session_options_config_keys.h"
1415

1516
bool CheckStatus(const OrtApi* g_ort, OrtStatus* status) {
1617
if (status != nullptr) {
1718
const char* msg = g_ort->GetErrorMessage(status);
18-
std::cerr << msg << std::endl;
1919
g_ort->ReleaseStatus(status);
2020
throw Ort::Exception(msg, OrtErrorCode::ORT_EP_FAIL);
2121
}
@@ -253,6 +253,12 @@ int main(int argc, char* argv[]) {
253253
std::string model_path(argv[2]);
254254
std::string input_path(argv[3]);
255255

256-
run_ort_qnn_ep(backend, model_path, input_path, generate_ctx, float32_model);
256+
try {
257+
run_ort_qnn_ep(backend, model_path, input_path, generate_ctx, float32_model);
258+
} catch (const std::exception& e) {
259+
std::cerr << "Exception in run_ort_qnn_ep: " << e.what() << std::endl;
260+
} catch (...) {
261+
std::cerr << "Unknown exception in run_ort_qnn_ep" << std::endl;
262+
}
257263
return 0;
258264
}

c_cxx/QNN_EP/mobilenetv2_classification/run_qnn_ep_sample.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,16 @@ qnn_ep_sample.exe --htp mobilenetv2-12_quant_shape.onnx kitten_input.raw --gen_c
145145

146146
REM TODO Check for mobilenetv2-12_quant_shape.onnx_ctx.onnx
147147

148+
@ECHO OFF
148149
IF EXIST mobilenetv2-12_quant_shape.onnx_ctx.onnx (
149150
REM run mobilenetv2-12_quant_shape.onnx_ctx.onnx with QNN HTP backend (generted from previous step)
151+
@ECHO ON
150152
qnn_ep_sample.exe --htp mobilenetv2-12_quant_shape.onnx_ctx.onnx kitten_input.raw
151153
) ELSE (
152154
ECHO mobilenetv2-12_quant_shape.onnx_ctx.onnx does not exist. It didn't get generated in previous step. Are you using ONNX 1.17+? or build from latest main branch
153155
)
154156

155-
157+
@ECHO ON
156158
REM run mobilenetv2-12_net_qnn_ctx.onnx (generated from native QNN) with QNN HTP backend
157159
qnn_ep_sample.exe --qnn mobilenetv2-12_net_qnn_ctx.onnx kitten_input_nhwc.raw
158160

0 commit comments

Comments
 (0)