6dec9ea8f3e2cc2dce22570d3f695dce88b6fa44
[platform/core/ml/nnfw.git] / runtime / onert / core / src / ir / pass / PermutationOperationPass.h
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
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
17 #ifndef __ONERT_GRAPH_PASS_PERMUTATION_OPERATION_PASS_H__
18 #define __ONERT_GRAPH_PASS_PERMUTATION_OPERATION_PASS_H__
19
20 #include "ir/OperationVisitor.h"
21 #include "LoweredOperationPass.h"
22
23 namespace onert
24 {
25 namespace ir
26 {
27 namespace pass
28 {
29
30 class PermutationOperationPass : public LoweredOperationPass, public OperationVisitor
31 {
32 public:
33   using LoweredOperationPass::LoweredOperationPass;
34
35 public:
36   std::string id() final { return "PermutationOperationPass"; }
37
38 public:
39   void callback(const OperationIndex &i, Operation &n) final;
40
41 public:
42   void visit(const operation::Add &) final;
43   void visit(const operation::Comparison &) final;
44   void visit(const operation::Concat &) final;
45   void visit(const operation::Div &) final;
46   void visit(const operation::LogicalAnd &) final;
47   void visit(const operation::LogicalNot &) final;
48   void visit(const operation::LogicalOr &) final;
49   void visit(const operation::Max &) final;
50   void visit(const operation::Min &) final;
51   void visit(const operation::Mul &) final;
52   void visit(const operation::Pack &) final;
53   void visit(const operation::PReLU &) final;
54   void visit(const operation::SquaredDifference &) final;
55   void visit(const operation::Sub &) final;
56   void visit(const operation::Unpack &) final;
57   void visit(const operation::FullyConnected &) final;
58   void visit(const operation::Gather &) final;
59   void visit(const operation::Reshape &) final;
60
61 private:
62   void applyExpandRanks(const Operation &);
63   void changeToKeepLayout(const Operation &);
64 };
65
66 } // namespace pass
67 } // namespace ir
68 } // namespace onert
69
70 #endif // __ONERT_GRAPH_PASS_PERMUTATION_OPERATION_PASS_H__