tvm
op.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_OP_H_
25 #define TVM_RELAX_ATTRS_OP_H_
26 
27 #include <tvm/ir/global_info.h>
28 #include <tvm/relax/expr.h>
29 
30 namespace tvm {
31 namespace relax {
32 
34 struct CallTIRWithGradAttrs : public AttrsNodeReflAdapter<CallTIRWithGradAttrs> {
35  String te_grad_name;
36  Map<String, Any> te_grad_kwargs;
37 
38  static void RegisterReflection() {
39  namespace refl = tvm::ffi::reflection;
40  refl::ObjectDef<CallTIRWithGradAttrs>()
41  .def_ro(
42  "te_grad_name", &CallTIRWithGradAttrs::te_grad_name,
43  "The name of the te gradient function associated with this call_tir_with_grad node.")
44  .def_ro("te_grad_kwargs", &CallTIRWithGradAttrs::te_grad_kwargs,
45  "The keyword arguments passed to the te gradient function.");
46  }
47 
48  static constexpr const char* _type_key = "relax.attrs.CallTIRWithGradAttrs";
50 }; // struct CallTIRAttrs
51 
53 struct CallTIRInplaceAttrs : public AttrsNodeReflAdapter<CallTIRInplaceAttrs> {
61  Array<Integer> inplace_indices;
62 
63  static void RegisterReflection() {
64  namespace refl = tvm::ffi::reflection;
65  refl::ObjectDef<CallTIRInplaceAttrs>().def_ro("inplace_indices",
67  }
68 
69  static constexpr const char* _type_key = "relax.attrs.CallTIRInplaceAttrs";
71 }; // struct CallTIRInplaceAttrs
72 
74 struct CallInplacePackedAttrs : public AttrsNodeReflAdapter<CallInplacePackedAttrs> {
82  Array<Integer> inplace_indices;
83 
84  static void RegisterReflection() {
85  namespace refl = tvm::ffi::reflection;
86  refl::ObjectDef<CallInplacePackedAttrs>().def_ro("inplace_indices",
88  }
89 
90  static constexpr const char* _type_key = "relax.attrs.CallInplacePackedAttrs";
92 }; // struct CallInplacePackedAttrs
93 
95 struct ToVDeviceAttrs : public AttrsNodeReflAdapter<ToVDeviceAttrs> {
97 
98  static void RegisterReflection() {
99  namespace refl = tvm::ffi::reflection;
100  refl::ObjectDef<ToVDeviceAttrs>().def_ro("dst_vdevice", &ToVDeviceAttrs::dst_vdevice,
101  "The destination device where the data is copied to.");
102  }
103 
104  static constexpr const char* _type_key = "relax.attrs.ToVDeviceAttrs";
106 }; // struct ToVDeviceAttrs
107 
109 struct HintOnDeviceAttrs : public AttrsNodeReflAdapter<HintOnDeviceAttrs> {
110  int32_t dev_type;
111  int32_t dev_id;
112 
113  static void RegisterReflection() {
114  namespace refl = tvm::ffi::reflection;
115  refl::ObjectDef<HintOnDeviceAttrs>()
116  .def_ro("dev_type", &HintOnDeviceAttrs::dev_type,
117  "The device type where the data is supposed to be executed.")
118  .def_ro("dev_id", &HintOnDeviceAttrs::dev_id, "The device id.");
119  }
120 
121  static constexpr const char* _type_key = "relax.attrs.HintOnDeviceAttrs";
123 }; // struct HintOnDeviceAttrs
124 
125 } // namespace relax
126 } // namespace tvm
127 
128 #endif // TVM_RELAX_ATTRS_OP_H_
Adapter for AttrsNode with the new reflection API.
Definition: attrs.h:384
Base class of all attribute class.
Definition: attrs.h:103
Managed reference to VDeviceNode.
Definition: global_info.h:90
GlobalInfo are globally static object that are referred by the IR itself.
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
Attributes used in call_inplace_packed.
Definition: op.h:74
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(CallInplacePackedAttrs, BaseAttrsNode)
static constexpr const char * _type_key
Definition: op.h:90
Array< Integer > inplace_indices
Indices that describe which input corresponds to which output.
Definition: op.h:82
static void RegisterReflection()
Definition: op.h:84
Attributes used in call_tir_inplace.
Definition: op.h:53
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(CallTIRInplaceAttrs, BaseAttrsNode)
static void RegisterReflection()
Definition: op.h:63
Array< Integer > inplace_indices
Indices that describe which input corresponds to which output.
Definition: op.h:61
static constexpr const char * _type_key
Definition: op.h:69
Attributes used in call_tir_with_grad.
Definition: op.h:34
String te_grad_name
Definition: op.h:35
Map< String, Any > te_grad_kwargs
Definition: op.h:36
static void RegisterReflection()
Definition: op.h:38
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(CallTIRWithGradAttrs, BaseAttrsNode)
static constexpr const char * _type_key
Definition: op.h:48
Attributes used in hint_on_device.
Definition: op.h:109
int32_t dev_id
Definition: op.h:111
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(HintOnDeviceAttrs, BaseAttrsNode)
int32_t dev_type
Definition: op.h:110
static void RegisterReflection()
Definition: op.h:113
static constexpr const char * _type_key
Definition: op.h:121
Attributes used in to_vdevice.
Definition: op.h:95
static void RegisterReflection()
Definition: op.h:98
static constexpr const char * _type_key
Definition: op.h:104
VDevice dst_vdevice
Definition: op.h:96
TVM_FFI_DECLARE_FINAL_OBJECT_INFO(ToVDeviceAttrs, BaseAttrsNode)