tvm
Loading...
Searching...
No Matches
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
24#ifndef TVM_RELAX_GLOBAL_INFO_H_
25#define TVM_RELAX_GLOBAL_INFO_H_
26
27#include <tvm/ir/global_info.h>
28#include <tvm/target/target.h>
29
30namespace tvm {
31namespace relax {
32
36using MemoryScope = ffi::String;
37
42 public:
44 ffi::Optional<Target> target;
50
51 static void RegisterReflection() {
52 namespace refl = tvm::ffi::reflection;
53 refl::ObjectDef<VDeviceNode>()
54 .def_ro("target", &VDeviceNode::target)
55 .def_ro("vdevice_id", &VDeviceNode::vdevice_id)
56 .def_ro("memory_scope", &VDeviceNode::memory_scope);
57 }
58
60};
61
66class VDevice : public GlobalInfo {
67 public:
68 TVM_DLL explicit VDevice(ffi::Optional<Target> tgt, int dev_id, MemoryScope mem_scope);
70};
71
76 public:
77 static void RegisterReflection() {
78 namespace refl = tvm::ffi::reflection;
79 refl::ObjectDef<DummyGlobalInfoNode>();
80 }
81
83};
84
90 public:
91 explicit DummyGlobalInfo(ffi::UnsafeInit tag, ffi::ObjectPtr<DummyGlobalInfoNode> n)
92 : GlobalInfo(tag) {
93 data_ = std::move(n);
94 }
96};
97
98} // namespace relax
99} // namespace tvm
100
101#endif // TVM_RELAX_GLOBAL_INFO_H_
GlobalInfo are globally static object that are referred by the IR itself. Base node for all global in...
Definition global_info.h:36
Managed reference to GlobalInfoNode.
Definition global_info.h:47
A dummy global info sub-class for testing purpose.
Definition global_info.h:75
static void RegisterReflection()
Definition global_info.h:77
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.DummyGlobalInfo", DummyGlobalInfoNode, GlobalInfoNode)
Managed reference to DummyGlobalInfoNode.
Definition global_info.h:89
DummyGlobalInfo(ffi::UnsafeInit tag, ffi::ObjectPtr< DummyGlobalInfoNode > n)
Definition global_info.h:91
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DummyGlobalInfo, GlobalInfo, DummyGlobalInfoNode)
A global info subclass for virtual devices.
Definition global_info.h:41
ffi::Optional< Target > target
The Target describing how to compile for the virtual device.
Definition global_info.h:44
static void RegisterReflection()
Definition global_info.h:51
MemoryScope memory_scope
Definition global_info.h:49
int vdevice_id
The device identifier for the virtual device. This enables us to differentiate between distinct devic...
Definition global_info.h:48
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.VDevice", VDeviceNode, GlobalInfoNode)
Managed reference to VDeviceNode.
Definition global_info.h:66
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(VDevice, GlobalInfo, VDeviceNode)
VDevice(ffi::Optional< Target > tgt, int dev_id, MemoryScope mem_scope)
Base for globally static objects referred to by the IR.
ffi::String MemoryScope
Abstract label for an area of memory.
Definition global_info.h:36
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
Compilation target object.