tvm
tune_context.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_TUNE_CONTEXT_H_
20 #define TVM_META_SCHEDULE_TUNE_CONTEXT_H_
21 
22 #include <tvm/ffi/container/array.h>
23 #include <tvm/ffi/container/map.h>
24 #include <tvm/ffi/function.h>
25 #include <tvm/ffi/optional.h>
26 #include <tvm/ffi/reflection/registry.h>
27 #include <tvm/ffi/string.h>
28 #include <tvm/ir/expr.h>
29 #include <tvm/ir/module.h>
34 #include <tvm/runtime/object.h>
36 #include <tvm/target/target.h>
37 
38 namespace tvm {
39 namespace meta_schedule {
40 
41 class TaskSchedulerNode;
42 class MeasureCallback;
43 class TuneContext;
44 
46 class TuneContextNode : public runtime::Object {
47  public:
49 
51  Optional<IRModule> mod;
53  Optional<Target> target;
55  Optional<SpaceGenerator> space_generator;
57  Optional<SearchStrategy> search_strategy;
59  Optional<String> task_name;
66 
67  static void RegisterReflection() {
68  namespace refl = tvm::ffi::reflection;
69  refl::ObjectDef<TuneContextNode>()
70  .def_ro("mod", &TuneContextNode::mod)
71  .def_ro("target", &TuneContextNode::target)
72  .def_ro("space_generator", &TuneContextNode::space_generator)
73  .def_ro("search_strategy", &TuneContextNode::search_strategy)
74  .def_ro("task_name", &TuneContextNode::task_name)
75  .def_ro("num_threads", &TuneContextNode::num_threads)
76  .def_ro("rand_state", &TuneContextNode::rand_state);
77  // `logger` is not registered
78  }
79 
83  void Initialize();
88  TuneContext Clone() const;
89 
90  static constexpr const char* _type_key = "meta_schedule.TuneContext";
92 };
93 
98 class TuneContext : public runtime::ObjectRef {
99  public:
112  TVM_DLL explicit TuneContext(Optional<IRModule> mod, Optional<Target> target,
113  Optional<SpaceGenerator> space_generator,
114  Optional<SearchStrategy> search_strategy, Optional<String> task_name,
115  int num_threads, TRandState rand_state, ffi::Function logger);
117 };
118 
119 } // namespace meta_schedule
120 } // namespace tvm
121 
122 #endif // TVM_META_SCHEDULE_TUNE_CONTEXT_H_
The auto tuning context.
Definition: tune_context.h:46
static constexpr const char * _type_key
Definition: tune_context.h:90
TRandState rand_state
The random state.
Definition: tune_context.h:63
static void RegisterReflection()
Definition: tune_context.h:67
Optional< IRModule > mod
The workload to be tuned.
Definition: tune_context.h:51
Optional< String > task_name
The name of the tuning task.
Definition: tune_context.h:59
TuneContext Clone() const
Clone the tune context.
Optional< SpaceGenerator > space_generator
The design space generator.
Definition: tune_context.h:55
void Initialize()
Initialize members that needs initialization with tune context.
TVM_DECLARE_FINAL_OBJECT_INFO(TuneContextNode, Object)
support::LinearCongruentialEngine::TRandState TRandState
Definition: tune_context.h:48
int num_threads
The number of threads to be used.
Definition: tune_context.h:61
ffi::Function logger
The tuning task's logging function. t.
Definition: tune_context.h:65
Optional< SearchStrategy > search_strategy
The search strategy.
Definition: tune_context.h:57
Optional< Target > target
The target to be tuned for.
Definition: tune_context.h:53
Managed reference to TuneContextNode.
Definition: tune_context.h:98
TuneContext(Optional< IRModule > mod, Optional< Target > target, Optional< SpaceGenerator > space_generator, Optional< SearchStrategy > search_strategy, Optional< String > task_name, int num_threads, TRandState rand_state, ffi::Function logger)
Constructor.
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TuneContext, ObjectRef, TuneContextNode)
support::LinearCongruentialEngine::TRandState TRandState
Definition: tune_context.h:100
int64_t TRandState
Definition: random_engine.h:46
Base expr nodes in TVM.
IRModule that holds the functions and type definitions.
Definition: repr_printer.h:91
tvm::relax::Function Function
Definition: transform.h:42
tvm::PrimExpr mod(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition: broadcast.h:306
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
A managed object in the TVM runtime.
Random number generator. It provides a generic interface consistent with std::uniform_random_bit_gene...
Compilation target object.