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  ffi::Array<PrimExpr> symbol_values;
46  ffi::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  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.MatchResult", MatchResultNode, Object);
56 };
57 
61 class MatchResult : public ObjectRef {
62  public:
69  TVM_DLL explicit MatchResult(TIRPattern pattern, ffi::Array<PrimExpr> symbol_values,
70  ffi::Array<tir::Buffer> matched_buffers);
71 
73 };
74 
75 using FCodegen = ffi::TypedFunction<ffi::Array<ffi::Any>(ffi::Array<MatchResult> match_results)>;
76 } // namespace relax
77 } // namespace tvm
78 #endif // TVM_RELAX_TIR_PATTERN_H_
Definition: tir_pattern.h:39
TIRPattern pattern
Definition: tir_pattern.h:42
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.MatchResult", MatchResultNode, Object)
static void RegisterReflection()
Definition: tir_pattern.h:48
ffi::Array< tir::Buffer > matched_buffers
The matched buffers of input and output.
Definition: tir_pattern.h:46
ffi::Array< PrimExpr > symbol_values
The evaluated values of symbolic vars.
Definition: tir_pattern.h:44
Managed reference to MatchResultNode.
Definition: tir_pattern.h:61
MatchResult(TIRPattern pattern, ffi::Array< PrimExpr > symbol_values, ffi::Array< tir::Buffer > matched_buffers)
Constructor.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(MatchResult, ObjectRef, MatchResultNode)
Managed reference to PrimFuncNode.
Definition: function.h:129
Definition: repr_printer.h:91
ffi::TypedFunction< ffi::Array< ffi::Any >(ffi::Array< MatchResult > match_results)> FCodegen
Definition: tir_pattern.h:75
PrimFuncFrame PrimFunc(bool is_private)
The primitive function statement.
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
TIR Function.