@@ -321,29 +321,50 @@ Status QnnModel::DeserializeGraphInfoFromBinaryInfo(const QnnSystemContext_Graph
321
321
std::vector<QnnTensorWrapper> output_tensor_wrappers;
322
322
323
323
std::string graph_name;
324
- if (qnn_sys_ctx_graph_info.version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_1) {
324
+ Qnn_Tensor_t* input_tensors = nullptr ;
325
+ Qnn_Tensor_t* output_tensors = nullptr ;
326
+ uint32_t graph_input_num = 0 ;
327
+ uint32_t graph_output_num = 0 ;
328
+ if (qnn_sys_ctx_graph_info.version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_3) {
329
+ graph_name.assign (qnn_sys_ctx_graph_info.graphInfoV3 .graphName );
330
+ graph_input_num = qnn_sys_ctx_graph_info.graphInfoV3 .numGraphInputs ;
331
+ graph_output_num = qnn_sys_ctx_graph_info.graphInfoV3 .numGraphOutputs ;
332
+
333
+ input_tensors = qnn_sys_ctx_graph_info.graphInfoV3 .graphInputs ;
334
+ output_tensors = qnn_sys_ctx_graph_info.graphInfoV3 .graphOutputs ;
335
+ } else if (qnn_sys_ctx_graph_info.version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_2) {
336
+ graph_name.assign (qnn_sys_ctx_graph_info.graphInfoV2 .graphName );
337
+ graph_input_num = qnn_sys_ctx_graph_info.graphInfoV2 .numGraphInputs ;
338
+ graph_output_num = qnn_sys_ctx_graph_info.graphInfoV2 .numGraphOutputs ;
339
+
340
+ input_tensors = qnn_sys_ctx_graph_info.graphInfoV2 .graphInputs ;
341
+ output_tensors = qnn_sys_ctx_graph_info.graphInfoV2 .graphOutputs ;
342
+ } else if (qnn_sys_ctx_graph_info.version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_1) {
325
343
graph_name.assign (qnn_sys_ctx_graph_info.graphInfoV1 .graphName );
326
- auto graph_input_num = qnn_sys_ctx_graph_info.graphInfoV1 .numGraphInputs ;
327
- auto graph_output_num = qnn_sys_ctx_graph_info.graphInfoV1 .numGraphOutputs ;
328
- ORT_RETURN_IF (nullptr == qnn_sys_ctx_graph_info.graphInfoV1 .graphInputs , " Graph from cached context doesn't have any inputs." );
329
- ORT_RETURN_IF (nullptr == qnn_sys_ctx_graph_info.graphInfoV1 .graphOutputs , " Graph from cached context doesn't have any outputs." );
330
-
331
- // Copy graph input
332
- Qnn_Tensor_t* input_tensors = qnn_sys_ctx_graph_info.graphInfoV1 .graphInputs ;
333
- for (size_t i = 0 ; i < graph_input_num; ++i) {
334
- QnnTensorWrapper tensorwrapper;
335
- ORT_RETURN_IF_ERROR (tensorwrapper.Init (input_tensors[i]));
336
- input_tensor_wrappers.push_back (std::move (tensorwrapper));
337
- }
344
+ graph_input_num = qnn_sys_ctx_graph_info.graphInfoV1 .numGraphInputs ;
345
+ graph_output_num = qnn_sys_ctx_graph_info.graphInfoV1 .numGraphOutputs ;
338
346
339
- // Copy graph output
340
- Qnn_Tensor_t* output_tensors = qnn_sys_ctx_graph_info.graphInfoV1 .graphOutputs ;
341
- for (size_t i = 0 ; i < graph_output_num; ++i) {
342
- QnnTensorWrapper tensorwrapper;
343
- ORT_RETURN_IF_ERROR (tensorwrapper.Init (output_tensors[i]));
344
- output_tensor_wrappers.push_back (std::move (tensorwrapper));
345
- }
347
+ input_tensors = qnn_sys_ctx_graph_info.graphInfoV1 .graphInputs ;
348
+ output_tensors = qnn_sys_ctx_graph_info.graphInfoV1 .graphOutputs ;
349
+ } else {
350
+ return ORT_MAKE_STATUS (ONNXRUNTIME, FAIL, " Unsupported context graph info version." );
351
+ }
352
+ ORT_RETURN_IF (nullptr == input_tensors, " Graph from cached context doesn't have any inputs." );
353
+ ORT_RETURN_IF (nullptr == output_tensors, " Graph from cached context doesn't have any outputs." );
354
+
355
+ // Copy graph input
356
+ for (size_t i = 0 ; i < graph_input_num; ++i) {
357
+ QnnTensorWrapper tensorwrapper;
358
+ ORT_RETURN_IF_ERROR (tensorwrapper.Init (input_tensors[i]));
359
+ input_tensor_wrappers.push_back (std::move (tensorwrapper));
346
360
}
361
+ // Copy graph output
362
+ for (size_t i = 0 ; i < graph_output_num; ++i) {
363
+ QnnTensorWrapper tensorwrapper;
364
+ ORT_RETURN_IF_ERROR (tensorwrapper.Init (output_tensors[i]));
365
+ output_tensor_wrappers.push_back (std::move (tensorwrapper));
366
+ }
367
+
347
368
Qnn_GraphHandle_t graph;
348
369
auto qnn_interface = qnn_backend_manager_->GetQnnInterface ();
349
370
auto rt = qnn_interface.graphRetrieve (context, graph_name.c_str (), &graph);
0 commit comments