tvm
global_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  */
19 
25 #ifndef TVM_IR_GLOBAL_INFO_H_
26 #define TVM_IR_GLOBAL_INFO_H_
27 
28 #include <tvm/ir/expr.h>
29 #include <tvm/target/target.h>
30 
31 namespace tvm {
32 
37 
42 class GlobalInfoNode : public Object {
43  public:
44  static constexpr const char* _type_key = "GlobalInfo";
45  static constexpr const bool _type_has_method_sequal_reduce = true;
46  static constexpr const bool _type_has_method_shash_reduce = true;
48 };
49 
54 class GlobalInfo : public ObjectRef {
55  public:
57 };
58 
62 class VDeviceNode : public GlobalInfoNode {
63  public:
72  v->Visit("target", &target);
73  v->Visit("vdevice_id", &vdevice_id);
74  v->Visit("memory_scope", &memory_scope);
75  }
76 
77  TVM_DLL bool SEqualReduce(const VDeviceNode* other, SEqualReducer equal) const {
78  return equal(target, other->target) && equal(vdevice_id, other->vdevice_id) &&
80  }
81 
82  TVM_DLL void SHashReduce(SHashReducer hash_reduce) const {
83  hash_reduce(target);
84  hash_reduce(vdevice_id);
85  hash_reduce(memory_scope);
86  }
87  static constexpr const char* _type_key = "VDevice";
89 };
90 
95 class VDevice : public GlobalInfo {
96  public:
97  TVM_DLL explicit VDevice(Target tgt, int dev_id, MemoryScope mem_scope);
99 };
100 
105  public:
107  static constexpr const char* _type_key = "DummyGlobalInfo";
108 
109  TVM_DLL bool SEqualReduce(const DummyGlobalInfoNode* other, SEqualReducer equal) const {
110  return true;
111  }
112 
113  TVM_DLL void SHashReduce(SHashReducer hash_reduce) const {}
115 };
116 
121 class DummyGlobalInfo : public GlobalInfo {
122  public:
124 };
125 
126 } // namespace tvm
127 
128 #endif // TVM_IR_GLOBAL_INFO_H_
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
A dummy global info sub-class for testing purpose.
Definition: global_info.h:104
TVM_DECLARE_FINAL_OBJECT_INFO(DummyGlobalInfoNode, GlobalInfoNode)
void VisitAttrs(tvm::AttrVisitor *v)
Definition: global_info.h:106
static constexpr const char * _type_key
Definition: global_info.h:107
bool SEqualReduce(const DummyGlobalInfoNode *other, SEqualReducer equal) const
Definition: global_info.h:109
void SHashReduce(SHashReducer hash_reduce) const
Definition: global_info.h:113
Managed reference to DummyGlobalInfoNode.
Definition: global_info.h:121
TVM_DEFINE_OBJECT_REF_METHODS(DummyGlobalInfo, GlobalInfo, DummyGlobalInfoNode)
GlobalInfo are globally static object that are referred by the IR itself. Base node for all global in...
Definition: global_info.h:42
TVM_DECLARE_BASE_OBJECT_INFO(GlobalInfoNode, Object)
static constexpr const bool _type_has_method_sequal_reduce
Definition: global_info.h:45
static constexpr const char * _type_key
Definition: global_info.h:44
static constexpr const bool _type_has_method_shash_reduce
Definition: global_info.h:46
Managed reference to GlobalInfoNode.
Definition: global_info.h:54
TVM_DEFINE_OBJECT_REF_METHODS(GlobalInfo, ObjectRef, GlobalInfoNode)
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:126
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:110
Managed reference class to TargetNode.
Definition: target.h:192
A global info subclass for virtual devices.
Definition: global_info.h:62
Target target
The Target describing how to compile for the virtual device.
Definition: global_info.h:65
void SHashReduce(SHashReducer hash_reduce) const
Definition: global_info.h:82
TVM_DECLARE_FINAL_OBJECT_INFO(VDeviceNode, GlobalInfoNode)
int vdevice_id
The device identifier for the virtual device. This enables us to differentiate between distinct devic...
Definition: global_info.h:69
static constexpr const char * _type_key
Definition: global_info.h:87
bool SEqualReduce(const VDeviceNode *other, SEqualReducer equal) const
Definition: global_info.h:77
MemoryScope memory_scope
Definition: global_info.h:70
void VisitAttrs(tvm::AttrVisitor *v)
Definition: global_info.h:71
Managed reference to VDeviceNode.
Definition: global_info.h:95
VDevice(Target tgt, int dev_id, MemoryScope mem_scope)
TVM_DEFINE_OBJECT_REF_METHODS(VDevice, GlobalInfo, VDeviceNode)
Base class of all object reference.
Definition: object.h:519
base class of all object containers.
Definition: object.h:171
Reference to string objects.
Definition: string.h:98
Base expr nodes in TVM.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
Compilation target object.