Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / runtime / onert / core / src / compiler / 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_COMPILER_PASS_PERMUTATION_OPERATION_PASS_H__
18 #define __ONERT_COMPILER_PASS_PERMUTATION_OPERATION_PASS_H__
19
20 #include "ir/OperationVisitor.h"
21 #include "LoweredOperationPass.h"
22
23 namespace onert
24 {
25 namespace compiler
26 {
27 namespace pass
28 {
29
30 class PermutationOperationPass : public LoweredOperationPass, public ir::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 ir::OperationIndex &i, ir::IOperation &n) final;
40
41 public:
42   void visit(const ir::operation::BinaryArithmetic &) final;
43   void visit(const ir::operation::Comparison &) final;
44   void visit(const ir::operation::Concat &) final;
45   void visit(const ir::operation::ElementwiseBinary &) final;
46   void visit(const ir::operation::ElementwiseUnary &) final;
47   void visit(const ir::operation::OneHot &) final;
48   void visit(const ir::operation::Pack &) final;
49   void visit(const ir::operation::PReLU &) final;
50   void visit(const ir::operation::SquaredDifference &) final;
51   void visit(const ir::operation::Unpack &) final;
52   void visit(const ir::operation::FullyConnected &) final;
53   void visit(const ir::operation::Gather &) final;
54   void visit(const ir::operation::Reshape &) final;
55
56 private:
57   void applyExpandRanks(const ir::Operation &);
58   void changeToKeepLayout(const ir::Operation &);
59 };
60
61 } // namespace pass
62 } // namespace compiler
63 } // namespace onert
64
65 #endif // __ONERT_COMPILER_PASS_PERMUTATION_OPERATION_PASS_H__