tvm
Classes | Typedefs | Enumerations | Functions | Variables
tvm::auto_scheduler Namespace Reference

Classes

class  TuningOptionsNode
 Tuning and measurement options. More...
 
class  TuningOptions
 Managed reference to TuningOptionsNode. More...
 
class  AccessAnalyzerNode
 Static analyzer for a ComputeDAG. More...
 
class  AccessAnalyzer
 Managed reference to AccessAnalyzerNode. More...
 
class  ComputeDAGNode
 The auto-scheduler's computational graph and related program analyses. More...
 
class  ComputeDAG
 Managed reference to ComputeDAGNode. More...
 
class  CostModelNode
 The base class for cost model. More...
 
class  CostModel
 Managed reference to CostModelNode. More...
 
class  RandomModelNode
 The cost model returning random value for all predictions. More...
 
class  RandomModel
 Managed reference to RandomModelNode. More...
 
class  PythonBasedModelNode
 A wrapper for cost model defined by python code This class will call functions defined in the python. More...
 
class  PythonBasedModel
 Managed reference to PythonBasedModelNode. More...
 
struct  StageAttributes
 Stage-level attributes. More...
 
class  StageNode
 A op stage in the compute declaration. Similar to te::Stage in include/tvm/te/schedule.h. More...
 
class  Stage
 Managed reference to StageNode. More...
 
class  AttachMapNode
 stores the compute_at relation between stages This stores a bi-directional mapping from stages and iter: More...
 
class  AttachMap
 Managed reference to AttachMapNode. More...
 
class  StateNode
 A state in the search process. It consists of the current loop structure and a list of transformation steps used to construct it. Each State corresponds to a specific schedule for its ComputeDAG. More...
 
class  State
 Managed reference to StateNode. More...
 
class  MeasureInputNode
 Store the input of a measurement. More...
 
class  MeasureInput
 Managed reference to MeasureInputNode. More...
 
class  BuildResultNode
 Store the result of a build. More...
 
class  BuildResult
 Managed reference to BuildResultNode. More...
 
class  MeasureResultNode
 Store the results of a measurement. More...
 
class  MeasureResult
 Managed reference to MeasureResultNode. More...
 
class  MeasureCallbackNode
 Bass class of measurement callbacks. More...
 
class  MeasureCallback
 Managed reference to MeasureCallbackNode. More...
 
class  PythonBasedMeasureCallbackNode
 A wrapper for measure callback defined by python code This class will call functions defined in the python. More...
 
class  PythonBasedMeasureCallback
 Managed reference to PythonBasedMeasureCallbackNode. More...
 
class  ProgramBuilderNode
 ProgramBuilder that builds the programs. More...
 
class  ProgramBuilder
 Managed reference to ProgramBuilderNode. More...
 
class  ProgramRunnerNode
 ProgramRunner that runs the built programs and measure the time cost. More...
 
class  ProgramRunner
 Managed reference to ProgramRunnerNode. More...
 
class  LocalBuilderNode
 LocalBuilder use local CPU cores to build programs in parallel. More...
 
class  LocalBuilder
 Managed reference to LocalBuilderNode. More...
 
class  LocalRunnerNode
 LocalRunner that uses local CPU/GPU to measure the time cost of programs. More...
 
class  LocalRunner
 Managed reference to LocalRunnerNode. More...
 
class  RPCRunnerNode
 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) More...
 
class  RPCRunner
 Managed reference to RPCRunnerNode. More...
 
class  ProgramMeasurerNode
 Measurer that measures the time costs of tvm programs This class combines ProgramBuilder and ProgramRunner, and provides a simpler API. More...
 
class  ProgramMeasurer
 Managed reference to ProgramMeasurerNode. More...
 
class  RecordToFileNode
 Callback for logging the input and results of measurements to file. More...
 
class  RecordToFile
 Managed reference to RecordToFileNode. More...
 
class  RecordReaderNode
 Log reader to load step logs from a file. More...
 
class  RecordReader
 Managed reference to RecordReaderNode. More...
 
