blob: 26a20de9960412e2469c04b6e6d39cae6d6dc878 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
2 * Copyright (c) 2021 Arm Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://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,
13 * WITHOUT 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#include "hal.h" /* Brings in platform definitions. */
18#include "TestModel.hpp" /* Model class for running inference. */
19#include "UseCaseHandler.hpp" /* Handlers for different user options. */
20#include "UseCaseCommonUtils.hpp" /* Utils functions. */
21
22enum opcodes
23{
24 MENU_OPT_RUN_INF_NEXT = 1, /* Run on next vector. */
25 MENU_OPT_SHOW_MODEL_INFO, /* Show model info. */
26};
27
28void main_loop(hal_platform& platform)
29{
30 arm::app::TestModel model; /* Model wrapper object. */
31
32 /* Load the model. */
33 if (!model.Init()) {
34 printf_err("Failed to initialise model\n");
35 return;
36 }
37
38 /* Instantiate application context. */
39 arm::app::ApplicationContext caseContext;
40
Isabella Gottardi8df12f32021-04-07 17:15:31 +010041 arm::app::Profiler profiler{&platform, "inference_runner"};
42 caseContext.Set<arm::app::Profiler&>("profiler", profiler);
43
alexander3c798932021-03-26 21:42:19 +000044 caseContext.Set<hal_platform&>("platform", platform);
45 caseContext.Set<arm::app::Model&>("model", model);
46 caseContext.Set<uint32_t>("imgIndex", 0);
47
48 /* Loop. */
49 if (RunInferenceHandler(caseContext)) {
50 info("Inference completed.\n");
51 } else {
52 printf_err("Inference failed.\n");
53 }
54}