tvm
Loading...
Searching...
No Matches
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_S_TIR_META_SCHEDULE_TUNE_CONTEXT_H_
20#define TVM_S_TIR_META_SCHEDULE_TUNE_CONTEXT_H_
21
22#include <tvm/base.h>
23#include <tvm/ffi/container/array.h>
24#include <tvm/ffi/container/map.h>
25#include <tvm/ffi/function.h>
26#include <tvm/ffi/optional.h>
27#include <tvm/ffi/reflection/registry.h>
28#include <tvm/ffi/string.h>
29#include <tvm/ir/expr.h>
30#include <tvm/ir/module.h>
31#include <tvm/ir/prim/expr.h>
37#include <tvm/target/target.h>
38
39namespace tvm {
40namespace s_tir {
41namespace meta_schedule {
42
43class TaskSchedulerObj;
44class MeasureCallback;
45class TuneContext;
46
48class TuneContextObj : public ffi::Object {
49 public:
51
53 ffi::Optional<IRModule> mod;
55 ffi::Optional<Target> target;
57 ffi::Optional<SpaceGenerator> space_generator;
59 ffi::Optional<SearchStrategy> search_strategy;
61 ffi::Optional<ffi::String> task_name;
67 ffi::Function logger;
68
69 static void RegisterReflection() {
70 namespace refl = tvm::ffi::reflection;
71 refl::ObjectDef<TuneContextObj>()
72 .def_ro("mod", &TuneContextObj::mod)
73 .def_ro("target", &TuneContextObj::target)
74 .def_ro("space_generator", &TuneContextObj::space_generator)
75 .def_ro("search_strategy", &TuneContextObj::search_strategy)
76 .def_ro("task_name", &TuneContextObj::task_name)
77 .def_ro("num_threads", &TuneContextObj::num_threads)
78 .def_ro("rand_state", &TuneContextObj::rand_state);
79 // `logger` is not registered
80 }
81
85 void Initialize();
91
92 static constexpr const bool _type_mutable = true;
93 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.TuneContext", TuneContextObj, ffi::Object);
94};
95
100class TuneContext : public ffi::ObjectRef {
101 public:
107 explicit TuneContext(ffi::ObjectPtr<TuneContextObj> data) : ffi::ObjectRef(data) {
108 TVM_FFI_ICHECK(data != nullptr);
109 }
121 TVM_DLL explicit TuneContext(ffi::Optional<IRModule> mod, ffi::Optional<Target> target,
122 ffi::Optional<SpaceGenerator> space_generator,
123 ffi::Optional<SearchStrategy> search_strategy,
124 ffi::Optional<ffi::String> task_name, int num_threads,
125 TRandState rand_state, ffi::Function logger);
127};
128
129} // namespace meta_schedule
130} // namespace s_tir
131} // namespace tvm
132
133#endif // TVM_S_TIR_META_SCHEDULE_TUNE_CONTEXT_H_
Base expr nodes in TVM.
TIR expressions.
int64_t TRandState
Definition random_engine.h:47
The auto tuning context.
Definition tune_context.h:48
void Initialize()
Initialize members that needs initialization with tune context.
int num_threads
The number of threads to be used.
Definition tune_context.h:63
ffi::Optional< SearchStrategy > search_strategy
The search strategy.
Definition tune_context.h:59
TRandState rand_state
The random state.
Definition tune_context.h:65
ffi::Optional< SpaceGenerator > space_generator
The design space generator.
Definition tune_context.h:57
ffi::Optional< ffi::String > task_name
The name of the tuning task.
Definition tune_context.h:61
TuneContext Clone() const
Clone the tune context.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("s_tir.meta_schedule.TuneContext", TuneContextObj, ffi::Object)
LinearCongruentialEngine::TRandState TRandState
Definition tune_context.h:50
ffi::Function logger
The tuning task's logging function. t.
Definition tune_context.h:67
static constexpr const bool _type_mutable
Definition tune_context.h:92
ffi::Optional< IRModule > mod
The workload to be tuned.
Definition tune_context.h:53
ffi::Optional< Target > target
The target to be tuned for.
Definition tune_context.h:55
static void RegisterReflection()
Definition tune_context.h:69
Managed reference to TuneContextObj.
Definition tune_context.h:100
LinearCongruentialEngine::TRandState TRandState
Definition tune_context.h:102
TuneContext(ffi::Optional< IRModule > mod, ffi::Optional< Target > target, ffi::Optional< SpaceGenerator > space_generator, ffi::Optional< SearchStrategy > search_strategy, ffi::Optional< ffi::String > task_name, int num_threads, TRandState rand_state, ffi::Function logger)
Constructor.
TuneContext(ffi::ObjectPtr< TuneContextObj > data)
Constructor from ffi::ObjectPtr<TuneContextObj>.
Definition tune_context.h:107
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TuneContext, ffi::ObjectRef, TuneContextObj)
Parent compiler symbol visibility.
IRModule that holds the functions and type definitions.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Random number generator. It provides a generic interface consistent with std::uniform_random_bit_gene...
Compilation target object.