any.hpp
1 //*****************************************************************************
2 // Copyright 2017-2020 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 to the matched value list. If the predicate is true for the node
29  /// and the arguments match, the match succeeds.
30  class NGRAPH_API Any : public Pattern
31  {
32  public:
33  static constexpr NodeTypeInfo type_info{"patternAny", 0};
34  const NodeTypeInfo& get_type_info() const override;
35  /// \brief creates a Any node containing a sub-pattern described by \sa type and \sa
36  /// shape.
37  Any(const element::Type& type,
38  const PartialShape& s,
39  ValuePredicate pred,
40  const OutputVector& wrapped_values)
41  : Pattern(wrapped_values, pred)
42  {
43  set_output_type(0, type, s);
44  }
45  Any(const element::Type& type,
46  const PartialShape& s,
47  NodePredicate pred,
48  const NodeVector& wrapped_values)
49  : Any(type, s, as_value_predicate(pred), as_output_vector(wrapped_values))
50  {
51  }
52  /// \brief creates a Any node containing a sub-pattern described by the type and
53  /// shape of \sa node.
54  Any(const Output<Node>& node,
55  ValuePredicate pred,
56  const OutputVector& wrapped_values)
57  : Any(node.get_element_type(), node.get_partial_shape(), pred, wrapped_values)
58  {
59  }
60  Any(const Output<Node>& node, NodePredicate pred, const NodeVector& wrapped_values)
61  : Any(node.get_element_type(),
62  node.get_partial_shape(),
63  as_value_predicate(pred),
64  as_output_vector(wrapped_values))
65  {
66  }
67 
68  bool match_value(pattern::Matcher* matcher,
69  const Output<Node>& pattern_value,
70  const Output<Node>& graph_value) override;
71  };
72  }
73  }
74 }
ngraph::pattern::op::Any
Definition: any.hpp:31
ngraph::pattern::op::Any::Any
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:54
ngraph::pattern::op::Any::Any
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:37
ngraph::pattern::Matcher
Definition: matcher.hpp:75
ngraph::pattern::op::Any::get_type_info
const NodeTypeInfo & get_type_info() const override
ngraph::element::Type
Definition: element_type.hpp:61
ngraph::pattern::op::Pattern
Definition: pattern.hpp:79
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28