tvm
auto_schedule.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 
25 #ifndef TVM_AUTO_SCHEDULER_AUTO_SCHEDULE_H_
26 #define TVM_AUTO_SCHEDULER_AUTO_SCHEDULE_H_
27 
30 
31 #include <utility>
32 
33 namespace tvm {
34 namespace auto_scheduler {
35 
37 class TuningOptionsNode : public Object {
38  public:
46  int verbose;
53 
55  v->Visit("num_measure_trials", &num_measure_trials);
56  v->Visit("early_stopping", &early_stopping);
57  v->Visit("num_measures_per_round", &num_measures_per_round);
58  v->Visit("verbose", &verbose);
59  v->Visit("builder", &builder);
60  v->Visit("runner", &runner);
61  v->Visit("measure_callbacks", &measure_callbacks);
62  }
63 
64  static constexpr const char* _type_key = "auto_scheduler.TuningOptions";
66 };
67 
72 class TuningOptions : public ObjectRef {
73  public:
85  TuningOptions(int num_measure_trials, int early_stopping, int num_measures_per_round, int verbose,
86  ProgramBuilder builder, ProgramRunner runner,
87  Optional<Array<MeasureCallback>> measure_callbacks);
88 
90 };
91 
99 TVM_DLL std::pair<te::Schedule, Array<te::Tensor>> AutoSchedule(SearchPolicy search_policy,
100  TuningOptions tuning_options);
101 } // namespace auto_scheduler
102 } // namespace tvm
103 
104 #endif // TVM_AUTO_SCHEDULER_AUTO_SCHEDULE_H_
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
Managed reference to ProgramBuilderNode.
Definition: measure.h:291
Managed reference to ProgramRunnerNode.
Definition: measure.h:333
Managed reference to SearchPolicyNode.
Definition: search_policy.h:198
Tuning and measurement options.
Definition: auto_schedule.h:37
ProgramRunner runner
ProgramRunner which runs the program and measures time costs.
Definition: auto_schedule.h:50
Optional< Array< MeasureCallback > > measure_callbacks
MeasureCallback functions to be called after each measure batch.
Definition: auto_schedule.h:52
int early_stopping
Stops the tuning early if no improvement after n measurements.
Definition: auto_schedule.h:42
ProgramBuilder builder
ProgramBuilder which builds the program.
Definition: auto_schedule.h:48
void VisitAttrs(tvm::AttrVisitor *v)
Definition: auto_schedule.h:54
TVM_DECLARE_FINAL_OBJECT_INFO(TuningOptionsNode, Object)
int verbose
Verbosity level. 0 for silent, 1 to output information during schedule searching.
Definition: auto_schedule.h:46
int num_measures_per_round
The number of programs to be measured at each search round.
Definition: auto_schedule.h:44
static constexpr const char * _type_key
Definition: auto_schedule.h:64
int num_measure_trials
The number of total measurement trials.
Definition: auto_schedule.h:40
Managed reference to TuningOptionsNode.
Definition: auto_schedule.h:72
TVM_DEFINE_OBJECT_REF_METHODS(TuningOptions, ObjectRef, TuningOptionsNode)
TuningOptions(int num_measure_trials, int early_stopping, int num_measures_per_round, int verbose, ProgramBuilder builder, ProgramRunner runner, Optional< Array< MeasureCallback >> measure_callbacks)
The constructor.
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
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
Distributed measurement infrastructure to measure the runtime costs of tensor programs....
std::pair< te::Schedule, Array< te::Tensor > > AutoSchedule(SearchPolicy search_policy, TuningOptions tuning_options)
Run schedule search for a given compute declaration.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
The base class of search policies, including the abstract definition of search policy and other suppo...