class  SearchCallbackNode
 Callback function to be called by the search process. This interface allows to do extra initializations before schedule search or extra check during/after the schedule search. More...
 
class  SearchCallback
 Managed reference to SearchCallbackNode. More...
 
class  PreloadMeasuredStatesNode
 Preload measured states from a log file. This can resume the state of the search policy. More...
 
class  PreloadMeasuredStates
 Managed reference to PreloadMeasuredStatesNode. More...
 
struct  SearchPolicyKey
 Attribute keys of ops used for SearchPolicy. More...
 
class  SearchPolicyNode
 The base class of search policies. More...
 
class  SearchPolicy
 Managed reference to SearchPolicyNode. More...
 
class  HardwareParamsNode
 The parameters of target hardware used to guide the SearchPolicy. More...
 
class  HardwareParams
 Managed reference to HardwareParamsNode. More...
 
class  SearchTaskNode
 The computation information and hardware parameters for a specific schedule search task. More...
 
class  SearchTask
 Managed reference to SearchTaskNode. More...
 
class  IteratorNode
 An iterator of a for-loop Similar to tvm::IterVar in include/tvm/tir/expr.h More...
 
class  Iterator
 Managed reference to IteratorNode. More...
 
class  StepNode
 The base class of transformation steps. Each step has its corresponding tvm.te schedule primitives. More...
 
class  Step
 Managed reference to StepNode. More...
 
class  AnnotationStepNode
 Annotation step that corresponds to vectorize, parallel, unroll and thread binding. (i.e. te::Stage::vectorize, te::Stage::parallel, te::Stage::vectorize, te::Stage::bind) More...
 
class  AnnotationStep
 Managed reference to AnnotationStepNode. More...
 
class  FuseStepNode
 Fuse step that corresponds to te::Stage::fuse. More...
 
class  FuseStep
 Managed reference to FuseStepNode. More...
 
class  PragmaStepNode
 Pragma step that corresponds to te::Stage::pragma. More...
 
class  PragmaStep
 Managed reference to PragmaStepNode. More...
 
class  ReorderStepNode
 Reorder step that corresponds to te::Stage::reorder. More...
 
class  ReorderStep
 Managed reference to ReorderStepNode. More...
 
class  SplitStepNode
 Split step that corresponds to te::Stage::split with additional support of multiple-level of factors. More...
 
class  SplitStep
 Managed reference to SplitStepNode. More...
 
class  FollowSplitStepNode
 Similar to SplitStepNode, but uses split factors from another step (i.e. Follow another split step) More...
 
class  FollowSplitStep
 Managed reference to FollowSplitStepNode. More...
 
class  FollowFusedSplitStepNode
 Similar to FollowSplitStep, but uses split factors from multiple steps. More...
 
class  FollowFusedSplitStep
 Managed reference to FollowFusedSplitStepNode. More...
 
class  StorageAlignStepNode
 Storage align step that corresponds to te::Stage::storage_align. More...
 
class  StorageAlignStep
 Managed reference to StorageAlignStepNode. More...
 
class  ComputeAtStepNode
 Compute at step that corresponds to te::Stage::compute_at. More...
 
class  ComputeAtStep
 Managed reference to ComputeAtStepNode. More...
 
class  ComputeInlineStepNode
 Compute inline step that corresponds to te::Stage::compute_inline. More...
 
class  ComputeInlineStep
 Managed reference to ComputeInlineStepNode. More...
 
class  ComputeRootStepNode
 Compute root step that corresponds to te::Stage::compute_root. More...
 
class  ComputeRootStep
 Managed reference to ComputeRootStepNode. More...
 
class  CacheReadStepNode
 Cache read step that corresponds to te::Schedule::cache_read. More...
 
class  CacheReadStep
 Managed reference to CacheReadStepNode. More...
 
class  CacheWriteStepNode
 Cache write step that corresponds to te::Schedule::cache_write. More...
 
class  CacheWriteStep
 Managed reference to CacheWriteStepNode. More...
 
