alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | /* |
| 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. */ |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 21 | #include "log_macros.h" |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 22 | |
| 23 | enum opcodes |
| 24 | { |
| 25 | MENU_OPT_RUN_INF_NEXT = 1, /* Run on next vector. */ |
| 26 | MENU_OPT_SHOW_MODEL_INFO, /* Show model info. */ |
| 27 | }; |
| 28 | |
Kshitij Sisodia | 4cc4021 | 2022-04-08 09:54:53 +0100 | [diff] [blame^] | 29 | void main_loop() |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 30 | { |
| 31 | arm::app::TestModel model; /* Model wrapper object. */ |
| 32 | |
| 33 | /* Load the model. */ |
| 34 | if (!model.Init()) { |
| 35 | printf_err("Failed to initialise model\n"); |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | /* Instantiate application context. */ |
| 40 | arm::app::ApplicationContext caseContext; |
| 41 | |
Kshitij Sisodia | 4cc4021 | 2022-04-08 09:54:53 +0100 | [diff] [blame^] | 42 | arm::app::Profiler profiler{"inference_runner"}; |
Isabella Gottardi | 8df12f3 | 2021-04-07 17:15:31 +0100 | [diff] [blame] | 43 | caseContext.Set<arm::app::Profiler&>("profiler", profiler); |
alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 44 | caseContext.Set<arm::app::Model&>("model", model); |
| 45 | caseContext.Set<uint32_t>("imgIndex", 0); |
| 46 | |
| 47 | /* Loop. */ |
| 48 | if (RunInferenceHandler(caseContext)) { |
| 49 | info("Inference completed.\n"); |
| 50 | } else { |
| 51 | printf_err("Inference failed.\n"); |
| 52 | } |
| 53 | } |