tvm
|
An execution trace of a scheduling program. More...
#include <trace.h>
Public Member Functions | |
TVM_DECLARE_FINAL_OBJECT_INFO (TraceNode, runtime::Object) | |
Any | GetDecision (const Instruction &inst) const |
Retrieve the decision made on a specific instruction. More... | |
void | Append (Instruction inst) |
Append a new instruction to the trace. More... | |
void | Append (Instruction inst, Any decision) |
Append a new instruction with a random decision to the trace. More... | |
Optional< Instruction > | Pop () |
Remove the last instruction, along with the decision made on that instruction, if any. More... | |
void | ApplyToSchedule (Schedule sch, bool remove_postproc, FTraceDecisionProvider decision_provider=nullptr) const |
Apply the trace to a TensorIR schedule. More... | |
ObjectRef | AsJSON (bool remove_postproc) const |
Serialize the trace as a JSON-style object. More... | |
Array< String > | AsPython (bool remove_postproc) const |
Serialize the trace as a sequence of python statements. More... | |
Trace | WithDecision (Instruction inst, Any decision, bool remove_postproc) const |
Create a new trace with an instruction whose decision is changed, assuming this instruction exists in the resulting trace. More... | |
Trace | Simplified (bool remove_postproc) const |
Simplify the trace with dead-code elimination. More... | |
Static Public Member Functions | |
static void | RegisterReflection () |
Public Attributes | |
Array< Instruction > | insts |
The instructions invoked so far in the program execution. More... | |
Map< Instruction, Any > | decisions |
The random decisions made upon those instructions. More... | |
Static Public Attributes | |
static constexpr const char * | _type_key = "tir.Trace" |
An execution trace of a scheduling program.
A trace has two parts: 1) The instructions invoked so far in the program execution 2) The random decisions made upon those instructions, if any
A trace can be serialized to: 1) Roundtrippable JSON format: can be saved to file and loaded back 2) Python syntax: allows users to copy-paste the trace to reproduce the scheduling process
A trace can be applied to a TensorIR schedule by re-applying all its instructions possibly with their decisions accordingly. Re-sampling is invoked if a sampling instruction doesn't have its corresponding decision; Otherwise the existing decision will be reused accordingly.
void tvm::tir::TraceNode::Append | ( | Instruction | inst | ) |
Append a new instruction to the trace.
inst | The new instruction to be appended |
void tvm::tir::TraceNode::Append | ( | Instruction | inst, |
Any | decision | ||
) |
Append a new instruction with a random decision to the trace.
inst | The new instruction to be appended |
decision | The random decision made on this instruction The type of decision depends on the instruction, e.g. the decision of SamplePerfectTile has type Array<IntImm> |
void tvm::tir::TraceNode::ApplyToSchedule | ( | Schedule | sch, |
bool | remove_postproc, | ||
FTraceDecisionProvider | decision_provider = nullptr |
||
) | const |
Apply the trace to a TensorIR schedule.
sch | The schedule to be applied onto |
remove_postproc | If postprocessing instructions are removed |
decision_provider | A callback that allows users to mutate decisions on the fly when applying instructions. |
ObjectRef tvm::tir::TraceNode::AsJSON | ( | bool | remove_postproc | ) | const |
Serialize the trace as a JSON-style object.
remove_postproc | If postprocessing instructions are removed |
Array<String> tvm::tir::TraceNode::AsPython | ( | bool | remove_postproc | ) | const |
Serialize the trace as a sequence of python statements.
remove_postproc | If postprocessing instructions are removed |
Any tvm::tir::TraceNode::GetDecision | ( | const Instruction & | inst | ) | const |
Retrieve the decision made on a specific instruction.
inst | The instruction whose decision is to be retrieved |
Optional<Instruction> tvm::tir::TraceNode::Pop | ( | ) |
Remove the last instruction, along with the decision made on that instruction, if any.
|
inlinestatic |
Trace tvm::tir::TraceNode::Simplified | ( | bool | remove_postproc | ) | const |
Simplify the trace with dead-code elimination.
remove_postproc | If postprocessing instructions are removed |
tvm::tir::TraceNode::TVM_DECLARE_FINAL_OBJECT_INFO | ( | TraceNode | , |
runtime::Object | |||
) |
Trace tvm::tir::TraceNode::WithDecision | ( | Instruction | inst, |
Any | decision, | ||
bool | remove_postproc | ||
) | const |
Create a new trace with an instruction whose decision is changed, assuming this instruction exists in the resulting trace.
inst | The instruction whose decision is to be changed |
decision | The decision to be changed to |
remove_postproc | If postprocessing instructions are removed |
|
staticconstexpr |
Map<Instruction, Any> tvm::tir::TraceNode::decisions |
The random decisions made upon those instructions.
Array<Instruction> tvm::tir::TraceNode::insts |
The instructions invoked so far in the program execution.