tvm
ccl.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_ATTRS_CCL_H_
25 #define TVM_RELAX_ATTRS_CCL_H_
26 
27 #include <tvm/ffi/reflection/registry.h>
28 #include <tvm/relax/expr.h>
29 
30 namespace tvm {
31 namespace relax {
32 
34 struct AllReduceAttrs : public tvm::AttrsNodeReflAdapter<AllReduceAttrs> {
35  ffi::String op_type;
36  bool in_group;
37 
38  static void RegisterReflection() {
39  namespace refl = tvm::ffi::reflection;
40  refl::ObjectDef<AllReduceAttrs>()
41  .def_ro("op_type", &AllReduceAttrs::op_type,
42  "The type of reduction operation to be applied to the input data. Now only sum is "
43  "supported.")
44  .def_ro("in_group", &AllReduceAttrs::in_group,
45  "Whether the reduction operation performs in group or globally or in group as "
46  "default.");
47  }
49 }; // struct AllReduceAttrs
50 
52 struct AllGatherAttrs : public tvm::AttrsNodeReflAdapter<AllGatherAttrs> {
54  bool in_group;
55 
56  static void RegisterReflection() {
57  namespace refl = tvm::ffi::reflection;
58  refl::ObjectDef<AllGatherAttrs>()
59  .def_ro("num_workers", &AllGatherAttrs::num_workers,
60  "The number of workers, also the number of parts the given buffer should be "
61  "chunked into.")
62  .def_ro("in_group", &AllGatherAttrs::in_group,
63  "Whether the allgather operation performs in group or globally or in group as "
64  "default.");
65  }
67 }; // struct AllGatherAttrs
68 
70 struct ScatterCollectiveAttrs : public tvm::AttrsNodeReflAdapter<ScatterCollectiveAttrs> {
72  int axis;
73 
74  static void RegisterReflection() {
75  namespace refl = tvm::ffi::reflection;
76  refl::ObjectDef<ScatterCollectiveAttrs>()
77  .def_ro("num_workers", &ScatterCollectiveAttrs::num_workers,
78  "The number of workers, also the number of parts the given buffer should be "
79  "chunked into.")
80  .def_ro("axis", &ScatterCollectiveAttrs::axis,
81  "The axis of the tensor to be scattered. The tensor will be chunked along "
82  "this axis.");
83  }
84  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.ScatterCollectiveAttrs", ScatterCollectiveAttrs,
86 }; // struct ScatterCollectiveAttrs
87 
88 } // namespace relax
89 } // namespace tvm
90 
91 #endif // TVM_RELAX_ATTRS_CCL_H_
Adapter for AttrsNode with the new reflection API.
Definition: attrs.h:385
Base class of all attribute class.
Definition: attrs.h:102
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
Attributes used in allgather operators.
Definition: ccl.h:52
static void RegisterReflection()
Definition: ccl.h:56
int num_workers
Definition: ccl.h:53
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.AllGatherAttrs", AllGatherAttrs, BaseAttrsNode)
bool in_group
Definition: ccl.h:54
Attributes used in allreduce operators.
Definition: ccl.h:34
bool in_group
Definition: ccl.h:36
static void RegisterReflection()
Definition: ccl.h:38
ffi::String op_type
Definition: ccl.h:35
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.AllReduceAttrs", AllReduceAttrs, BaseAttrsNode)
Attributes used in scatter operators.
Definition: ccl.h:70
static void RegisterReflection()
Definition: ccl.h:74
int num_workers
Definition: ccl.h:71
int axis
Definition: ccl.h:72
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.ScatterCollectiveAttrs", ScatterCollectiveAttrs, BaseAttrsNode)