blob: 7a91bfe4b992c0cac4b7576e6e8adfabcfcec8e6 [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#ifndef MODEL_RUNNER_IMPL_H_
17#define MODEL_RUNNER_IMPL_H_
18
19#include "model_runner.h"
20#include "graph_status.h"
21#include "version.h"
22
23#include "ops/op_factory.h"
24#include "subgraph_traverser.h"
25#include "tosa_serialization_handler.h"
26
27namespace TosaReference
28{
29
30/*
31 * This is a private implementation of the IModelRunner class.
32 * See documented IModelRunner for usage.
33 */
34class ModelRunnerImpl
35{
36public:
37 ModelRunnerImpl();
38 ModelRunnerImpl(const func_config_t& func_config, const func_debug_t& func_debug);
39
40 ~ModelRunnerImpl();
41
42 void setFuncConfig(func_config_t& func_config);
43 void setFuncDebug(func_debug_t& func_debug);
44
45 GraphStatus initialize(TosaSerializationHandler& serialization_handler);
46 GraphStatus run();
47
48 template <typename T>
49 int setInput(std::string input_name, std::vector<T> vals);
50
51 template <typename T>
52 std::vector<T> getOutput(std::string output_name);
53
54private:
55 SubgraphTraverser* _main_gt = nullptr;
56
57 // Used to determine if all input tensors have been set correctly.
58 uint32_t n_input_tensors = 0;
59
60 void validateTosaVersion(TosaSerializationHandler& serialization_handler);
61 void checkGraphStatus(SubgraphTraverser& main_gt);
62};
63
64}; // namespace TosaReference
65
66#endif