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_RELAX_DISTRIBUTED_GLOBAL_INFO_H_
26 #define TVM_RELAX_DISTRIBUTED_GLOBAL_INFO_H_
27 
28 #include <tvm/ffi/container/shape.h>
29 #include <tvm/ir/expr.h>
30 #include <tvm/ir/module.h>
31 namespace tvm {
32 namespace relax {
33 namespace distributed {
34 /*
35  * \brief Device mesh express a view of topology of devices, represented by an n-d matrix of
36  * device ids
37  */
39  public:
41  ffi::Shape shape;
42 
44  ffi::Array<int64_t> device_ids;
45 
47  ffi::Optional<Range> device_range;
48 
49  static void RegisterReflection() {
50  namespace refl = tvm::ffi::reflection;
51  refl::ObjectDef<DeviceMeshNode>()
52  .def_ro("shape", &DeviceMeshNode::shape)
53  .def_ro("device_ids", &DeviceMeshNode::device_ids)
54  .def_ro("device_range", &DeviceMeshNode::device_range);
55  }
57 };
58 
63 class DeviceMesh : public GlobalInfo {
64  public:
65  TVM_DLL DeviceMesh(ffi::Shape shape, ffi::Array<int64_t> device_ids);
66  TVM_DLL DeviceMesh(ffi::Shape shape, Range device_range);
68 };
69 
70 } // namespace distributed
71 } // namespace relax
72 } // namespace tvm
73 
74 #endif // TVM_RELAX_DISTRIBUTED_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:43
Managed reference to GlobalInfoNode.
Definition: global_info.h:54
Range container
Definition: expr.h:484
Definition: global_info.h:38
ffi::Shape shape
logical shape of the mesh
Definition: global_info.h:41
ffi::Array< int64_t > device_ids
device ids in the mesh
Definition: global_info.h:44
static void RegisterReflection()
Definition: global_info.h:49
ffi::Optional< Range > device_range
Optionally use range to represent device_ids.
Definition: global_info.h:47
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.distributed.DeviceMesh", DeviceMeshNode, GlobalInfoNode)
Managed reference to a DeviceMesh.
Definition: global_info.h:63
DeviceMesh(ffi::Shape shape, Range device_range)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(DeviceMesh, GlobalInfo, DeviceMeshNode)
DeviceMesh(ffi::Shape shape, ffi::Array< int64_t > device_ids)
Base expr nodes in TVM.
IRModule that holds the functions and type definitions.
Tensor shape(const Tensor &src, PrimType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:2010
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40