tvm
Loading...
Searching...
No Matches
sblock_dependence_info.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 */
31#ifndef TVM_S_TIR_SBLOCK_DEPENDENCE_INFO_H_
32#define TVM_S_TIR_SBLOCK_DEPENDENCE_INFO_H_
33
34#include <tvm/base.h>
35#include <tvm/ffi/reflection/registry.h>
37
38#include <unordered_map>
39
40namespace tvm {
41namespace tirx {
42
55class SBlockDependenceInfoObj : public ffi::Object {
56 public:
61 std::unordered_map<StmtSRef, SBlockScope, ffi::ObjectPtrHash, ffi::ObjectPtrEqual> sref2scope;
63 std::unordered_map<const StmtObj*, StmtSRef> stmt2ref;
64
65 static void RegisterReflection() {
66 namespace refl = tvm::ffi::reflection;
67 refl::ObjectDef<SBlockDependenceInfoObj>();
68 }
70 ffi::Object);
71
77 SBlockScope GetSBlockScope(const StmtSRef& scope_root) const {
78 auto it = sref2scope.find(scope_root);
79 TVM_FFI_CHECK(it != sref2scope.end(), IndexError)
80 << "Cannot find the corresponding SBlockScope to the block sref:\n"
81 << ffi::GetRef<Stmt>(scope_root->stmt);
82 return it->second;
83 }
84};
85
90class SBlockDependenceInfo : public ffi::ObjectRef {
93 TVM_DLL SBlockDependenceInfo();
94
95 public:
99
102};
103
104} // namespace tirx
105} // namespace tvm
106#endif // TVM_S_TIR_SBLOCK_DEPENDENCE_INFO_H_
Managed reference class to IRModuleObj.
Definition module.h:292
An object that helps build and query block level dependences using the 2 core objects SBlockScope and...
Definition sblock_dependence_info.h:55
std::unordered_map< const StmtObj *, StmtSRef > stmt2ref
The reverse mapping from block/for-loop to their corresponding srefs.
Definition sblock_dependence_info.h:63
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.SBlockDependenceInfo", SBlockDependenceInfoObj, ffi::Object)
std::unordered_map< StmtSRef, SBlockScope, ffi::ObjectPtrHash, ffi::ObjectPtrEqual > sref2scope
Mapping from a block sref to its corresponding SBlockScope, tracking the dependency inside the block ...
Definition sblock_dependence_info.h:61
static void RegisterReflection()
Definition sblock_dependence_info.h:65
SBlockScope GetSBlockScope(const StmtSRef &scope_root) const
Get the SBlockScope corresponding to the sref of scope root block.
Definition sblock_dependence_info.h:77
Managed reference to SBlockDependenceInfoObj.
Definition sblock_dependence_info.h:90
SBlockDependenceInfo(IRModule mod)
Construct a SBlockDependenceInfo from IRModule.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(SBlockDependenceInfo, ffi::ObjectRef, SBlockDependenceInfoObj)
Managed reference to SBlockScopeObj.
Definition sblock_scope.h:309
Managed reference to StmtSRefObj.
Definition sblock_scope.h:109
Parent compiler symbol visibility.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Definition of two pillar data structure for TensorIR scheduling: StmtSRef, SBlockScope.