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/base.h>
29#include <tvm/ffi/reflection/registry.h>
30#include <tvm/tirx/function.h>
31
32namespace tvm {
33namespace relax {
34
36
37/*
38 * \brief The match result of a TIR pattern.
39 */
40class MatchResultObj : public ffi::Object {
41 public:
42 explicit MatchResultObj(TIRPattern pattern) : pattern(std::move(pattern)) {}
43 explicit MatchResultObj(ffi::UnsafeInit) : pattern(ffi::UnsafeInit{}) {}
44
48 ffi::Array<PrimExpr> symbol_values;
50 ffi::Array<tirx::TensorVar> matched_tensors;
51
52 static void RegisterReflection() {
53 namespace refl = tvm::ffi::reflection;
54 refl::ObjectDef<MatchResultObj>()
55 .def_ro("pattern", &MatchResultObj::pattern)
56 .def_ro("symbol_values", &MatchResultObj::symbol_values)
57 .def_ro("matched_tensors", &MatchResultObj::matched_tensors);
58 }
59 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.MatchResult", MatchResultObj, ffi::Object);
60};
61
65class MatchResult : public ffi::ObjectRef {
66 public:
73 TVM_DLL explicit MatchResult(TIRPattern pattern, ffi::Array<PrimExpr> symbol_values,
74 ffi::Array<tirx::TensorVar> matched_tensors);
75
77};
78
79using FCodegen = ffi::TypedFunction<ffi::Array<ffi::Any>(ffi::Array<MatchResult> match_results)>;
80} // namespace relax
81} // namespace tvm
82#endif // TVM_RELAX_TIR_PATTERN_H_
TIR Function.
Definition tir_pattern.h:40
TIRPattern pattern
Definition tir_pattern.h:46
MatchResultObj(ffi::UnsafeInit)
Definition tir_pattern.h:43
MatchResultObj(TIRPattern pattern)
Definition tir_pattern.h:42
ffi::Array< PrimExpr > symbol_values
The evaluated values of symbolic vars.
Definition tir_pattern.h:48
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.MatchResult", MatchResultObj, ffi::Object)
static void RegisterReflection()
Definition tir_pattern.h:52
ffi::Array< tirx::TensorVar > matched_tensors
The matched tensors of input and output.
Definition tir_pattern.h:50
Managed reference to MatchResultObj.
Definition tir_pattern.h:65
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 FunctionObj.
Definition function.h:107
Parent compiler symbol visibility.
ffi::TypedFunction< ffi::Array< ffi::Any >(ffi::Array< MatchResult > match_results)> FCodegen
Definition tir_pattern.h:79
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41