1818#include < pybind11/stl.h>
1919#include < memory>
2020#include < string_view>
21+ #include " QnnTypes.h"
2122
2223namespace py = pybind11;
2324namespace executorch {
@@ -34,7 +35,7 @@ class PyQnnManager {
3435 auto qnn_executorch_options = GetQnnExecuTorchOptions (
3536 qnn_executorch_option_ptr_.cast <std::string_view>().data ());
3637 qnn_manager_ = std::make_shared<QnnManager>(
37- qnn_executorch_options, qnn_executorch_context_binary_);
38+ qnn_executorch_options, qnn_executorch_context_binary_, false );
3839 }
3940
4041 // used for loading context binary directly
@@ -47,7 +48,7 @@ class PyQnnManager {
4748 qnn_executorch_context_binary_.buffer = info.ptr ;
4849 qnn_executorch_context_binary_.nbytes = info.size * info.itemsize ;
4950 qnn_manager_ = std::make_shared<QnnManager>(
50- qnn_executorch_options, qnn_executorch_context_binary_);
51+ qnn_executorch_options, qnn_executorch_context_binary_, false );
5152 }
5253
5354 // used during stage 2 of multi-graph mode
@@ -160,7 +161,12 @@ class PyQnnManager {
160161 qnn_executorch_context_binary_ =
161162 MakeQcirCustomBinaryInfo (qcir_bin, tensor_data);
162163 qnn_manager_ = std::make_shared<QnnManager>(
163- qnn_executorch_options, qnn_executorch_context_binary_);
164+ qnn_executorch_options, qnn_executorch_context_binary_, false );
165+ }
166+
167+ std::vector<int > GetQnnAPIVersion () {
168+ return {
169+ QNN_API_VERSION_MAJOR, QNN_API_VERSION_MINOR, QNN_API_VERSION_PATCH};
164170 }
165171
166172 executorch::runtime::Error Init () {
@@ -195,7 +201,7 @@ class PyQnnManager {
195201 std::vector<std::shared_ptr<OpWrapper>>& op_wrappers) {
196202 QnnExecuTorchContextBinary binary_info;
197203
198- if (qnn_manager_->IsOnlinePrepare () || qnn_manager_-> IsMultipleGraphs ()) {
204+ if (qnn_manager_->IsMultipleGraphs ()) {
199205 builder_.Reset ();
200206 std::vector<uint8_t > tensor_data;
201207 std::vector<uint64_t > offsets;
@@ -305,8 +311,11 @@ class PyQnnManager {
305311 QNN_EXECUTORCH_LOG_ERROR (" Fail to compile QNN graph" );
306312 return py::array_t <char >(0 );
307313 }
308- if (qnn_manager_->GetContextBinary (binary_info) !=
309- executorch::runtime::Error::Ok) {
314+ auto qnn_executorch_options = GetQnnExecuTorchOptions (
315+ qnn_executorch_option_ptr_.cast <std::string_view>().data ());
316+ if (qnn_executorch_options->saver () ||
317+ qnn_manager_->GetContextBinary (binary_info) !=
318+ executorch::runtime::Error::Ok) {
310319 return py::array_t <char >(0 );
311320 }
312321 }
0 commit comments