Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions c_cxx/QNN_EP/mobilenetv2_classification/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
10 changes: 8 additions & 2 deletions c_cxx/QNN_EP/mobilenetv2_classification/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -253,6 +253,12 @@ 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);
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading