2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __ONERT_COMPILER_LOWERED_GRAPH_H__
18 #define __ONERT_COMPILER_LOWERED_GRAPH_H__
21 #include "compiler/GraphLowerInfo.h"
22 #include "compiler/BackendResolver.h"
23 #include "compiler/Compiler.h"
31 * @brief Class that contains lowering information on graph.
32 * In addition, after lowering, operands in graph will be set to "dynamic"
33 * if the shape of output of an operation cannot be decided at compilation time.
38 LoweredGraph(const ir::Graph &graph, const compiler::CompilerOptions &options);
40 ir::Graph &graph() { return _graph; }
41 const ir::Graph &graph() const { return _graph; }
42 const compiler::GraphLowerInfo &lower_info() const { return _lower_info_map; }
43 compiler::GraphLowerInfo &lower_info() { return _lower_info_map; }
44 std::shared_ptr<ir::OperationIndexMap<int64_t>> indexed_ranks() { return _indexed_ranks; }
46 void setHasDynamicTensor(ir::OperationIndex ind, bool val)
48 _has_dynamic_tensor_map.emplace(ind, val);
50 bool getHasDynamicTensor(ir::OperationIndex ind) const
52 auto itr = _has_dynamic_tensor_map.find(ind);
53 return (itr == _has_dynamic_tensor_map.end()) ? false : itr->second;
57 void makeLowerInfo(const compiler::BackendResolver &backend_resolver);
59 void lowerGraph(const compiler::CompilerOptions &options);
63 * @brief Copy of target graph for lowering
64 * @note It uses copy of graph, not reference.
65 * It allows the original graph can be compiled multiple times.
68 std::shared_ptr<ir::OperationIndexMap<int64_t>> _indexed_ranks;
69 compiler::GraphLowerInfo _lower_info_map;
70 ir::OperationIndexMap<bool> _has_dynamic_tensor_map;
73 } // namespace compiler
76 #endif // __ONERT_COMPILER_LOWERED_GRAPH_H__