blob: 2395a8501401a0d215c12d65f71984660ab6c251 [file] [log] [blame]
Matthew Sloyanba5fad32022-09-26 13:31:43 +01001
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
18using namespace TosaReference;
19
20// Global instantiation of configuration and debug objects
21func_config_t g_func_config;
22func_debug_t g_func_debug;
23
24IModelRunner::IModelRunner() : model_runner_impl(new ModelRunnerImpl())
25{}
26
27IModelRunner::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
32IModelRunner::~IModelRunner()
33{}
34
35void IModelRunner::setFuncConfig(func_config_t& func_config)
36{
37 model_runner_impl->setFuncConfig(func_config);
38}
39
40void IModelRunner::setFuncDebug(func_debug_t& func_debug)
41{
42 model_runner_impl->setFuncDebug(func_debug);
43}
44
45GraphStatus IModelRunner::initialize(tosa::TosaSerializationHandler& serialization_handler)
46{
47 return model_runner_impl->initialize(serialization_handler);
48}
49
50GraphStatus IModelRunner::run()
51{
52 return model_runner_impl->run();
53}
54
55template <typename T>
56int IModelRunner::setInput(std::string input_name, std::vector<T> vals)
57{
58 return model_runner_impl->setInput<T>(input_name, vals);
59}
60
61template <typename T>
62std::vector<T> IModelRunner::getOutput(std::string output_name)
63{
64 return model_runner_impl->getOutput<T>(output_name);
65}
66
67// Template explicit specialization
68template int IModelRunner::setInput<float>(std::string input_name, std::vector<float> vals);
69template int IModelRunner::setInput<int32_t>(std::string input_name, std::vector<int32_t> vals);
70template int IModelRunner::setInput<int64_t>(std::string input_name, std::vector<int64_t> vals);
71template int IModelRunner::setInput<unsigned char>(std::string input_name, std::vector<unsigned char> vals);
72
73template std::vector<float> IModelRunner::getOutput<float>(std::string output_name);
74template std::vector<int32_t> IModelRunner::getOutput<int32_t>(std::string output_name);
75template std::vector<int64_t> IModelRunner::getOutput<int64_t>(std::string output_name);
76template std::vector<unsigned char> IModelRunner::getOutput<unsigned char>(std::string output_name);