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/ir/expr.h>
23 #include <tvm/ir/module.h>
28 #include <tvm/node/reflection.h>
33 #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 
47  public:
49 
66 
68  v->Visit("mod", &mod);
69  v->Visit("target", &target);
70  v->Visit("space_generator", &space_generator);
71  v->Visit("search_strategy", &search_strategy);
72  v->Visit("task_name", &task_name);
73  v->Visit("num_threads", &num_threads);
74  v->Visit("rand_state", &rand_state);
75  // `logger` is not visited
76  }
80  void Initialize();
85  TuneContext Clone() const;
86 
87  static constexpr const char* _type_key = "meta_schedule.TuneContext";
89 };
90 
96  public:
110  Optional<SpaceGenerator> space_generator,
111  Optional<SearchStrategy> search_strategy, Optional<String> task_name,
112  int num_threads, TRandState rand_state, PackedFunc logger);
114 };
115 
116 } // namespace meta_schedule
117 } // namespace tvm
118 
119 #endif // TVM_META_SCHEDULE_TUNE_CONTEXT_H_
Runtime Array container types.
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
The auto tuning context.
Definition: tune_context.h:46
void VisitAttrs(tvm::AttrVisitor *v)
Definition: tune_context.h:67
static constexpr const char * _type_key
Definition: tune_context.h:87
TRandState rand_state
The random state.
Definition: tune_context.h:63
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
Optional< SearchStrategy > search_strategy
The search strategy.
Definition: tune_context.h:57
PackedFunc logger
The tuning task's logging function. t.
Definition: tune_context.h:65
Optional< Target > target
The target to be tuned for.
Definition: tune_context.h:53
Managed reference to TuneContextNode.
Definition: tune_context.h:95
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TuneContext, ObjectRef, TuneContextNode)
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, PackedFunc logger)
Constructor.
support::LinearCongruentialEngine::TRandState TRandState
Definition: tune_context.h:97
Base class of all object reference.
Definition: object.h:519
base class of all object containers.
Definition: object.h:171
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:141
int64_t TRandState
Definition: random_engine.h:46
Base expr nodes in TVM.
IRModule that holds the functions and type definitions.
Runtime Map container types.
tvm::PrimExpr mod(const tvm::PrimExpr &a, const tvm::PrimExpr &b)
Definition: broadcast.h:290
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A managed object in the TVM runtime.
Runtime Optional container types.
Type-erased function used across TVM API.
Random number generator. It provides a generic interface consistent with std::uniform_random_bit_gene...
Reflection and serialization of compiler IR/AST nodes.
Runtime String container types.
Compilation target object.