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
25#ifndef TVM_RELAX_DISTRIBUTED_GLOBAL_INFO_H_
26#define TVM_RELAX_DISTRIBUTED_GLOBAL_INFO_H_
27
28#include <tvm/base.h>
29#include <tvm/ffi/container/shape.h>
30#include <tvm/ir/expr.h>
31#include <tvm/ir/module.h>
32namespace tvm {
33namespace relax {
34namespace distributed {
35/*
36 * \brief Device mesh express a view of topology of devices, represented by an n-d matrix of
37 * device ids
38 */
40 public:
42 ffi::Shape shape;
43
45 ffi::Array<int64_t> device_ids;
46
48 ffi::Optional<Range> device_range;
49
50 static void RegisterReflection() {
51 namespace refl = tvm::ffi::reflection;
52 refl::ObjectDef<DeviceMeshObj>()
53 .def_ro("shape", &DeviceMeshObj::shape)
54 .def_ro("device_ids", &DeviceMeshObj::device_ids)
55 .def_ro("device_range", &DeviceMeshObj::device_range);
56 }
58};
59
64class DeviceMesh : public GlobalInfo {
65 public:
66 TVM_DLL DeviceMesh(ffi::Shape shape, ffi::Array<int64_t> device_ids);
67 TVM_DLL DeviceMesh(ffi::Shape shape, Range device_range);
69};
70
71} // namespace distributed
72} // namespace relax
73} // namespace tvm
74
75#endif // TVM_RELAX_DISTRIBUTED_GLOBAL_INFO_H_
Base expr nodes in TVM.
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
Range container
Definition expr.h:883
Definition global_info.h:39
ffi::Array< int64_t > device_ids
device ids in the mesh
Definition global_info.h:45
ffi::Optional< Range > device_range
Optionally use range to represent device_ids.
Definition global_info.h:48
static void RegisterReflection()
Definition global_info.h:50
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.distributed.DeviceMesh", DeviceMeshObj, GlobalInfoObj)
ffi::Shape shape
logical shape of the mesh
Definition global_info.h:42
Managed reference to a DeviceMesh.
Definition global_info.h:64
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DeviceMesh, GlobalInfo, DeviceMeshObj)
DeviceMesh(ffi::Shape shape, Range device_range)
DeviceMesh(ffi::Shape shape, ffi::Array< int64_t > device_ids)
Parent compiler symbol visibility.
IRModule that holds the functions and type definitions.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41