Matthew Sloyan | ba5fad3 | 2022-09-26 13:31:43 +0100 | [diff] [blame] | 1 | |
| 2 | // Copyright (c) 2022, ARM Limited. |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | #include "model_runner_impl.h" |
| 17 | |
| 18 | using namespace TosaReference; |
| 19 | |
| 20 | // Global instantiation of configuration and debug objects |
| 21 | func_config_t g_func_config; |
| 22 | func_debug_t g_func_debug; |
| 23 | |
| 24 | IModelRunner::IModelRunner() : model_runner_impl(new ModelRunnerImpl()) |
| 25 | {} |
| 26 | |
| 27 | IModelRunner::IModelRunner(const func_config_t& func_config, |
| 28 | const func_debug_t& func_debug) |
| 29 | : model_runner_impl(new ModelRunnerImpl(func_config, func_debug)) |
| 30 | {} |
| 31 | |
| 32 | IModelRunner::~IModelRunner() |
| 33 | {} |
| 34 | |
| 35 | void IModelRunner::setFuncConfig(func_config_t& func_config) |
| 36 | { |
| 37 | model_runner_impl->setFuncConfig(func_config); |
| 38 | } |
| 39 | |
| 40 | void IModelRunner::setFuncDebug(func_debug_t& func_debug) |
| 41 | { |
| 42 | model_runner_impl->setFuncDebug(func_debug); |
| 43 | } |
| 44 | |
| 45 | GraphStatus IModelRunner::initialize(tosa::TosaSerializationHandler& serialization_handler) |
| 46 | { |
| 47 | return model_runner_impl->initialize(serialization_handler); |
| 48 | } |
| 49 | |
| 50 | GraphStatus IModelRunner::run() |
| 51 | { |
| 52 | return model_runner_impl->run(); |
| 53 | } |
| 54 | |
| 55 | template <typename T> |
| 56 | int IModelRunner::setInput(std::string input_name, std::vector<T> vals) |
| 57 | { |
| 58 | return model_runner_impl->setInput<T>(input_name, vals); |
| 59 | } |
| 60 | |
| 61 | template <typename T> |
| 62 | std::vector<T> IModelRunner::getOutput(std::string output_name) |
| 63 | { |
| 64 | return model_runner_impl->getOutput<T>(output_name); |
| 65 | } |
| 66 | |
| 67 | // Template explicit specialization |
| 68 | template int IModelRunner::setInput<float>(std::string input_name, std::vector<float> vals); |
| 69 | template int IModelRunner::setInput<int32_t>(std::string input_name, std::vector<int32_t> vals); |
| 70 | template int IModelRunner::setInput<int64_t>(std::string input_name, std::vector<int64_t> vals); |
| 71 | template int IModelRunner::setInput<unsigned char>(std::string input_name, std::vector<unsigned char> vals); |
| 72 | |
| 73 | template std::vector<float> IModelRunner::getOutput<float>(std::string output_name); |
| 74 | template std::vector<int32_t> IModelRunner::getOutput<int32_t>(std::string output_name); |
| 75 | template std::vector<int64_t> IModelRunner::getOutput<int64_t>(std::string output_name); |
| 76 | template std::vector<unsigned char> IModelRunner::getOutput<unsigned char>(std::string output_name); |