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_IR_OPERATION_VALIDATOR_H__
18 #define __ONERT_IR_OPERATION_VALIDATOR_H__
20 #include "ir/OperationVisitor.h"
36 class OperationValidator : public OperationVisitor
39 OperationValidator(void) = delete;
40 OperationValidator(const Graph &graph);
46 void visit(const operation::AddN &node) override;
47 void visit(const operation::BatchMatMul &node) override;
48 void visit(const operation::BatchToSpaceND &node) override;
49 void visit(const operation::BinaryArithmetic &node) override;
50 void visit(const operation::Comparison &node) override;
51 void visit(const operation::DepthToSpace &node) override;
52 void visit(const operation::DepthwiseConv2D &node) override;
53 void visit(const operation::ElementwiseActivation &node) override;
54 void visit(const operation::ElementwiseBinary &node) override;
55 void visit(const operation::ElementwiseUnary &node) override;
56 void visit(const operation::EmbeddingLookup &node) override;
57 void visit(const operation::ExpandDims &node) override;
58 void visit(const operation::HashtableLookup &node) override;
59 void visit(const operation::Pack &node) override;
60 void visit(const operation::Pad &node) override;
61 void visit(const operation::Rank &node) override;
62 void visit(const operation::ResizeBilinear &node) override;
63 void visit(const operation::Reverse &node) override;
64 void visit(const operation::Select &node) override;
65 void visit(const operation::Shape &node) override;
66 void visit(const operation::SpaceToBatchND &node) override;
67 void visit(const operation::SpaceToDepth &node) override;
68 void visit(const operation::Split &node) override;
69 void visit(const operation::SquaredDifference &node) override;
70 void visit(const operation::StridedSlice &node) override;
71 void visit(const operation::TransposeConv &node) override;
72 void visit(const operation::Unpack &node) override;
73 void visit(const operation::While &node) override;
76 DataType operandType(const OperandIndex &idx);
77 bool isConstant(const OperandIndex &idx);
78 bool isSameType(const OperandIndex &idx1, const OperandIndex &idx2);
79 bool isValidType(const OperandIndex &idx, const DataType &type);
80 bool isValidType(const OperandIndex &idx, std::initializer_list<DataType> valid_types);
83 const Operations &_operations;
84 const Operands &_operands;
90 #endif // __ONERT_IR_OPERATION_VALIDATOR_H__