class  RfactorStepNode
 Reduction factor step that corresponds to te::Schedule::rfactor. More...
 
class  RfactorStep
 Managed reference to RfactorStepNode. More...
 

Typedefs

using StageKey = int
 Use stage_id to represent a stage. More...
 
using IterKey = std::pair< int, int >
 Use stage_id and iter_id to represent a iterator. More...
 
typedef Map< tvm::te::Stage, Array< tir::IterVar >, ObjectHash, ObjectEqualStageToAxesMap
 

Enumerations

enum class  LayoutRewriteOption : int { NoRewrite = 0 , InsertTransformStage = 1 , RewriteForPreTransformed = 2 }
 Options for applying layout rewrite. This is an optimization to rewrite the layout of input tensors according to the schedule we get. More...
 
enum class  StageKind : int { kPlaceholder = 0 , kCompute = 1 }
 The type of a stage. More...
 
enum class  ComputeAtKind : int { kRoot = 0 , kInlined = 1 , kIter = 2 }
 The type of compute location. More...
 
enum class  MeasureErrorNO : int {
  kNoError = 0 , kInstantiationError = 1 , kCompileHostError = 2 , kCompileDeviceError = 3 ,
  kRuntimeDeviceError = 4 , kWrongAnswerError = 5 , kBuildTimeoutError = 6 , kRunTimeoutError = 7 ,
  kUnknownError = 8
}
 The error code of one measurement. More...
 
enum class  IteratorKind : int { kSpatial = 0 , kReduction = 1 , kMixed = 2 , kSpecial = 3 }
 The type of an iterator. More...
 
enum class  IteratorAnnotation : int {
  kNone = 0 , kUnroll = 1 , kVectorize = 2 , kParallel = 3 ,
  kVThread = 4 , kBlockX = 5 , kThreadX = 6 , kBlockY = 7 ,
  kThreadY = 8 , kBlockZ = 9 , kThreadZ = 10 , kTensorize = 11
}
 The type of an iterator's annotation. More...
 

Functions

std::pair< te::Schedule, Array< te::Tensor > > AutoSchedule (SearchPolicy search_policy, TuningOptions tuning_options)
 Run schedule search for a given compute declaration. More...
 
Array< PrimExprGetShapeFromRewrittenLayout (String rewritten_layout, Array< String > axis_names)
 Get the orginal shape from a rewritten layout string. More...
 
void GetPerStoreFeature (const PrimFunc &func, int cache_line_size, int max_n_bufs, std::vector< float > *ret, bool log_scale=true)
 Get per-store features from a TIR PrimFunc. More...
 
void GetPerStoreFeatureName (int max_n_bufs, std::vector< std::string > *ret)
 
void GetPerStoreFeaturesFromStates (const Array< State > &states, const SearchTask &task, int skip_first_n_feature_extraction, int max_n_bufs, std::vector< std::vector< float >> *features)
 Get per-store feature from states of the same task. More...
 
void GetPerStoreFeaturesFromStates (const Array< State > &states, const std::vector< SearchTask > &tasks, int skip_first_n_feature_extraction, int max_n_bufs, std::vector< std::vector< float >> *features)
 Get per-store feature from states of different tasks. More...
 
void GetPerStoreFeaturesFromFile (const std::string &filename, int max_lines, int max_n_bufs, std::vector< std::vector< float >> *features, std::vector< float > *normalized_throughputs, std::vector< int > *task_ids)
 Get per-store features from a log file. More...
 
void GetPerStoreFeaturesFromMeasurePairs (const Array< MeasureInput > &inputs, const Array< MeasureResult > &results, int skip_first_n_feature_extraction, int max_n_bufs, std::vector< std::vector< float >> *features, std::vector< float > *normalized_throughputs, std::vector< int > *task_ids)
 Get per-store features from measurement input/result pairs. More...
 
void WriteMeasureRecords (std::ostream *os, const Array< MeasureInput > &inputs, const Array< MeasureResult > &results, const std::string log_version=AUTO_SCHEDULER_LOG_VERSION)
 Append measure records to an output stream. More...
 
