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 = ffi::String;
38 
43 class GlobalInfoNode : public Object {
44  public:
45  static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
46 
47  TVM_FFI_DECLARE_OBJECT_INFO("ir.GlobalInfo", GlobalInfoNode, Object);
48 };
49 
54 class GlobalInfo : public ObjectRef {
55  public:
57 };
58 
62 class VDeviceNode : public GlobalInfoNode {
63  public:
71 
72  static void RegisterReflection() {
73  namespace refl = tvm::ffi::reflection;
74  refl::ObjectDef<VDeviceNode>()
75  .def_ro("target", &VDeviceNode::target)
76  .def_ro("vdevice_id", &VDeviceNode::vdevice_id)
77  .def_ro("memory_scope", &VDeviceNode::memory_scope);
78  }
79 
81 };
82 
87 class VDevice : public GlobalInfo {
88  public:
89  TVM_DLL explicit VDevice(Target tgt, int dev_id, MemoryScope mem_scope);
91 };
92 
97  public:
98  static void RegisterReflection() {
99  namespace refl = tvm::ffi::reflection;
100  refl::ObjectDef<DummyGlobalInfoNode>();
101  }
102 
104 };
105 
110 class DummyGlobalInfo : public GlobalInfo {
111  public:
113 };
114 
115 } // namespace tvm
116 
117 #endif // TVM_IR_GLOBAL_INFO_H_
A dummy global info sub-class for testing purpose.
Definition: global_info.h:96
static void RegisterReflection()
Definition: global_info.h:98
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.DummyGlobalInfo", DummyGlobalInfoNode, GlobalInfoNode)
Managed reference to DummyGlobalInfoNode.
Definition: global_info.h:110
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(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
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: global_info.h:45
TVM_FFI_DECLARE_OBJECT_INFO("ir.GlobalInfo", GlobalInfoNode, Object)
Managed reference to GlobalInfoNode.
Definition: global_info.h:54
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(GlobalInfo, ObjectRef, GlobalInfoNode)
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
int vdevice_id
The device identifier for the virtual device. This enables us to differentiate between distinct devic...
Definition: global_info.h:69
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.VDevice", VDeviceNode, GlobalInfoNode)
static void RegisterReflection()
Definition: global_info.h:72
MemoryScope memory_scope
Definition: global_info.h:70
Managed reference to VDeviceNode.
Definition: global_info.h:87
VDevice(Target tgt, int dev_id, MemoryScope mem_scope)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(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
ffi::String MemoryScope
Abstract label for an area of memory.
Definition: global_info.h:37
Compilation target object.