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_SEQUENCE_H__
18 #define __ONERT_IR_OP_SEQUENCE_H__
24 #include "ir/Layout.h"
26 #include "ir/Operation.h"
38 explicit OpSequence(Layout layout);
39 OpSequence(const OpSequence &) = delete;
42 void accept(OperationVisitor &v) const;
45 const OperandIndexSequence &getInputs() const { return _inputs; }
46 const OperandIndexSequence &getOutputs() const { return _outputs; }
47 void setInputs(const OperandIndexSequence &indexes) { _inputs = indexes; }
48 void setOutputs(const OperandIndexSequence &indexes) { _outputs = indexes; }
49 void replaceInputs(const OperandIndex &from, const OperandIndex &to)
51 _inputs.replace(from, to);
53 void replaceOutputs(const OperandIndex &from, const OperandIndex &to)
55 _outputs.replace(from, to);
58 void appendOperation(const OperationIndex &index) { _operations.emplace_back(index); }
60 std::vector<OperationIndex> &operations(void) { return _operations; }
62 const std::vector<OperationIndex> &operations(void) const { return _operations; }
64 uint32_t size(void) const { return _operations.size(); }
67 void remove(const OperationIndex &index);
69 bool exist(const OperationIndex &index) const;
72 Layout getLayout() const { return _layout; }
75 std::vector<OperationIndex>::const_iterator begin() const { return _operations.begin(); }
76 std::vector<OperationIndex>::const_iterator end() const { return _operations.end(); }
80 * @brief Set @c true if any operation in this opSequence has dynamic input
82 * @c false if all operations' inputs and outputs are static tensors
84 void has_dynamic_tensor(bool has_dynamic_tensor) { _has_dynamic_tensor = has_dynamic_tensor; }
85 bool has_dynamic_tensor() const { return _has_dynamic_tensor; }
88 OperandIndexSequence _inputs;
89 OperandIndexSequence _outputs;
90 std::vector<OperationIndex> _operations;
94 bool _has_dynamic_tensor;
97 std::string getStrFromOpSeq(const OpSequence &op_seq, const Operations &operations);
102 #endif // __ONERT_IR_OP_SEQUENCE_H__