blob: b43370c49d5b8c22e091e070b616b6874ae48788 [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
Grant Watson64285a12022-11-16 15:32:39 +000023#include "array_proxy.h"
Matthew Sloyanba5fad32022-09-26 13:31:43 +010024#include "ops/op_factory.h"
25#include "subgraph_traverser.h"
26#include "tosa_serialization_handler.h"
27
28namespace TosaReference
29{
30
31/*
32 * This is a private implementation of the IModelRunner class.
33 * See documented IModelRunner for usage.
34 */
35class ModelRunnerImpl
36{
37public:
38 ModelRunnerImpl();
39 ModelRunnerImpl(const func_config_t& func_config, const func_debug_t& func_debug);
40
41 ~ModelRunnerImpl();
42
43 void setFuncConfig(func_config_t& func_config);
44 void setFuncDebug(func_debug_t& func_debug);
45
Grant Watson64285a12022-11-16 15:32:39 +000046 GraphStatus initialize(TosaSerializationBasicBlock& bb);
Matthew Sloyanba5fad32022-09-26 13:31:43 +010047 GraphStatus initialize(TosaSerializationHandler& serialization_handler);
48 GraphStatus run();
49
50 template <typename T>
Grant Watson64285a12022-11-16 15:32:39 +000051 int setInput(std::string input_name, ArrayProxy<T> vals);
52 int setInput(std::string input_name, uint8_t* raw_ptr, size_t size);
Matthew Sloyanba5fad32022-09-26 13:31:43 +010053
54 template <typename T>
55 std::vector<T> getOutput(std::string output_name);
Grant Watson64285a12022-11-16 15:32:39 +000056 int getOutput(std::string output_name, uint8_t* ptr, size_t size);
Matthew Sloyanba5fad32022-09-26 13:31:43 +010057
58private:
59 SubgraphTraverser* _main_gt = nullptr;
60
61 // Used to determine if all input tensors have been set correctly.
62 uint32_t n_input_tensors = 0;
63
Grant Watson64285a12022-11-16 15:32:39 +000064 GraphStatus initialize(TosaSerializationBasicBlock* bb, TosaSerializationHandler* serialization_handler);
Matthew Sloyanba5fad32022-09-26 13:31:43 +010065 void validateTosaVersion(TosaSerializationHandler& serialization_handler);
66 void checkGraphStatus(SubgraphTraverser& main_gt);
67};
68
69}; // namespace TosaReference
70
71#endif