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/base.h>
28#include <tvm/ir/global_info.h>
30#include <tvm/target/target.h>
31
32namespace tvm {
33namespace relax {
34
38using runtime::MemoryScope;
39
43class VDeviceObj : public GlobalInfoObj {
44 public:
46 ffi::Optional<Target> target;
52
53 static void RegisterReflection() {
54 namespace refl = tvm::ffi::reflection;
55 refl::ObjectDef<VDeviceObj>()
56 .def_ro("target", &VDeviceObj::target)
57 .def_ro("vdevice_id", &VDeviceObj::vdevice_id)
58 .def_ro("memory_scope", &VDeviceObj::memory_scope);
59 }
60
62};
63
68class VDevice : public GlobalInfo {
69 public:
70 TVM_DLL explicit VDevice(ffi::Optional<Target> tgt, int dev_id, MemoryScope mem_scope);
72};
73
78 public:
79 static void RegisterReflection() {
80 namespace refl = tvm::ffi::reflection;
81 refl::ObjectDef<DummyGlobalInfoObj>();
82 }
83
85};
86
92 public:
93 explicit DummyGlobalInfo(ffi::UnsafeInit tag, ffi::ObjectPtr<DummyGlobalInfoObj> n)
94 : GlobalInfo(tag) {
95 data_ = std::move(n);
96 }
98};
99
100} // namespace relax
101} // namespace tvm
102
103#endif // TVM_RELAX_GLOBAL_INFO_H_
Base for globally static objects referred to by the IR.
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 GlobalInfoObj.
Definition global_info.h:47
A dummy global info sub-class for testing purpose.
Definition global_info.h:77
static void RegisterReflection()
Definition global_info.h:79
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.DummyGlobalInfo", DummyGlobalInfoObj, GlobalInfoObj)
Managed reference to DummyGlobalInfoObj.
Definition global_info.h:91
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DummyGlobalInfo, GlobalInfo, DummyGlobalInfoObj)
DummyGlobalInfo(ffi::UnsafeInit tag, ffi::ObjectPtr< DummyGlobalInfoObj > n)
Definition global_info.h:93
A global info subclass for virtual devices.
Definition global_info.h:43
static void RegisterReflection()
Definition global_info.h:53
int vdevice_id
The device identifier for the virtual device. This enables us to differentiate between distinct devic...
Definition global_info.h:50
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.VDevice", VDeviceObj, GlobalInfoObj)
MemoryScope memory_scope
Definition global_info.h:51
ffi::Optional< Target > target
The Target describing how to compile for the virtual device.
Definition global_info.h:46
Managed reference to VDeviceObj.
Definition global_info.h:68
VDevice(ffi::Optional< Target > tgt, int dev_id, MemoryScope mem_scope)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(VDevice, GlobalInfo, VDeviceObj)
A registered memory space, independent of backend allocation policy.
Definition memory_scope.h:65
Parent compiler symbol visibility.
Memory scopes and allocation properties for runtime storage.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Compilation target object.