tvm
annotation.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_RELAY_ATTRS_ANNOTATION_H_
25 #define TVM_RELAY_ATTRS_ANNOTATION_H_
26 
27 #include <tvm/ir/attrs.h>
28 
29 #include <string>
30 
31 namespace tvm {
32 namespace relay {
33 
74 struct OnDeviceAttrs : public tvm::AttrsNode<OnDeviceAttrs> {
75  // TODO(mbs): Replace device types with TargetDevice.
84  bool is_fixed = false;
85 
86  TVM_DECLARE_ATTRS(OnDeviceAttrs, "relay.attrs.OnDeviceAttrs") {
87  TVM_ATTR_FIELD(device_type)
88  .describe("The type of the virtual device which should hold the expression result.")
89  .set_default(0);
90  TVM_ATTR_FIELD(is_fixed)
91  .describe("If true, do not insert a \"device_copy\" call to respect this annotation.")
92  .set_default(false);
93  }
94 };
95 
99 struct CastHintAttrs : public tvm::AttrsNode<CastHintAttrs> {
101 
102  TVM_DECLARE_ATTRS(CastHintAttrs, "relay.attrs.CastHintAttrs") {
103  TVM_ATTR_FIELD(dtype).describe("The data type denoted to be cast.");
104  }
105 };
106 
110 struct CompilerAttrs : public tvm::AttrsNode<CompilerAttrs> {
112  std::string compiler;
113 
114  TVM_DECLARE_ATTRS(CompilerAttrs, "relay.attrs.CompilerAttrs") {
115  TVM_ATTR_FIELD(compiler).describe("A 3rd party compiler used for code generation.");
116  }
117 };
118 
122 struct TIRCallAttrs : public tvm::AttrsNode<TIRCallAttrs> {
125 
126  TVM_DECLARE_ATTRS(TIRCallAttrs, "relay.attrs.TIRCallAttrs") {
127  TVM_ATTR_FIELD(metadata).describe("Metadata attached to the TIR function call.");
128  }
129 };
130 
131 } // namespace relay
132 } // namespace tvm
133 #endif // TVM_RELAY_ATTRS_ANNOTATION_H_
std::string compiler
A 3rd party compiler for code generation.
Definition: annotation.h:112
TVM_DECLARE_ATTRS(CompilerAttrs, "relay.attrs.CompilerAttrs")
Definition: annotation.h:114
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
Options for the operators used to annotate a compiler.
Definition: annotation.h:110
int device_type
Device type on which argument expression should be evaluated.
Definition: annotation.h:77
TVM_DECLARE_ATTRS(OnDeviceAttrs, "relay.attrs.OnDeviceAttrs")
Definition: annotation.h:86
TVM_DECLARE_ATTRS(CastHintAttrs, "relay.attrs.CastHintAttrs")
Definition: annotation.h:102
DataType dtype
Definition: annotation.h:100
Helpers for attribute objects.
Metadata for calls to TIR functions, useful for program analysis crossing Relay and TIR...
Definition: annotation.h:122
Map< String, ObjectRef > metadata
The metadata attached to the call node.
Definition: annotation.h:124
Runtime primitive data type.
Definition: data_type.h:41
#define TVM_ATTR_FIELD(FieldName)
Declare an attribute field.
Definition: attrs.h:76
Annotate an expression to be cast into specific data type.
Definition: annotation.h:99
Attributes for the "on_device" special operator.
Definition: annotation.h:74
bool is_fixed
If true, the result device must also be device_type and device planning should not insert any "device...
Definition: annotation.h:84
The base class of the all the Use "curiously recurring template pattern".
Definition: attrs.h:793
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics, which means map is mutable but copy will happen when array is referenced in more than two places.
Definition: map.h:1235
TVM_DECLARE_ATTRS(TIRCallAttrs, "relay.attrs.TIRCallAttrs")
Definition: annotation.h:126
constexpr DLDeviceType kInvalidDeviceType
Definition: ndarray.h:51