Skip to content

Commit 5328421

Browse files
quic-alokpandquic-zhanweiw
authored andcommitted
Add support for QNN Binary Info V3
Signed-off-by: Alok Kumar Pandey <[email protected]>
1 parent 216166c commit 5328421

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/Utils/QnnSampleAppUtils.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,35 @@ bool sample_app::copyTensorsInfo(const Qnn_Tensor_t *tensorsInfoSrc,
249249
return returnStatus;
250250
}
251251

252+
bool sample_app::copyGraphsInfoV3(const QnnSystemContext_GraphInfoV3_t* graphInfoSrc,
253+
qnn_wrapper_api::GraphInfo_t* graphInfoDst) {
254+
graphInfoDst->graphName = nullptr;
255+
if (graphInfoSrc->graphName) {
256+
graphInfoDst->graphName =
257+
pal::StringOp::strndup(graphInfoSrc->graphName, strlen(graphInfoSrc->graphName));
258+
}
259+
graphInfoDst->inputTensors = nullptr;
260+
graphInfoDst->numInputTensors = 0;
261+
if (graphInfoSrc->graphInputs) {
262+
if (!copyTensorsInfo(
263+
graphInfoSrc->graphInputs, graphInfoDst->inputTensors, graphInfoSrc->numGraphInputs)) {
264+
return false;
265+
}
266+
graphInfoDst->numInputTensors = graphInfoSrc->numGraphInputs;
267+
}
268+
graphInfoDst->outputTensors = nullptr;
269+
graphInfoDst->numOutputTensors = 0;
270+
if (graphInfoSrc->graphOutputs) {
271+
if (!copyTensorsInfo(graphInfoSrc->graphOutputs,
272+
graphInfoDst->outputTensors,
273+
graphInfoSrc->numGraphOutputs)) {
274+
return false;
275+
}
276+
graphInfoDst->numOutputTensors = graphInfoSrc->numGraphOutputs;
277+
}
278+
return true;
279+
}
280+
252281
bool sample_app::copyGraphsInfoV1(const QnnSystemContext_GraphInfoV1_t *graphInfoSrc,
253282
qnn_wrapper_api::GraphInfo_t *graphInfoDst) {
254283
graphInfoDst->graphName = nullptr;
@@ -301,6 +330,9 @@ bool sample_app::copyGraphsInfo(const QnnSystemContext_GraphInfo_t *graphsInput,
301330
if (graphsInput[gIdx].version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_1) {
302331
copyGraphsInfoV1(&graphsInput[gIdx].graphInfoV1, &graphInfoArr[gIdx]);
303332
}
333+
else if (graphsInput[gIdx].version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_3) {
334+
copyGraphsInfoV3(&graphsInput[gIdx].graphInfoV3, &graphInfoArr[gIdx]);
335+
}
304336
graphsInfo[gIdx] = graphInfoArr + gIdx;
305337
}
306338
}
@@ -359,6 +391,18 @@ bool sample_app::copyMetadataToGraphsInfo(const QnnSystemContext_BinaryInfo_t *b
359391
return true;
360392
}
361393
}
394+
else if (binaryInfo->version == QNN_SYSTEM_CONTEXT_BINARY_INFO_VERSION_3) {
395+
if (binaryInfo->contextBinaryInfoV3.graphs) {
396+
if (!copyGraphsInfo(binaryInfo->contextBinaryInfoV3.graphs,
397+
binaryInfo->contextBinaryInfoV3.numGraphs,
398+
graphsInfo)) {
399+
QNN_ERROR("Failed while copying graphs Info.");
400+
return false;
401+
}
402+
graphsCount = binaryInfo->contextBinaryInfoV3.numGraphs;
403+
return true;
404+
}
405+
}
362406
QNN_ERROR("Unrecognized system context binary info version.");
363407
return false;
364408
}

src/Utils/QnnSampleAppUtils.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ bool copyGraphsInfo(const QnnSystemContext_GraphInfo_t *graphsInput,
6363
bool copyGraphsInfoV1(const QnnSystemContext_GraphInfoV1_t *graphInfoSrc,
6464
qnn_wrapper_api::GraphInfo_t *graphInfoDst);
6565

66+
bool copyGraphsInfoV3(const QnnSystemContext_GraphInfoV3_t *graphInfoSrc,
67+
qnn_wrapper_api::GraphInfo_t *graphInfoDst);
68+
6669
bool copyTensorsInfo(const Qnn_Tensor_t *tensorsInfoSrc,
6770
Qnn_Tensor_t *&tensorWrappers,
6871
uint32_t tensorsCount);

0 commit comments

Comments
 (0)