diff --git a/c_cxx/QNN_EP/mobilenetv2_classification/CMakeLists.txt b/c_cxx/QNN_EP/mobilenetv2_classification/CMakeLists.txt index c6810ce2d..164a55e06 100644 --- a/c_cxx/QNN_EP/mobilenetv2_classification/CMakeLists.txt +++ b/c_cxx/QNN_EP/mobilenetv2_classification/CMakeLists.txt @@ -25,6 +25,8 @@ target_link_libraries(qnn_ep_sample ${ORT_LIBS}) if(MSVC) target_link_directories(qnn_ep_sample PRIVATE ${ONNXRUNTIME_BUILDDIR}) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") else() target_link_directories(qnn_ep_sample PRIVATE ${ONNXRUNTIME_ROOTDIR}/build/Android/${CMAKE_BUILD_TYPE}) endif() diff --git a/c_cxx/QNN_EP/mobilenetv2_classification/main.cpp b/c_cxx/QNN_EP/mobilenetv2_classification/main.cpp index 444859232..002924978 100644 --- a/c_cxx/QNN_EP/mobilenetv2_classification/main.cpp +++ b/c_cxx/QNN_EP/mobilenetv2_classification/main.cpp @@ -9,13 +9,13 @@ #include <unordered_map> #include <memory> #include <algorithm> +#include <stdexcept> #include <onnxruntime_cxx_api.h> #include "onnxruntime_session_options_config_keys.h" bool CheckStatus(const OrtApi* g_ort, OrtStatus* status) { if (status != nullptr) { const char* msg = g_ort->GetErrorMessage(status); - std::cerr << msg << std::endl; g_ort->ReleaseStatus(status); throw Ort::Exception(msg, OrtErrorCode::ORT_EP_FAIL); } @@ -253,6 +253,13 @@ int main(int argc, char* argv[]) { std::string model_path(argv[2]); std::string input_path(argv[3]); - run_ort_qnn_ep(backend, model_path, input_path, generate_ctx, float32_model); + std::locale::global(std::locale("en_US.UTF-8")); + try { + run_ort_qnn_ep(backend, model_path, input_path, generate_ctx, float32_model); + } catch (const std::exception& e) { + std::cerr << "Exception in run_ort_qnn_ep: " << e.what() << std::endl; + } catch (...) { + std::cerr << "Unknown exception in run_ort_qnn_ep" << std::endl; + } return 0; } diff --git a/c_cxx/QNN_EP/mobilenetv2_classification/run_qnn_ep_sample.bat b/c_cxx/QNN_EP/mobilenetv2_classification/run_qnn_ep_sample.bat index aa302aec9..0db99043a 100644 --- a/c_cxx/QNN_EP/mobilenetv2_classification/run_qnn_ep_sample.bat +++ b/c_cxx/QNN_EP/mobilenetv2_classification/run_qnn_ep_sample.bat @@ -145,14 +145,16 @@ qnn_ep_sample.exe --htp mobilenetv2-12_quant_shape.onnx kitten_input.raw --gen_c REM TODO Check for mobilenetv2-12_quant_shape.onnx_ctx.onnx +@ECHO OFF IF EXIST mobilenetv2-12_quant_shape.onnx_ctx.onnx ( REM run mobilenetv2-12_quant_shape.onnx_ctx.onnx with QNN HTP backend (generted from previous step) + @ECHO ON qnn_ep_sample.exe --htp mobilenetv2-12_quant_shape.onnx_ctx.onnx kitten_input.raw ) ELSE ( 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 ) - +@ECHO ON REM run mobilenetv2-12_net_qnn_ctx.onnx (generated from native QNN) with QNN HTP backend qnn_ep_sample.exe --qnn mobilenetv2-12_net_qnn_ctx.onnx kitten_input_nhwc.raw