2 * Copyright (c) 2019 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_IR_OP_SEQUENCES_H__
18 #define __ONERT_IR_OP_SEQUENCES_H__
21 #include "ir/OpSequence.h"
22 #include "util/ObjectManager.h"
30 * @brief Class that manages OpSequence objects
32 class OpSequences : public util::ObjectManager<OpSequenceIndex, OpSequence>
36 * @brief Create an instance of OpSequence with given op and push it to objects
38 * @param[in] op_idx Operation index that is emplaced
39 * @param[in] layout OpSequence's layout
40 * @return OpSequenceIndex
42 OpSequenceIndex emplace(const OperationIndex &op_index, Layout layout);
45 * @brief Push an instance of OpSequence to objects
47 * @param[in] op_seq An instance of OpSequence
48 * @return OpSequenceIndex
50 OpSequenceIndex emplace(std::unique_ptr<OpSequence> &&op_seq);
52 * @brief Check if an operation does exist in any OpSequences
54 * @param operation_index Operation index to find
55 * @return true If such operation exists in any OpSequences otherwise false
57 bool containsOperation(const OperationIndex &operation_index) const;
59 * @brief Find an operation from all OpSequences
61 * @param operation_index Operation index to find
62 * @return OpSequenceIndex Index of OpSequence that contains given operation index
64 OpSequenceIndex getOperation(const OperationIndex &operation_index) const;
66 * @brief Remove an operation from OpSequence
68 * @param operation_index Operation index to be removed
70 void removeFromOpSequence(const OperationIndex &operation_index);
73 void cacheSequenceIndex(const OpSequenceIndex &seq_index, const OperationIndex &op_index) const;
74 OpSequenceIndex *findSequenceIndex(const OperationIndex &operation_index) const;
76 OpSequenceIndex findOperation(const OperationIndex &operation_index) const;
77 mutable std::unordered_map<OperationIndex, OpSequenceIndex> _seq_indexes;
81 * @brief Dump OpSequences
83 * @param op_seqs Operation Sequences
84 * @param operations Operation context
86 void dumpOpSequences(const OpSequences &op_seqs, const Operations &operations);
91 #endif // __ONERT_IR_OP_SEQUENCES_H__