tvm
dataflow_matcher.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef TVM_RELAX_DATAFLOW_MATCHER_H_
25 #define TVM_RELAX_DATAFLOW_MATCHER_H_
26 
29 
30 #include <memory>
31 
32 namespace tvm {
33 namespace relax {
34 
47 
48 /* \brief Similar to above, but return pairs of a matching pattern and an expression. */
50  DFPattern pattern, Expr expr, Optional<runtime::Map<Var, Expr>> bindings = NullOpt);
51 
59  const DataflowBlock& dfb);
60 
71  const PatternContext& ctx,
73 
97 TVM_DLL Function RewriteCall(const DFPattern& pattern,
99  Function func);
100 
101 } // namespace relax
102 } // namespace tvm
103 
104 #endif // TVM_RELAX_DATAFLOW_MATCHER_H_
Managed reference to RelayExprNode.
Definition: expr.h:442
Managed reference to dataflow patterns.
Definition: dataflow_pattern.h:101
Definition: expr.h:806
Definition: expr.h:995
Managed reference to a pattern context.
Definition: dataflow_pattern.h:278
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Please refer to TypedPackedFunc<R(Args..)>.
Definition: packed_func.h:63
Optional< Map< DFPattern, Expr > > ExtractMatchedExpr(DFPattern pattern, Expr expr, Optional< runtime::Map< Var, Expr >> bindings=NullOpt)
Function RewriteCall(const DFPattern &pattern, TypedPackedFunc< Expr(Expr, Map< DFPattern, Expr >)> rewriter, Function func)
Rewrite a function with the given pattern and the rewriter function.
Optional< Map< DFPattern, Var > > MatchGraph(const PatternContext &ctx, const DataflowBlock &dfb)
Match a sub-graph in a DataflowBlock with a graph of patterns and return the mapping.
Function RewriteBindings(const PatternContext &ctx, TypedPackedFunc< Map< Var, Expr >(Map< DFPattern, Var >, Map< Var, Expr >)> rewriter, Function f)
Rewrite a function with the given pattern and the rewriter function.
RelayExpr Expr
Definition: expr.h:37
bool MatchExpr(DFPattern pattern, Expr expr, Optional< runtime::Map< Var, Expr >> bindings=NullOpt)
Determine if a pattern matches an expression.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
constexpr runtime::NullOptType NullOpt
Definition: optional.h:169
Runtime Optional container types.
A pattern language for matching dataflow properties.