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/ffi/reflection/registry.h>
29 #include <tvm/ir/expr.h>
30 #include <tvm/target/target.h>
31 
32 namespace tvm {
33 
37 using MemoryScope = String;
38 
43 class GlobalInfoNode : public Object {
44  public:
45  static constexpr const char* _type_key = "ir.GlobalInfo";
46 
47  static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
48 
50 };
51 
56 class GlobalInfo : public ObjectRef {
57  public:
59 };
60 
64 class VDeviceNode : public GlobalInfoNode {
65  public:
73 
74  static void RegisterReflection() {
75  namespace refl = tvm::ffi::reflection;
76  refl::ObjectDef<VDeviceNode>()
77  .def_ro("target", &VDeviceNode::target)
78  .def_ro("vdevice_id", &VDeviceNode::vdevice_id)
79  .def_ro("memory_scope", &VDeviceNode::memory_scope);
80  }
81 
82  static constexpr const char* _type_key = "ir.VDevice";
84 };
85 
90 class VDevice : public GlobalInfo {
91  public:
92  TVM_DLL explicit VDevice(Target tgt, int dev_id, MemoryScope mem_scope);
94 };
95 
100  public:
101  static void RegisterReflection() {
102  namespace refl = tvm::ffi::reflection;
103  refl::ObjectDef<DummyGlobalInfoNode>();
104  }
105 
106  static constexpr const char* _type_key = "ir.DummyGlobalInfo";
108 };
109 
114 class DummyGlobalInfo : public GlobalInfo {
115  public:
117 };
118 
119 } // namespace tvm
120 
121 #endif // TVM_IR_GLOBAL_INFO_H_
A dummy global info sub-class for testing purpose.
Definition: global_info.h:99
TVM_DECLARE_FINAL_OBJECT_INFO(DummyGlobalInfoNode, GlobalInfoNode)
static constexpr const char * _type_key
Definition: global_info.h:106
static void RegisterReflection()
Definition: global_info.h:101
Managed reference to DummyGlobalInfoNode.
Definition: global_info.h:114
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:43
TVM_DECLARE_BASE_OBJECT_INFO(GlobalInfoNode, Object)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: global_info.h:47
static constexpr const char * _type_key
Definition: global_info.h:45
Managed reference to GlobalInfoNode.
Definition: global_info.h:56
TVM_DEFINE_OBJECT_REF_METHODS(GlobalInfo, ObjectRef, GlobalInfoNode)
Managed reference class to TargetNode.
Definition: target.h:191
A global info subclass for virtual devices.
Definition: global_info.h:64
Target target
The Target describing how to compile for the virtual device.
Definition: global_info.h:67
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:71
static constexpr const char * _type_key
Definition: global_info.h:82
static void RegisterReflection()
Definition: global_info.h:74
MemoryScope memory_scope
Definition: global_info.h:72
Managed reference to VDeviceNode.
Definition: global_info.h:90
VDevice(Target tgt, int dev_id, MemoryScope mem_scope)
TVM_DEFINE_OBJECT_REF_METHODS(VDevice, GlobalInfo, VDeviceNode)
Base expr nodes in TVM.
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
String MemoryScope
Abstract label for an area of memory.
Definition: global_info.h:37
Compilation target object.