blob: 84d5e16f2f142b11054841927a3db340e6f784a6 [file] [log] [blame]
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +01001/*
Mikael Olsson68709512024-02-12 13:30:31 +01002 * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +01003 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the License); you may
6 * not use _this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20/*****************************************************************************
21 * Includes
22 *****************************************************************************/
23
24#include "message_handler.hpp"
25
26#include <inference_process.hpp>
27
28/*****************************************************************************
Mikael Olsson918cd902023-12-13 09:57:42 +010029 * JobContext
30 *****************************************************************************/
31
32struct JobContext;
33
34/*****************************************************************************
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +010035 * InferenceRunner
36 *****************************************************************************/
37
38class InferenceRunner {
39public:
40 InferenceRunner(uint8_t *tensorArena,
41 size_t arenaSize,
42 MessageHandler::InferenceQueue &inferenceQueue,
43 MessageHandler::ResponseQueue &responseQueue);
44 ~InferenceRunner();
45
46private:
47 static void inferenceTask(void *param);
48
Mikael Olsson68709512024-02-12 13:30:31 +010049 void
50 handleInferenceRequest(const uint32_t src, const uint64_t msgId, const EthosU::ethosu_rpmsg_inference_req &request);
51 InferenceProcess::InferenceJob makeInferenceJob(const EthosU::ethosu_rpmsg_inference_req &request,
Mikael Olsson918cd902023-12-13 09:57:42 +010052 JobContext &context);
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +010053
54 MessageHandler::InferenceQueue &inferenceQueue;
55 MessageHandler::ResponseQueue &responseQueue;
56 InferenceProcess::InferenceProcess inference;
57
58 // FreeRTOS
59 TaskHandle_t taskHandle;
60};