any.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 to the matched value list. If the predicate is true for the node
17  /// and the arguments match, the match succeeds.
18  class NGRAPH_API Any : public Pattern
19  {
20  public:
21  static constexpr NodeTypeInfo type_info{"patternAny", 0};
22  const NodeTypeInfo& get_type_info() const override;
23  /// \brief creates a Any node containing a sub-pattern described by \sa type and \sa
24  /// shape.
25  Any(const element::Type& type,
26  const PartialShape& s,
27  ValuePredicate pred,
28  const OutputVector& wrapped_values)
29  : Pattern(wrapped_values, pred)
30  {
31  set_output_type(0, type, s);
32  }
33  Any(const element::Type& type,
34  const PartialShape& s,
35  NodePredicate pred,
36  const NodeVector& wrapped_values)
37  : Any(type, s, as_value_predicate(pred), as_output_vector(wrapped_values))
38  {
39  }
40  /// \brief creates a Any node containing a sub-pattern described by the type and
41  /// shape of \sa node.
42  Any(const Output<Node>& node,
43  ValuePredicate pred,
44  const OutputVector& wrapped_values)
45  : Any(node.get_element_type(), node.get_partial_shape(), pred, wrapped_values)
46  {
47  }
48  Any(const Output<Node>& node, NodePredicate pred, const NodeVector& wrapped_values)
49  : Any(node.get_element_type(),
50  node.get_partial_shape(),
51  as_value_predicate(pred),
52  as_output_vector(wrapped_values))
53  {
54  }
55 
56  bool match_value(pattern::Matcher* matcher,
57  const Output<Node>& pattern_value,
58  const Output<Node>& graph_value) override;
59  };
60  } // namespace op
61  } // namespace pattern
62 } // namespace ngraph
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Class representing a shape that may be partially or totally dynamic.
Definition: partial_shape.hpp:34
Definition: element_type.hpp:51
Definition: matcher.hpp:63
Definition: any.hpp:19
Any(const Output< Node > &node, ValuePredicate pred, const OutputVector &wrapped_values)
creates a Any node containing a sub-pattern described by the type and shape of
Definition: any.hpp:42
Any(const element::Type &type, const PartialShape &s, ValuePredicate pred, const OutputVector &wrapped_values)
creates a Any node containing a sub-pattern described by
Definition: any.hpp:25
const NodeTypeInfo & get_type_info() const override
Definition: pattern.hpp:73
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27