tvm
Loading...
Searching...
No Matches
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/tirx/function.h>
30
31namespace tvm {
32namespace relax {
33
35
36/*
37 * \brief The match result of a TIR pattern.
38 */
39class MatchResultNode : public ffi::Object {
40 public:
44 ffi::Array<PrimExpr> symbol_values;
46 ffi::Array<tirx::BufferVar> 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, ffi::Object);
56};
57
61class MatchResult : public ffi::ObjectRef {
62 public:
69 TVM_DLL explicit MatchResult(TIRPattern pattern, ffi::Array<PrimExpr> symbol_values,
70 ffi::Array<tirx::BufferVar> matched_buffers);
71
73};
74
75using 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_
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Definition tir_pattern.h:39
TIRPattern pattern
Definition tir_pattern.h:42
static void RegisterReflection()
Definition tir_pattern.h:48
ffi::Array< tirx::BufferVar > 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
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.MatchResult", MatchResultNode, ffi::Object)
Managed reference to MatchResultNode.
Definition tir_pattern.h:61
MatchResult(TIRPattern pattern, ffi::Array< PrimExpr > symbol_values, ffi::Array< tirx::BufferVar > matched_buffers)
Constructor.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(MatchResult, ffi::ObjectRef, MatchResultNode)
Managed reference to PrimFuncNode.
Definition function.h:105
ffi::TypedFunction< ffi::Array< ffi::Any >(ffi::Array< MatchResult > match_results)> FCodegen
Definition tir_pattern.h:75
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
TIR Function.