1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
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.
15 //*****************************************************************************
16 #include "ngraph/op/util/op_types.hpp"
17 #include "ngraph/op/add.hpp"
18 #include "ngraph/op/and.hpp"
19 #include "ngraph/op/constant.hpp"
20 #include "ngraph/op/equal.hpp"
21 #include "ngraph/op/maximum.hpp"
22 #include "ngraph/op/minimum.hpp"
23 #include "ngraph/op/multiply.hpp"
24 #include "ngraph/op/not_equal.hpp"
25 #include "ngraph/op/op.hpp"
26 #include "ngraph/op/or.hpp"
27 #include "ngraph/op/parameter.hpp"
28 #include "ngraph/op/result.hpp"
29 #include "ngraph/op/select.hpp"
30 #include "ngraph/op/util/binary_elementwise_arithmetic.hpp"
31 #include "ngraph/op/util/binary_elementwise_comparison.hpp"
32 #include "ngraph/op/util/binary_elementwise_logical.hpp"
33 #include "ngraph/op/util/fused_op.hpp"
34 #include "ngraph/op/util/unary_elementwise_arithmetic.hpp"
35 #include "ngraph/op/xor.hpp"
36 #include "ngraph/type.hpp"
38 NGRAPH_SUPPRESS_DEPRECATED_START
40 bool ngraph::op::is_unary_elementwise_arithmetic(const ngraph::Node* node)
42 return dynamic_cast<const ngraph::op::util::UnaryElementwiseArithmetic*>(node) != nullptr;
45 bool ngraph::op::is_binary_elementwise_arithmetic(const ngraph::Node* node)
47 return dynamic_cast<const ngraph::op::util::BinaryElementwiseArithmetic*>(node) != nullptr;
50 bool ngraph::op::is_binary_elementwise_comparison(const ngraph::Node* node)
52 return dynamic_cast<const ngraph::op::util::BinaryElementwiseComparison*>(node) != nullptr;
55 bool ngraph::op::is_binary_elementwise_logical(const ngraph::Node* node)
57 return dynamic_cast<const ngraph::op::util::BinaryElementwiseLogical*>(node) != nullptr;
60 bool ngraph::op::supports_auto_broadcast(const ngraph::Node* node)
62 return dynamic_cast<const ngraph::op::v1::Select*>(node) != nullptr ||
63 dynamic_cast<const ngraph::op::util::BinaryElementwiseComparison*>(node) != nullptr ||
64 dynamic_cast<const ngraph::op::util::BinaryElementwiseLogical*>(node) != nullptr ||
65 dynamic_cast<const ngraph::op::util::BinaryElementwiseArithmetic*>(node) != nullptr;
68 bool ngraph::op::supports_decompose(const ngraph::Node* node)
70 NGRAPH_SUPPRESS_DEPRECATED_START
71 return dynamic_cast<const ngraph::op::util::FusedOp*>(node) != nullptr;
72 NGRAPH_SUPPRESS_DEPRECATED_END
75 bool ngraph::op::is_op(const ngraph::Node* node)
77 return dynamic_cast<const ngraph::op::Op*>(node) != nullptr;
80 bool ngraph::op::is_parameter(const ngraph::Node* node)
82 return dynamic_cast<const ngraph::op::Parameter*>(node) != nullptr;
85 bool ngraph::op::is_output(const ngraph::Node* node)
87 return dynamic_cast<const ngraph::op::Result*>(node) != nullptr;
90 bool ngraph::op::is_constant(const ngraph::Node* node)
92 return dynamic_cast<const ngraph::op::Constant*>(node) != nullptr;
95 bool ngraph::op::is_commutative(const ngraph::Node* node)
97 return dynamic_cast<const ngraph::op::v0::Add*>(node) != nullptr ||
98 dynamic_cast<const ngraph::op::v1::Add*>(node) != nullptr ||
99 dynamic_cast<const ngraph::op::v0::Maximum*>(node) != nullptr ||
100 dynamic_cast<const ngraph::op::v1::Maximum*>(node) != nullptr ||
101 dynamic_cast<const ngraph::op::v0::Equal*>(node) != nullptr ||
102 dynamic_cast<const ngraph::op::v1::Equal*>(node) != nullptr ||
103 dynamic_cast<const ngraph::op::v0::NotEqual*>(node) != nullptr ||
104 dynamic_cast<const ngraph::op::v1::NotEqual*>(node) != nullptr ||
105 dynamic_cast<const ngraph::op::v1::LogicalAnd*>(node) != nullptr ||
106 dynamic_cast<const ngraph::op::v0::Xor*>(node) != nullptr ||
107 dynamic_cast<const ngraph::op::v1::LogicalXor*>(node) != nullptr ||
108 dynamic_cast<const ngraph::op::v0::Minimum*>(node) != nullptr ||
109 dynamic_cast<const ngraph::op::v1::Minimum*>(node) != nullptr ||
110 dynamic_cast<const ngraph::op::v0::Multiply*>(node) != nullptr ||
111 dynamic_cast<const ngraph::op::v1::Multiply*>(node) != nullptr ||
112 dynamic_cast<const ngraph::op::v0::Or*>(node) != nullptr ||
113 dynamic_cast<const ngraph::op::v1::LogicalOr*>(node) != nullptr;
116 bool ngraph::op::is_unary_elementwise_arithmetic(const std::shared_ptr<ngraph::Node>& node)
118 return is_unary_elementwise_arithmetic(node.get());
120 bool ngraph::op::is_binary_elementwise_arithmetic(const std::shared_ptr<ngraph::Node>& node)
122 return is_binary_elementwise_arithmetic(node.get());
124 bool ngraph::op::is_binary_elementwise_comparison(const std::shared_ptr<ngraph::Node>& node)
126 return is_binary_elementwise_comparison(node.get());
128 bool ngraph::op::is_binary_elementwise_logical(const std::shared_ptr<ngraph::Node>& node)
130 return is_binary_elementwise_logical(node.get());
133 bool ngraph::op::supports_auto_broadcast(const std::shared_ptr<ngraph::Node>& node)
135 return supports_auto_broadcast(node.get());
138 bool ngraph::op::supports_decompose(const std::shared_ptr<ngraph::Node>& node)
140 return supports_decompose(node.get());
143 bool ngraph::op::is_op(const std::shared_ptr<ngraph::Node>& node)
145 return is_op(node.get());
147 bool ngraph::op::is_parameter(const std::shared_ptr<ngraph::Node>& node)
149 return is_parameter(node.get());
151 bool ngraph::op::is_output(const std::shared_ptr<ngraph::Node>& node)
153 return is_output(node.get());
155 bool ngraph::op::is_constant(const std::shared_ptr<ngraph::Node>& node)
157 return is_constant(node.get());
159 bool ngraph::op::is_commutative(const std::shared_ptr<ngraph::Node>& node)
161 return is_commutative(node.get());