skip.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/node.hpp"
8 #include "ngraph/pattern/op/pattern.hpp"
9 
10 namespace ngraph
11 {
12  namespace pattern
13  {
14  namespace op
15  {
16  /// The graph value is added to the matched value list. If the predicate is true, the
17  /// match succeeds if the arguments match; if the predicate is false, the match succeeds
18  /// if the pattern input matches the graph value.
19  class NGRAPH_API Skip : public Pattern
20  {
21  public:
22  static constexpr NodeTypeInfo type_info{"patternSkip", 0};
23  const NodeTypeInfo& get_type_info() const override;
24  Skip(const Output<Node>& arg, ValuePredicate pred)
25  : Pattern({arg}, pred)
26  {
27  set_output_type(0, arg.get_element_type(), arg.get_partial_shape());
28  }
29 
30  Skip(const Output<Node>& arg, NodePredicate pred = nullptr)
31  : Pattern({arg}, as_value_predicate(pred))
32  {
33  set_output_type(0, arg.get_element_type(), arg.get_partial_shape());
34  }
35 
36  Skip(const OutputVector& args, ValuePredicate pred)
37  : Pattern(args, pred)
38  {
39  set_output_type(
40  0, args.at(0).get_element_type(), args.at(0).get_partial_shape());
41  }
42 
43  Skip(const OutputVector& args, NodePredicate pred = nullptr)
44  : Pattern(args, as_value_predicate(pred))
45  {
46  set_output_type(
47  0, args.at(0).get_element_type(), args.at(0).get_partial_shape());
48  }
49 
50  virtual bool match_value(pattern::Matcher* matcher,
51  const Output<Node>& pattern_value,
52  const Output<Node>& graph_value) override;
53  };
54  } // namespace op
55  } // namespace pattern
56 } // namespace ngraph
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Definition: pattern.hpp:73
Definition: skip.hpp:20
const NodeTypeInfo & get_type_info() const override
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27