tvm
tir_pattern.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 
25 #ifndef TVM_RELAX_TIR_PATTERN_H_
26 #define TVM_RELAX_TIR_PATTERN_H_
27 
28 #include <tvm/ffi/reflection/registry.h>
29 #include <tvm/tir/function.h>
30 
31 namespace tvm {
32 namespace relax {
33 
35 
36 /*
37  * \brief The match result of a TIR pattern.
38  */
39 class MatchResultNode : public Object {
40  public:
44  Array<PrimExpr> symbol_values;
46  Array<tir::Buffer> matched_buffers;
47 
48  static void RegisterReflection() {
49  namespace refl = tvm::ffi::reflection;
50  refl::ObjectDef<MatchResultNode>()
51  .def_ro("pattern", &MatchResultNode::pattern)
52  .def_ro("symbol_values", &MatchResultNode::symbol_values)
53  .def_ro("matched_buffers", &MatchResultNode::matched_buffers);
54  }
55 
56  static constexpr const char* _type_key = "relax.MatchResult";
58 };
59 
63 class MatchResult : public ObjectRef {
64  public:
71  TVM_DLL explicit MatchResult(TIRPattern pattern, Array<PrimExpr> symbol_values,
72  Array<tir::Buffer> matched_buffers);
73 
75 };
76 
77 using FCodegen = ffi::TypedFunction<Array<ffi::Any>(Array<MatchResult> match_results)>;
78 } // namespace relax
79 } // namespace tvm
80 #endif // TVM_RELAX_TIR_PATTERN_H_
Definition: tir_pattern.h:39
static constexpr const char * _type_key
Definition: tir_pattern.h:56
TIRPattern pattern
Definition: tir_pattern.h:42
static void RegisterReflection()
Definition: tir_pattern.h:48
TVM_DECLARE_FINAL_OBJECT_INFO(MatchResultNode, Object)
Array< PrimExpr > symbol_values
The evaluated values of symbolic vars.
Definition: tir_pattern.h:44
Array< tir::Buffer > matched_buffers
The matched buffers of input and output.
Definition: tir_pattern.h:46
Managed reference to MatchResultNode.
Definition: tir_pattern.h:63
MatchResult(TIRPattern pattern, Array< PrimExpr > symbol_values, Array< tir::Buffer > matched_buffers)
Constructor.
TVM_DEFINE_OBJECT_REF_METHODS(MatchResult, ObjectRef, MatchResultNode)
Managed reference to PrimFuncNode.
Definition: function.h:131
Definition: repr_printer.h:91
ffi::TypedFunction< Array< ffi::Any >(Array< MatchResult > match_results)> FCodegen
Definition: tir_pattern.h:77
PrimFuncFrame PrimFunc(bool is_private)
The primitive function statement.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
TIR Function.