tvm
integration.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 #ifndef TVM_META_SCHEDULE_INTEGRATION_H_
20 #define TVM_META_SCHEDULE_INTEGRATION_H_
21 
23 #include <tvm/support/with.h>
24 
25 #include <unordered_set>
26 
27 namespace tvm {
28 namespace meta_schedule {
29 
30 /**************** ExtractedTask ****************/
31 
36  public:
43 
45  v->Visit("task_name", &task_name);
46  v->Visit("mod", &mod);
47  v->Visit("dispatched", &dispatched);
48  }
49 
50  static constexpr const char* _type_key = "meta_schedule.ExtractedTask";
52 };
53 
59  public:
67 };
68 
69 /**************** MetaScheduleContext ****************/
70 
75  public:
77  virtual ~MetaScheduleContextNode() = default;
92 
93  static constexpr const char* _type_key = "meta_schedule.MetaScheduleContext";
95 };
96 
102  friend class MetaScheduleContextInternal;
103  friend class With<MetaScheduleContext>;
104 
105  public:
107  virtual ~MetaScheduleContext() = default;
113  static Optional<MetaScheduleContext> Current();
126  static Optional<ObjectRef> QueryInsideWithScope(runtime::String task_name, IRModule mod,
128 
131 
132  protected:
134  MetaScheduleContext() = default;
136  void EnterWithScope();
138  void ExitWithScope();
139 };
140 
141 /**************** TaskExtraction ****************/
142 
147  public:
149  Array<ExtractedTask> tasks{nullptr};
150 
151  void VisitAttrs(AttrVisitor* v) { v->Visit("tasks", &tasks); }
152 
153  // Inherited from base class
156 
157  static constexpr const char* _type_key = "meta_schedule.TaskExtraction";
159 };
160 
166  public:
168  TaskExtraction();
171 };
172 
173 /**************** ApplyHistoryBest ****************/
174 
180  public:
182  Database database{nullptr};
183 
185  v->Visit("database", &database); //
186  }
187 
188  // Inherited from base class
191 
192  static constexpr const char* _type_key = "meta_schedule.ApplyHistoryBest";
194 };
195 
201  public:
206  explicit ApplyHistoryBest(Database database);
209 };
210 
211 } // namespace meta_schedule
212 } // namespace tvm
213 
214 #endif // TVM_META_SCHEDULE_INTEGRATION_H_
#define TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:751
Managed reference to TaskExtractionNode.
Definition: integration.h:165
An integration context for task extraction.
Definition: integration.h:146
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
void VisitAttrs(AttrVisitor *v)
Definition: integration.h:151
Managed reference to ApplyHistoryBestNode.
Definition: integration.h:200
String task_name
The name of the task extracted.
Definition: integration.h:38
base class of all object containers.
Definition: object.h:165
Managed reference to ExtractedTaskNode.
Definition: integration.h:58
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
A tuning task extracted from the high-level IR.
Definition: integration.h:35
static constexpr const char * _type_key
Definition: integration.h:50
Managed reference to DatabaseNode.
Definition: database.h:262
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:270
Reference to string objects.
Definition: string.h:129
void VisitAttrs(AttrVisitor *v)
Definition: integration.h:44
RAII wrapper function to enter and exit a context object similar to python&#39;s with syntax...
Definition: with.h:57
IRModule mod
The high-level IR.
Definition: integration.h:40
Base class of all object reference.
Definition: object.h:504
Array< IRModule > dispatched
A list of low-level IRs that the high-level IR could potentially dispatch to.
Definition: integration.h:42
Managed reference class to IRModuleNode.
Definition: module.h:352
An integration context that allows application of historically best records from a database...
Definition: integration.h:179
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
void VisitAttrs(AttrVisitor *v)
Definition: integration.h:184
TVM_DECLARE_FINAL_OBJECT_INFO(ExtractedTaskNode, runtime::Object)
#define TVM_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType)
helper macro to declare a base object type that can be inherited.
Definition: object.h:641
#define TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:721
A context manager interface for the integration.
Definition: integration.h:74
Managed reference to MetaScheduleContextNode.
Definition: integration.h:101
RAII wrapper function to enter and exit a context object similar to python&#39;s with syntax...