void ReadMeasureRecord (const std::string &str, MeasureInputNode *inp, MeasureResultNode *res, std::string *log_version)
 Read one measure record from a string. More...
 
void UpdateStageToAxesMap (const te::Stage &stage, StageToAxesMap *stage_to_axes)
 Update the current stage IterVar information to StageToAxesMap. More...
 
Step StepReadFromRecord (dmlc::JSONReader *reader)
 Read a step record from JSONReader and create the corresponding step. More...
 
void StepApplyToState (const Step &step, State *state, const ComputeDAG &dag)
 Apply a general step to a State with runtime dynamic dispatching. More...
 
void StepApplyToSchedule (const Step &step, Array< te::Stage > *stages, StageToAxesMap *stage_to_axes, te::Schedule *schedule, const Array< Step > &transform_steps)
 Apply a general step to tvm.schedule with runtime dynamic dispatching. More...
 
String StepPrintAsPythonAPI (const Step &step, Array< te::Stage > *stages, StageToAxesMap *stage_to_axes, te::Schedule *schedule, const Array< Step > &transform_steps)
 Print a general step as equivalent python schedule API with runtime dynamic dispatching. More...
 

Variables

const std::string AUTO_SCHEDULER_LOG_VERSION = "v0.6"
 
const char * IteratorAnnotationString []
 

Typedef Documentation

◆ IterKey

using tvm::auto_scheduler::IterKey = typedef std::pair<int, int>

Use stage_id and iter_id to represent a iterator.

◆ StageKey

using tvm::auto_scheduler::StageKey = typedef int

Use stage_id to represent a stage.

◆ StageToAxesMap

Enumeration Type Documentation

◆ ComputeAtKind

The type of compute location.

Enumerator
kRoot 

Compute at root.

kInlined 

Compute inlined.

kIter 

Compute at some iterator.

◆ IteratorAnnotation

The type of an iterator's annotation.

Enumerator
kNone 

This iterator has no annotation.

kUnroll 

This iterator has been unrolled.

kVectorize 

This iterator has been vectorized.

kParallel 

This iterator has been paralleld.

kVThread 

This iterator has been bind to vthread.

kBlockX 

This iterator has been bind to blockIdx.x.

kThreadX 

This iterator has been bind to threadIdx.x.

kBlockY 

This iterator has been bind to blockIdx.y.

kThreadY 

This iterator has been bind to threadIdx.y.

kBlockZ 

This iterator has been bind to blockIdx.y.

kThreadZ 

This iterator has been bind to threadIdx.y.

kTensorize 

This iterator has been mapped with a tensorize intrinsic.

◆ IteratorKind

The type of an iterator.

Enumerator
kSpatial 

Spatial iterator.

kReduction 

Reduction iterator.

kMixed 

Fused spatial and reduction iterator.

kSpecial 

Special iterator. (e.g. virtual root iterator)

◆ LayoutRewriteOption

Options for applying layout rewrite. This is an optimization to rewrite the layout of input tensors according to the schedule we get.

Enumerator
NoRewrite 

Do not perform layout rewrite.

InsertTransformStage 

Insert layout transformation stages for input placeholders in the compute DAG.

RewriteForPreTransformed 

Do not insert layout transformation stages and assume the input placeholders are pre-transformed.

Note
The lowered function with this option does not accept the origial input shapes, so this option must be used along with AutoSchedulerLayoutRewrite pass in Relay.

◆ MeasureErrorNO

The error code of one measurement.

Enumerator
kNoError 

No error.

kInstantiationError 

Errors happen when apply transform steps from init state.

kCompileHostError 

Errors happen when compiling code on host. (when build module)

kCompileDeviceError 

Errors happen when compiling code on device. (when load module)

kRuntimeDeviceError 

Errors happen when run program on device.

kWrongAnswerError 

Answer is wrong when compared to a reference output.

kBuildTimeoutError 

Timeout during compilation.

kRunTimeoutError 

Timeout during run.

kUnknownError 

Unknown error.

