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 MatchResultObj : public ffi::Object {
40 public:
41 explicit MatchResultObj(TIRPattern pattern) : pattern(std::move(pattern)) {}
42 explicit MatchResultObj(ffi::UnsafeInit) : pattern(ffi::UnsafeInit{}) {}
43
47 ffi::Array<PrimExpr> symbol_values;
49 ffi::Array<tirx::TensorVar> matched_tensors;
50
51 static void RegisterReflection() {
52 namespace refl = tvm::ffi::reflection;
53 refl::ObjectDef<MatchResultObj>()
54 .def_ro("pattern", &MatchResultObj::pattern)
55 .def_ro("symbol_values", &MatchResultObj::symbol_values)
56 .def_ro("matched_tensors", &MatchResultObj::matched_tensors);
57 }
58 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.MatchResult", MatchResultObj, ffi::Object);
59};
60
64class MatchResult : public ffi::ObjectRef {
65 public:
72 TVM_DLL explicit MatchResult(TIRPattern pattern, ffi::Array<PrimExpr> symbol_values,
73 ffi::Array<tirx::TensorVar> matched_tensors);
74
76};
77
78using FCodegen = ffi::TypedFunction<ffi::Array<ffi::Any>(ffi::Array<MatchResult> match_results)>;
79} // namespace relax
80} // namespace tvm
81#endif // TVM_RELAX_TIR_PATTERN_H_
Definition tir_pattern.h:39
TIRPattern pattern
Definition tir_pattern.h:45
MatchResultObj(ffi::UnsafeInit)
Definition tir_pattern.h:42
MatchResultObj(TIRPattern pattern)
Definition tir_pattern.h:41
ffi::Array< PrimExpr > symbol_values
The evaluated values of symbolic vars.
Definition tir_pattern.h:47
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.MatchResult", MatchResultObj, ffi::Object)
static void RegisterReflection()
Definition tir_pattern.h:51
ffi::Array< tirx::TensorVar > matched_tensors
The matched tensors of input and output.
Definition tir_pattern.h:49
Managed reference to MatchResultObj.
Definition tir_pattern.h:64
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(MatchResult, ffi::ObjectRef, MatchResultObj)
MatchResult(TIRPattern pattern, ffi::Array< PrimExpr > symbol_values, ffi::Array< tirx::TensorVar > matched_tensors)
Constructor.
Managed reference to FunctionNode.
Definition function.h:105
ffi::TypedFunction< ffi::Array< ffi::Any >(ffi::Array< MatchResult > match_results)> FCodegen
Definition tir_pattern.h:78
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
TIR Function.