Skip to content

Commit

Permalink
Add support for QNN Binary Info V3
Browse files Browse the repository at this point in the history
Signed-off-by: Alok Kumar Pandey <[email protected]>
  • Loading branch information
quic-alokpand authored and quic-zhanweiw committed Dec 17, 2024
1 parent 216166c commit 5328421
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Utils/QnnSampleAppUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,35 @@ bool sample_app::copyTensorsInfo(const Qnn_Tensor_t *tensorsInfoSrc,
return returnStatus;
}

bool sample_app::copyGraphsInfoV3(const QnnSystemContext_GraphInfoV3_t* graphInfoSrc,
qnn_wrapper_api::GraphInfo_t* graphInfoDst) {
graphInfoDst->graphName = nullptr;
if (graphInfoSrc->graphName) {
graphInfoDst->graphName =
pal::StringOp::strndup(graphInfoSrc->graphName, strlen(graphInfoSrc->graphName));
}
graphInfoDst->inputTensors = nullptr;
graphInfoDst->numInputTensors = 0;
if (graphInfoSrc->graphInputs) {
if (!copyTensorsInfo(
graphInfoSrc->graphInputs, graphInfoDst->inputTensors, graphInfoSrc->numGraphInputs)) {
return false;
}
graphInfoDst->numInputTensors = graphInfoSrc->numGraphInputs;
}
graphInfoDst->outputTensors = nullptr;
graphInfoDst->numOutputTensors = 0;
if (graphInfoSrc->graphOutputs) {
if (!copyTensorsInfo(graphInfoSrc->graphOutputs,
graphInfoDst->outputTensors,
graphInfoSrc->numGraphOutputs)) {
return false;
}
graphInfoDst->numOutputTensors = graphInfoSrc->numGraphOutputs;
}
return true;
}

bool sample_app::copyGraphsInfoV1(const QnnSystemContext_GraphInfoV1_t *graphInfoSrc,
qnn_wrapper_api::GraphInfo_t *graphInfoDst) {
graphInfoDst->graphName = nullptr;
Expand Down Expand Up @@ -301,6 +330,9 @@ bool sample_app::copyGraphsInfo(const QnnSystemContext_GraphInfo_t *graphsInput,
if (graphsInput[gIdx].version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_1) {
copyGraphsInfoV1(&graphsInput[gIdx].graphInfoV1, &graphInfoArr[gIdx]);
}
else if (graphsInput[gIdx].version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_3) {
copyGraphsInfoV3(&graphsInput[gIdx].graphInfoV3, &graphInfoArr[gIdx]);
}
graphsInfo[gIdx] = graphInfoArr + gIdx;
}
}
Expand Down Expand Up @@ -359,6 +391,18 @@ bool sample_app::copyMetadataToGraphsInfo(const QnnSystemContext_BinaryInfo_t *b
return true;
}
}
else if (binaryInfo->version == QNN_SYSTEM_CONTEXT_BINARY_INFO_VERSION_3) {
if (binaryInfo->contextBinaryInfoV3.graphs) {
if (!copyGraphsInfo(binaryInfo->contextBinaryInfoV3.graphs,
binaryInfo->contextBinaryInfoV3.numGraphs,
graphsInfo)) {
QNN_ERROR("Failed while copying graphs Info.");
return false;
}
graphsCount = binaryInfo->contextBinaryInfoV3.numGraphs;
return true;
}
}
QNN_ERROR("Unrecognized system context binary info version.");
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/QnnSampleAppUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ bool copyGraphsInfo(const QnnSystemContext_GraphInfo_t *graphsInput,
bool copyGraphsInfoV1(const QnnSystemContext_GraphInfoV1_t *graphInfoSrc,
qnn_wrapper_api::GraphInfo_t *graphInfoDst);

bool copyGraphsInfoV3(const QnnSystemContext_GraphInfoV3_t *graphInfoSrc,
qnn_wrapper_api::GraphInfo_t *graphInfoDst);

bool copyTensorsInfo(const Qnn_Tensor_t *tensorsInfoSrc,
Qnn_Tensor_t *&tensorWrappers,
uint32_t tensorsCount);
Expand Down

0 comments on commit 5328421

Please sign in to comment.