tvm
Loading...
Searching...
No Matches
stmt_functor_with_analyzer.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_S_TIR_STMT_FUNCTOR_WITH_ANALYZER_H_
26#define TVM_S_TIR_STMT_FUNCTOR_WITH_ANALYZER_H_
27
30
31namespace tvm {
32namespace s_tir {
33
35 public:
37 using Parent::Visit;
38 using Parent::Visit_;
40 virtual ffi::Optional<VisitInterrupt> Visit_(const SBlockNode* op);
41 virtual ffi::Optional<VisitInterrupt> Visit_(const SBlockRealizeNode* op) {
42 return s_tir::StmtExprVisitor::VisitBlockRealize(this, op);
43 }
44
45 protected:
46 static void InitVTable(VTable* vtable) {
47 Parent::InitVTable(vtable);
48 SetDispatch<StmtExprVisitorWithAnalyzer, SBlockNode>(vtable);
49 SetDispatch<StmtExprVisitorWithAnalyzer, SBlockRealizeNode>(vtable);
50 }
51};
52
54 public:
56 using Parent::Mutate;
57 using Parent::Mutate_;
59 : StmtExprMutatorWithAnalyzer(analyzer.get()) {}
61 : Parent(analyzer, GlobalVTable()) {}
62 virtual UnchangedOr<Stmt> Mutate_(const SBlockNode* op, InplaceMode inplace_mode);
63 virtual UnchangedOr<Stmt> Mutate_(const SBlockRealizeNode* op, InplaceMode inplace_mode) {
64 return s_tir::StmtExprMutator::MutateBlockRealize(this, op, inplace_mode);
65 }
66
67 protected:
68 static void InitVTable(VTable* vtable) {
69 Parent::InitVTable(vtable);
70 SetDispatch<StmtExprMutatorWithAnalyzer, SBlockNode>(vtable);
71 SetDispatch<StmtExprMutatorWithAnalyzer, SBlockRealizeNode>(vtable);
72 }
73 static const VTable* GlobalVTable() {
74 static const VTable table = [] {
75 VTable table;
76 InitVTable(&table);
77 table.Finalize();
78 return table;
79 }();
80 return &table;
81 }
82};
83
84} // namespace s_tir
85} // namespace tvm
86#endif // TVM_S_TIR_STMT_FUNCTOR_WITH_ANALYZER_H_
A dynamically dispatched functor on the type of the first argument.
Definition object_functor.h:85
A block is a basic schedule unit in TIR.
Definition stmt.h:112
A block realization node represents execution of the block at the binding values.
Definition stmt.h:188
Definition stmt_functor_with_analyzer.h:53
virtual UnchangedOr< Stmt > Mutate_(const SBlockRealizeNode *op, InplaceMode inplace_mode)
Definition stmt_functor_with_analyzer.h:63
static void InitVTable(VTable *vtable)
Definition stmt_functor_with_analyzer.h:68
static const VTable * GlobalVTable()
Definition stmt_functor_with_analyzer.h:73
StmtExprMutatorWithAnalyzer(sym::AnalyzerObj *analyzer)
Definition stmt_functor_with_analyzer.h:60
StmtExprMutatorWithAnalyzer(const sym::Analyzer &analyzer)
Definition stmt_functor_with_analyzer.h:58
virtual UnchangedOr< Stmt > Mutate_(const SBlockNode *op, InplaceMode inplace_mode)
Definition stmt_functor_with_analyzer.h:34
static void InitVTable(VTable *vtable)
Definition stmt_functor_with_analyzer.h:46
Analyzer that contains bunch of sub-analyzers.
Definition analyzer.h:715
Managed reference to AnalyzerObj.
Definition analyzer.h:916
IRMutator with an analyzer context.
Definition stmt_functor_with_analyzer.h:89
Definition stmt_functor_with_analyzer.h:43
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
#define TVM_DEFINE_OBJECT_FUNCTOR_DEFAULT_CONSTRUCTOR(Class, Parent)
Define a default constructor backed by one initialized native dispatch table.
Definition object_functor.h:529
Native traversal and statement dispatch for schedulable TIR.
Statement and expression functors with an analyzer context.