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  ffi::String te_grad_name;
36  ffi::Map<ffi::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  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.CallTIRWithGradAttrs", CallTIRWithGradAttrs,
49 }; // struct CallTIRAttrs
50 
52 struct CallTIRInplaceAttrs : public AttrsNodeReflAdapter<CallTIRInplaceAttrs> {
60  ffi::Array<Integer> inplace_indices;
61 
62  static void RegisterReflection() {
63  namespace refl = tvm::ffi::reflection;
64  refl::ObjectDef<CallTIRInplaceAttrs>().def_ro("inplace_indices",
66  }
67  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.CallTIRInplaceAttrs", CallTIRInplaceAttrs,
69 }; // struct CallTIRInplaceAttrs
70 
72 struct CallInplacePackedAttrs : public AttrsNodeReflAdapter<CallInplacePackedAttrs> {
80  ffi::Array<Integer> inplace_indices;
81 
82  static void RegisterReflection() {
83  namespace refl = tvm::ffi::reflection;
84  refl::ObjectDef<CallInplacePackedAttrs>().def_ro("inplace_indices",
86  }
87  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.CallInplacePackedAttrs", CallInplacePackedAttrs,
89 }; // struct CallInplacePackedAttrs
90 
92 struct ToVDeviceAttrs : public AttrsNodeReflAdapter<ToVDeviceAttrs> {
94 
95  static void RegisterReflection() {
96  namespace refl = tvm::ffi::reflection;
97  refl::ObjectDef<ToVDeviceAttrs>().def_ro("dst_vdevice", &ToVDeviceAttrs::dst_vdevice,
98  "The destination device where the data is copied to.");
99  }
101 }; // struct ToVDeviceAttrs
102 
104 struct HintOnDeviceAttrs : public AttrsNodeReflAdapter<HintOnDeviceAttrs> {
105  int32_t device_type;
106  int32_t index;
107 
108  static void RegisterReflection() {
109  namespace refl = tvm::ffi::reflection;
110  refl::ObjectDef<HintOnDeviceAttrs>()
111  .def_ro("device_type", &HintOnDeviceAttrs::device_type,
112  "The device type where the data is supposed to be executed.")
113  .def_ro("index", &HintOnDeviceAttrs::index, "The device id.");
114  }
115  TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.HintOnDeviceAttrs", HintOnDeviceAttrs,
116  BaseAttrsNode);
117 }; // struct HintOnDeviceAttrs
118 
119 } // namespace relax
120 } // namespace tvm
121 
122 #endif // TVM_RELAX_ATTRS_OP_H_
Adapter for AttrsNode with the new reflection API.
Definition: attrs.h:385
Base class of all attribute class.
Definition: attrs.h:102
Managed reference to VDeviceNode.
Definition: global_info.h:87
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:72
ffi::Array< Integer > inplace_indices
Indices that describe which input corresponds to which output.
Definition: op.h:80
static void RegisterReflection()
Definition: op.h:82
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.CallInplacePackedAttrs", CallInplacePackedAttrs, BaseAttrsNode)
Attributes used in call_tir_inplace.
Definition: op.h:52
static void RegisterReflection()
Definition: op.h:62
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.CallTIRInplaceAttrs", CallTIRInplaceAttrs, BaseAttrsNode)
ffi::Array< Integer > inplace_indices
Indices that describe which input corresponds to which output.
Definition: op.h:60
Attributes used in call_tir_with_grad.
Definition: op.h:34
ffi::String te_grad_name
Definition: op.h:35
static void RegisterReflection()
Definition: op.h:38
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.CallTIRWithGradAttrs", CallTIRWithGradAttrs, BaseAttrsNode)
ffi::Map< ffi::String, Any > te_grad_kwargs
Definition: op.h:36
Attributes used in hint_on_device.
Definition: op.h:104
int32_t device_type
Definition: op.h:105
static void RegisterReflection()
Definition: op.h:108
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.HintOnDeviceAttrs", HintOnDeviceAttrs, BaseAttrsNode)
int32_t index
Definition: op.h:106
Attributes used in to_vdevice.
Definition: op.h:92
static void RegisterReflection()
Definition: op.h:95
VDevice dst_vdevice
Definition: op.h:93
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.ToVDeviceAttrs", ToVDeviceAttrs, BaseAttrsNode)