aboutsummaryrefslogtreecommitdiff
path: root/applications/message_handler/message_handler.cpp
diff options
context:
space:
mode:
authorDavide Grohmann <davide.grohmann@arm.com>2022-03-23 14:59:56 +0100
committerDavide Grohmann <davide.grohmann@arm.com>2022-05-05 11:11:25 +0200
commit00de9ee6aaa6328980a6d1c6b04fa75741194de3 (patch)
treedfdac207b49be1ea66fb2ec77bf553ab811824fa /applications/message_handler/message_handler.cpp
parent60c5737c37471b4e34f1ffc085e8b12e2a7c6866 (diff)
downloadethos-u-core-platform-00de9ee6aaa6328980a6d1c6b04fa75741194de3.tar.gz
Initial support for inference cancellation
Infransctrure work to being able to send back and forth requests and responses for inference cancellations. The implementation is stubbed to always fail in this commit. Change-Id: Id7848930b81a3f38fe6c05323ccca2edd6b5b5bf
Diffstat (limited to 'applications/message_handler/message_handler.cpp')
-rw-r--r--applications/message_handler/message_handler.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/applications/message_handler/message_handler.cpp b/applications/message_handler/message_handler.cpp
index a634c16..f06d056 100644
--- a/applications/message_handler/message_handler.cpp
+++ b/applications/message_handler/message_handler.cpp
@@ -117,7 +117,7 @@ bool getNetwork(const uint32_t index, void *&data, size_t &size) {
#endif
default:
- printf("Error: Network model index out of range. index=%u\n", index);
+ printf("Error: Network model index out of range. index=%" PRIu32 "\n", index);
return true;
}
@@ -131,7 +131,7 @@ bool getNetwork(const ethosu_core_network_buffer &buffer, void *&data, size_t &s
case ETHOSU_CORE_NETWORK_INDEX:
return getNetwork(buffer.index, data, size);
default:
- printf("Error: Unsupported network model type. type=%u\n", buffer.type);
+ printf("Error: Unsupported network model type. type=%" PRIu32 "\n", buffer.type);
return true;
}
}
@@ -293,6 +293,19 @@ bool IncomingMessageHandler::handleMessage() {
}
break;
}
+ case ETHOSU_CORE_MSG_CANCEL_INFERENCE_REQ: {
+ ethosu_core_cancel_inference_req req;
+ if (!inputMessageQueue.read(req)) {
+ sendErrorAndResetQueue(ETHOSU_CORE_MSG_ERR_INVALID_PAYLOAD, "CancelInferenceReq. Failed to read payload");
+ break;
+ }
+ printf("Msg: CancelInferenceReq. user_arg=0x%" PRIx64 ", inference_handle=0x%" PRIx64 "\n",
+ req.user_arg,
+ req.inference_handle);
+
+ sendCancelInferenceRsp(req.user_arg, ETHOSU_CORE_STATUS_ERROR);
+ break;
+ }
case ETHOSU_CORE_MSG_NETWORK_INFO_REQ: {
ethosu_core_network_info_req req;
if (!inputMessageQueue.read(req)) {
@@ -393,6 +406,16 @@ void IncomingMessageHandler::sendFailedInferenceRsp(uint64_t userArg, uint32_t s
mailbox.sendMessage();
}
}
+void IncomingMessageHandler::sendCancelInferenceRsp(uint64_t userArg, uint32_t status) {
+ ethosu_core_cancel_inference_rsp cancellation;
+ cancellation.user_arg = userArg;
+ cancellation.status = status;
+ if (!outputMessageQueue.write(ETHOSU_CORE_MSG_CANCEL_INFERENCE_RSP, cancellation)) {
+ printf("ERROR: Msg: Failed to write cancel inference response. No mailbox message sent\n");
+ } else {
+ mailbox.sendMessage();
+ }
+}
void IncomingMessageHandler::readCapabilties(ethosu_core_msg_capabilities_rsp &rsp) {
rsp = {};