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  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  }
48 
49  static constexpr const char* _type_key = "relax.attrs.AllReduceAttrs";
51 }; // struct AllReduceAttrs
52 
54 struct AllGatherAttrs : public tvm::AttrsNodeReflAdapter<AllGatherAttrs> {
56  bool in_group;
57 
58  static void RegisterReflection() {
59  namespace refl = tvm::ffi::reflection;
60  refl::ObjectDef<AllGatherAttrs>()
61  .def_ro("num_workers", &AllGatherAttrs::num_workers,
62  "The number of workers, also the number of parts the given buffer should be "
63  "chunked into.")
64  .def_ro("in_group", &AllGatherAttrs::in_group,
65  "Whether the allgather operation performs in group or globally or in group as "
66  "default.");
67  }
68 
69  static constexpr const char* _type_key = "relax.attrs.AllGatherAttrs";
71 }; // struct AllGatherAttrs
72 
74 struct ScatterCollectiveAttrs : public tvm::AttrsNodeReflAdapter<ScatterCollectiveAttrs> {
76  int axis;
77 
78  static void RegisterReflection() {
79  namespace refl = tvm::ffi::reflection;
80  refl::ObjectDef<ScatterCollectiveAttrs>()
81  .def_ro("num_workers", &ScatterCollectiveAttrs::num_workers,
82  "The number of workers, also the number of parts the given buffer should be "
83  "chunked into.")
84  .def_ro("axis", &ScatterCollectiveAttrs::axis,
85  "The axis of the tensor to be scattered. The tensor will be chunked along "
86  "this axis.");
87  }
88 
89  static constexpr const char* _type_key = "relax.attrs.ScatterCollectiveAttrs";
91 }; // struct ScatterCollectiveAttrs
92 
93 } // namespace relax
94 } // namespace tvm
95 
96 #endif // TVM_RELAX_ATTRS_CCL_H_
Adapter for AttrsNode with the new reflection API.
Definition: attrs.h:384
Base class of all attribute class.
Definition: attrs.h:103
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:54
static void RegisterReflection()
Definition: ccl.h:58
static constexpr const char * _type_key
Definition: ccl.h:69
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(AllGatherAttrs, BaseAttrsNode)
int num_workers
Definition: ccl.h:55
bool in_group
Definition: ccl.h:56
Attributes used in allreduce operators.
Definition: ccl.h:34
bool in_group
Definition: ccl.h:36
static void RegisterReflection()
Definition: ccl.h:38
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(AllReduceAttrs, BaseAttrsNode)
String op_type
Definition: ccl.h:35
static constexpr const char * _type_key
Definition: ccl.h:49
Attributes used in scatter operators.
Definition: ccl.h:74
static void RegisterReflection()
Definition: ccl.h:78
int num_workers
Definition: ccl.h:75
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(ScatterCollectiveAttrs, BaseAttrsNode)
int axis
Definition: ccl.h:76
static constexpr const char * _type_key
Definition: ccl.h:89