blob: 797fc77ad37f2080bfc60f8b1cc49ce06f970ab0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file Compiler.h
* @brief This file contains Compiler class to define and run compilation phase
*/
#ifndef __NEURUN_COMPILER_COMPILE_H_
#define __NEURUN_COMPILER_COMPILE_H_
#include "ir/Graph.h"
#include "exec/IExecutor.h"
namespace neurun
{
namespace compiler
{
enum class State
{
CREATED, // Before compilation
STARTED, // Compile is started
LOWERED, // Backend is decided
COMPILED // Success compilation
};
/**
* @brief Class to compile graph model
*/
class Compiler
{
public:
/**
* @brief Construct a new Compiler object
* @param[in] model Graph model
*/
Compiler(const std::shared_ptr<ir::Graph> &graph)
: _graph{graph}, _executor{nullptr}, _state{State::CREATED}
{
// DO NOTHING
}
public:
/**
* @brief Run compilation. Compilation result will be saved in _plan
*/
void compile(void);
/**
* @brief Pass plan reference
* @param[out] plan Plan reference to return\n
* Set nullptr if compile is not run yet
*/
void release(std::shared_ptr<exec::IExecutor> &executor) { executor = _executor; }
void state(State state) { _state = state; }
State state(void) const { return _state; }
/**
* @brief Check if model can compile
* @return @c true if model can compile, otherwise @c false
* @note This method don't check model correctness,\n
* so model verification should be done before calling this method
*/
bool checkCompilable();
private:
std::shared_ptr<ir::Graph> _graph;
std::shared_ptr<exec::IExecutor> _executor;
State _state;
};
} // namespace compiler
} // namespace neurun
#endif // __NEURUN_COMPILER_COMPILE_H_
|