◆ StageKind

enum tvm::auto_scheduler::StageKind : int
strong

The type of a stage.

Enumerator
kPlaceholder 

A placeholder stage.

kCompute 

A compute stage.

Function Documentation

◆ AutoSchedule()

std::pair<te::Schedule, Array<te::Tensor> > tvm::auto_scheduler::AutoSchedule ( SearchPolicy  search_policy,
TuningOptions  tuning_options 
)

Run schedule search for a given compute declaration.

Parameters
search_policyThe search policy.
tuning_optionsTuning and measurement options.
Returns
A te::schedule and an Array of te::Tensor to be used in tvm.lower or tvm.build.

◆ GetPerStoreFeature()

void tvm::auto_scheduler::GetPerStoreFeature ( const PrimFunc func,
int  cache_line_size,
int  max_n_bufs,
std::vector< float > *  ret,
bool  log_scale = true 
)

Get per-store features from a TIR PrimFunc.

Parameters
funcThe input lowered TIR PrimFunc
cache_line_sizeThe size of cache line in bytes
max_n_bufsThe maximum number of extracted buffers for one statement
retThe returned feature vector
log_scaleShould the outputs be scaled by log2(1+x).

◆ GetPerStoreFeatureName()

void tvm::auto_scheduler::GetPerStoreFeatureName ( int  max_n_bufs,
std::vector< std::string > *  ret 
)

◆ GetPerStoreFeaturesFromFile()

void tvm::auto_scheduler::GetPerStoreFeaturesFromFile ( const std::string &  filename,
int  max_lines,
int  max_n_bufs,
std::vector< std::vector< float >> *  features,
std::vector< float > *  normalized_throughputs,
std::vector< int > *  task_ids 
)

Get per-store features from a log file.

Parameters
filenameThe name of log file
max_linesOnly read the first n lines of the file
max_n_bufsThe maximum number of extracted buffers for one statement
featuresThe returned feature vector. The innermost vector contains the feature vectors for all BufferStoreNode statements
normalized_throughputsThe normalized throughputs for all states
task_idsThe task ids for all states

◆ GetPerStoreFeaturesFromMeasurePairs()

void tvm::auto_scheduler::GetPerStoreFeaturesFromMeasurePairs ( const Array< MeasureInput > &  inputs,
const Array< MeasureResult > &  results,
int  skip_first_n_feature_extraction,
int  max_n_bufs,
std::vector< std::vector< float >> *  features,
std::vector< float > *  normalized_throughputs,
std::vector< int > *  task_ids 
)

Get per-store features from measurement input/result pairs.

Parameters
inputsThe measurement inputs
resultsThe measurement results
skip_first_n_feature_extractionSkip feature extraction for the first n measurement pairs
max_n_bufsThe maximum number of extracted buffers for one statement
featuresThe returned feature vector. The innermost vector contains the feature vectors for all BufferStoreNode statements
normalized_throughputsThe normalized throughputs for all states
task_idsThe task ids for all states

◆ GetPerStoreFeaturesFromStates() [1/2]

void tvm::auto_scheduler::GetPerStoreFeaturesFromStates ( const Array< State > &  states,
const SearchTask task,
int  skip_first_n_feature_extraction,
int  max_n_bufs,
std::vector< std::vector< float >> *  features 
)

Get per-store feature from states of the same task.

Parameters
statesThe input states
taskThe same search task for all states
skip_first_n_feature_extractionSkip feature extraction for the first n states
max_n_bufsThe maximum number of extracted buffers for one statement
featuresThe returned feature vector. The innermost vector contains the feature vectors for all BufferStoreNode statements

◆ GetPerStoreFeaturesFromStates() [2/2]

void tvm::auto_scheduler::GetPerStoreFeaturesFromStates ( const Array< State > &  states,
const std::vector< SearchTask > &  tasks,
int  skip_first_n_feature_extraction,
int  max_n_bufs,
std::vector< std::vector< float >> *  features 
)

Get per-store feature from states of different tasks.

