skip.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 Intel Corporation
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 #pragma once
18 
19 #include "ngraph/node.hpp"
20 #include "ngraph/pattern/op/pattern.hpp"
21 
22 namespace ngraph
23 {
24  namespace pattern
25  {
26  namespace op
27  {
28  /// The graph value is added to the matched value list. If the predicate is true, the
29  /// match succeeds if the arguments match; if the predicate is false, the match succeeds
30  /// if the pattern input matches the graph value.
31  class NGRAPH_API Skip : public Pattern
32  {
33  public:
34  static constexpr NodeTypeInfo type_info{"patternSkip", 0};
35  const NodeTypeInfo& get_type_info() const override;
36  Skip(const Output<Node>& arg, ValuePredicate pred)
37  : Pattern({arg}, pred)
38  {
39  set_output_type(0, arg.get_element_type(), arg.get_partial_shape());
40  }
41 
42  Skip(const Output<Node>& arg, NodePredicate pred = nullptr)
43  : Pattern({arg}, as_value_predicate(pred))
44  {
45  set_output_type(0, arg.get_element_type(), arg.get_partial_shape());
46  }
47 
48  Skip(const OutputVector& args, ValuePredicate pred)
49  : Pattern(args, pred)
50  {
51  set_output_type(
52  0, args.at(0).get_element_type(), args.at(0).get_partial_shape());
53  }
54 
55  Skip(const OutputVector& args, NodePredicate pred = nullptr)
56  : Pattern(args, as_value_predicate(pred))
57  {
58  set_output_type(
59  0, args.at(0).get_element_type(), args.at(0).get_partial_shape());
60  }
61 
62  virtual bool match_value(pattern::Matcher* matcher,
63  const Output<Node>& pattern_value,
64  const Output<Node>& graph_value) override;
65  };
66  }
67  }
68 }
A handle for one of a node's outputs.
Definition: node_output.hpp:42
Definition: pattern.hpp:82
Definition: skip.hpp:32
const NodeTypeInfo & get_type_info() const override
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: type.hpp:39