38 #ifndef TVM_AUTO_SCHEDULER_MEASURE_H_ 39 #define TVM_AUTO_SCHEDULER_MEASURE_H_ 45 #include <unordered_map> 46 #include <unordered_set> 50 namespace auto_scheduler {
89 v->Visit(
"task", &task);
90 v->Visit(
"state", &state);
96 static constexpr
const char* _type_key =
"auto_scheduler.MeasureInput";
131 v->Visit(
"filename", &filename);
132 v->Visit(
"args", &args);
133 v->Visit(
"error_no", &error_no);
134 v->Visit(
"error_msg", &error_msg);
135 v->Visit(
"time_cost", &time_cost);
138 static constexpr
const char* _type_key =
"auto_scheduler.BuildResult";
176 v->Visit(
"costs", &costs);
177 v->Visit(
"error_no", &error_no);
178 v->Visit(
"error_msg", &error_msg);
179 v->Visit(
"all_cost", &all_cost);
180 v->Visit(
"timestamp", ×tamp);
186 static constexpr
const char* _type_key =
"auto_scheduler.MeasureResult";
222 static constexpr
const char* _type_key =
"auto_scheduler.MeasureCallback";
244 static constexpr
const char* _type_key =
"auto_scheduler.PythonBasedMeasureCallback";
283 static constexpr
const char* _type_key =
"auto_scheduler.ProgramBuilder";
325 static constexpr
const char* _type_key =
"auto_scheduler.ProgramRunner";
348 static constexpr
const char* _type_key =
"auto_scheduler.LocalBuilder";
376 static constexpr
const char* _type_key =
"auto_scheduler.LocalRunner";
398 LocalRunner(
int timeout,
int number,
int repeat,
int min_repeat_ms,
double cooldown_interval,
399 bool enable_cpu_cache_flush,
int device);
425 static constexpr
const char* _type_key =
"auto_scheduler.RPCRunner";
452 int timeout,
int number,
int repeat,
int min_repeat_ms,
double cooldown_interval,
453 bool enable_cpu_cache_flush,
int device);
510 static const int DEFAULT_MAX_CONTINUOUS_ERROR = 150;
512 static constexpr
const char* _type_key =
"auto_scheduler.ProgramMeasurer";
534 int max_continuous_error = -1);
542 #endif // TVM_AUTO_SCHEDULER_MEASURE_H_ Measurer that measures the time costs of tvm programs This class combines ProgramBuilder and ProgramR...
Definition: measure.h:461
std::unordered_map< std::string, int > best_ct
Workload key to best state's count index map.
Definition: measure.h:472
int error_ct
Continuous error counter.
Definition: measure.h:466
String filename
The filename of built binary file.
Definition: measure.h:120
int timeout
Timeout of a run.
Definition: measure.h:300
int repeat
The number of times to repeat the measurement.
Definition: measure.h:304
double cooldown_interval
The cool down interval between two measurements.
Definition: measure.h:308
Managed reference to BuildResultNode.
Definition: measure.h:146
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
int n_parallel
The number of build processes to run in parallel.
Definition: measure.h:270
Store the result of a build.
Definition: measure.h:117
int ct
Measured programs counter.
Definition: measure.h:464
Managed reference to StateNode.
Definition: loop_state.h:272
ProgramBuilder that builds the programs.
Definition: measure.h:267
A wrapper for measure callback defined by python code This class will call functions defined in the p...
Definition: measure.h:237
String error_msg
The error message if there is any error.
Definition: measure.h:169
std::unordered_map< std::string, double > best_flops
Workload key to best flops map.
Definition: measure.h:468
Array< PrimExpr > costs
The time costs of execution.
Definition: measure.h:165
Optional< Array< MeasureCallback > > callbacks
MeasureCallback to be called after each measure batch.
Definition: measure.h:480
base class of all object containers.
Definition: object.h:167
Managed reference to PythonBasedMeasureCallbackNode.
Definition: measure.h:252
Answer is wrong when compared to a reference output.
#define TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:744
void VisitAttrs(tvm::AttrVisitor *v)
Definition: measure.h:130
Errors happen when apply transform steps from init state.
Managed reference to ProgramRunnerNode.
Definition: measure.h:333
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
ProgramRunner runner
The ProgramRunner to measure each program.
Definition: measure.h:478
PackedFunc callback_func
Pointer to the callback function in python.
Definition: measure.h:240
String host
The host address of the RPC Tracker.
Definition: measure.h:414
int n_parallel
The number of tasks run in parallel.
Definition: measure.h:420
int min_repeat_ms
The minimum duration of one repeat in milliseconds.
Definition: measure.h:306
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
double all_cost
The time cost of build and run.
Definition: measure.h:171
RPCRunner that uses RPC call to measures the time cost of programs on remote devices. Or sometime we may need to use RPC even in local running to insulate the thread environment. (e.g. running CUDA programs)
Definition: measure.h:409
Errors happen when run program on device.
The definition of the "state" in the search.
LocalRunner that uses local CPU/GPU to measure the time cost of programs.
Definition: measure.h:371
int error_no
The error code. (0 means no error, see MeasureErrorNO)
Definition: measure.h:124
Reference to string objects.
Definition: string.h:98
Managed reference to RPCRunnerNode.
Definition: measure.h:433
int device
Which device to run on if multiple are avaialble.
Definition: measure.h:312
#define TVM_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:713
Managed reference to MeasureCallbackNode.
Definition: measure.h:230
std::unordered_map< std::string, State > best_state
Workload key to best state map.
Definition: measure.h:470
Array< te::Tensor > args
The arguments.
Definition: measure.h:122
Managed reference to SearchPolicyNode.
Definition: search_policy.h:198
String build_func
Build function.
Definition: measure.h:344
int priority
The priority of this run request, larger is more prior.
Definition: measure.h:418
Base class of all object reference.
Definition: object.h:511
int number
The number of times to run the generated code for taking average.
Definition: measure.h:302
double timestamp
The time stamps of this measurement.
Definition: measure.h:173
Errors happen when compiling code on host. (when build module)
std::unordered_set< std::string > has_valid
The set of workloads that have at least one valid schedule.
Definition: measure.h:474
Timeout during compilation.
int verbose
Verbosity level. 0 for silent, 1 to output information during program measuring.
Definition: measure.h:482
#define TVM_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:671
Managed reference to ProgramBuilderNode.
Definition: measure.h:291
int timeout
Timeout of a build.
Definition: measure.h:272
Store the results of a measurement.
Definition: measure.h:162
Managed reference to ProgramMeasurerNode.
Definition: measure.h:520
String error_msg
The error message if there is any error.
Definition: measure.h:126
runtime::Module Build(IRModule mod, Target target)
Build a module from array of lowered function.
Managed reference to LocalRunnerNode.
Definition: measure.h:384
bool enable_cpu_cache_flush
Whether to flush cache on CPU between repeated measurements.
Definition: measure.h:310
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:138
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Managed reference to MeasureResultNode.
Definition: measure.h:194
Managed reference to LocalBuilderNode.
Definition: measure.h:356
Errors happen when compiling code on device. (when load module)
ProgramRunner that runs the built programs and measure the time cost.
Definition: measure.h:297
int port
The port of the RPC Tracker.
Definition: measure.h:416
LocalBuilder use local CPU cores to build programs in parallel.
Definition: measure.h:341
Bass class of measurement callbacks.
Definition: measure.h:211
Managed reference to SearchTaskNode.
Definition: search_task.h:148
Tensor repeat(const Tensor &x, int repeats, int axis, std::string name="T_repeat", std::string tag=kBroadcast)
Creates an operation to repeat elements of an array.
Definition: transform.h:1174
void VisitAttrs(tvm::AttrVisitor *v)
Definition: measure.h:175
Meta information and hardware parameters for a search task.
String key
The key of the device registered in the RPC tracker.
Definition: measure.h:412
int error_no
The error code. (0 means no error, see MeasureErrorNO)
Definition: measure.h:167
double time_cost
The time cost of build.
Definition: measure.h:128
#define TVM_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType)
helper macro to declare a base object type that can be inherited.
Definition: object.h:648
int max_continuous_error
The number of allowed maximum continuous error before forcely stopping the tuning.
Definition: measure.h:484
MeasureErrorNO
The error code of one measurement.
Definition: measure.h:57
ProgramBuilder builder
The ProgramBuilder to build each program.
Definition: measure.h:476