Parameters
statesThe input states
tasksThe search tasks corresponding to the input states
skip_first_n_feature_extractionSkip feature extraction for the first n states
max_n_bufsThe maximum number of extracted buffers for one statement
featuresThe returned feature vector. The innermost vector contains the feature vectors for all BufferStoreNode statements

◆ GetShapeFromRewrittenLayout()

Array<PrimExpr> tvm::auto_scheduler::GetShapeFromRewrittenLayout ( String  rewritten_layout,
Array< String axis_names 
)

Get the orginal shape from a rewritten layout string.

Parameters
rewritten_layoutThe layout after auto-scheduler's layout rewrite.
axis_namesSpecifiy the names of axes.
Returns
shape The original shape.

◆ ReadMeasureRecord()

void tvm::auto_scheduler::ReadMeasureRecord ( const std::string &  str,
MeasureInputNode inp,
MeasureResultNode res,
std::string *  log_version 
)

Read one measure record from a string.

Parameters
strThe record string to be parsed.
inpA pointer to a MeasureInputNode used to store the return value.
resA pointer to a MeasureResultNode used to store the return value.
log_versionA pointer to a string used to store the log version.

◆ StepApplyToSchedule()

void tvm::auto_scheduler::StepApplyToSchedule ( const Step step,
Array< te::Stage > *  stages,
StageToAxesMap stage_to_axes,
te::Schedule schedule,
const Array< Step > &  transform_steps 
)

Apply a general step to tvm.schedule with runtime dynamic dispatching.

Parameters
stepThe step to be applied to tvm.schedule.
stagesThe list of current stages
stage_to_axesA map that maps stage ot all its iterators.
scheduleA mutable point to the current schedule
transform_stepsAn array of all history transform steps.

◆ StepApplyToState()

void tvm::auto_scheduler::StepApplyToState ( const Step step,
State state,
const ComputeDAG dag 
)

Apply a general step to a State with runtime dynamic dispatching.

Parameters
stepThe step to be applied to State.
stateA mutable pointer to state, which will be updated.
dagThe original ComputeDAG of this state.

◆ StepPrintAsPythonAPI()

String tvm::auto_scheduler::StepPrintAsPythonAPI ( const Step step,
Array< te::Stage > *  stages,
StageToAxesMap stage_to_axes,
te::Schedule schedule,
const Array< Step > &  transform_steps 
)

Print a general step as equivalent python schedule API with runtime dynamic dispatching.

Parameters
stepThe step to be printed as python API.
stagesThe list of current stages
stage_to_axesA map that maps stage ot all its iterators.
scheduleA mutable point to the current schedule
transform_stepsAn array of all history transform steps.
Returns
Python schedule code.

◆ StepReadFromRecord()

Step tvm::auto_scheduler::StepReadFromRecord ( dmlc::JSONReader *  reader)

Read a step record from JSONReader and create the corresponding step.

Parameters
readerThe input JSONReader.

◆ UpdateStageToAxesMap()

void tvm::auto_scheduler::UpdateStageToAxesMap ( const te::Stage stage,
StageToAxesMap stage_to_axes 
)

Update the current stage IterVar information to StageToAxesMap.

Parameters
stageThe stage to be updated.
stage_to_axesThe map to be updated.

◆ WriteMeasureRecords()

void tvm::auto_scheduler::WriteMeasureRecords ( std::ostream *  os,
const Array< MeasureInput > &  inputs,
const Array< MeasureResult > &  results,
const std::string  log_version = AUTO_SCHEDULER_LOG_VERSION 
)

Append measure records to an output stream.

Parameters
osA pointer to a output stream.
inputsThe MeasureInputs to be written.
resultsThe MeasureResults to be written.
log_versionThe log version for the given record.

Variable Documentation

◆ AUTO_SCHEDULER_LOG_VERSION

const std::string tvm::auto_scheduler::AUTO_SCHEDULER_LOG_VERSION = "v0.6"

◆ IteratorAnnotationString

const char* tvm::auto_scheduler::IteratorAnnotationString[]
extern