Result

Tuning result of AutoTVM dialect.

class lorien.dialect.tvm_dial.autotvm_dial.result.AutoTVMRecords(target_key: str, workload_key: Optional[str] = None, group_by_layout: bool = False)

The container to maintain the records of a tuning task by data layout.

static decode(record_str: str) Tuple[tvm.autotvm.measure.measure.MeasureInput, tvm.autotvm.measure.measure.MeasureResult]

Decode a string to a record.

static encode(record: Tuple[tvm.autotvm.measure.measure.MeasureInput, tvm.autotvm.measure.measure.MeasureResult]) str

Encode a record to a string.

static gen_record_item(record: Tuple[tvm.autotvm.measure.measure.MeasureInput, tvm.autotvm.measure.measure.MeasureResult])

Generate an item for a record that can be appended to the task item.

gen_task_item() Dict[str, Any]

Generate an item that can be committed to the database. Note that since all records in this container should be for the same task, they should be in the same task item.

peak() Tuple[tvm.autotvm.measure.measure.MeasureInput, tvm.autotvm.measure.measure.MeasureResult]

Peak the first record (of any layout).

pop() Tuple[tvm.autotvm.measure.measure.MeasureInput, tvm.autotvm.measure.measure.MeasureResult]

Pop the worst record in the container. We do not need this API for AutoTVM.

push(record: Tuple[tvm.autotvm.measure.measure.MeasureInput, tvm.autotvm.measure.measure.MeasureResult])

Push a new record to the bucket based on its layout.

Parameters

record (Tuple[MeasureInput, MeasureResult]) -- The record to be pushed.

to_list(nbest: int = - 1) List[Tuple[tvm.autotvm.measure.measure.MeasureInput, tvm.autotvm.measure.measure.MeasureResult]]

Sort the record (of any layout) to be a list and return the best N.

Parameters

nbest (int) -- The best N records to be returned. Default to return all.

Returns

records -- The sorted list of records.

Return type

List[Tuple[MeasureInput, MeasureResult]]

class lorien.dialect.tvm_dial.autotvm_dial.result.AutoTVMTuneResult

The result of a tuning job.

static create_records_by_workloads(log_file_path: str, nbest: int, workload: Optional[lorien.workload.Workload] = None) Sequence[lorien.dialect.tvm_dial.result.TVMRecords]

Parse records from the tuning log and group them by workloads.

Parameters
  • log_file_path (str) -- The log file path.

  • nbest (int) -- The maximum number of best records to be kept.

  • workload (Optional[Workload]) -- The target workload. If presented, the returnede map will only have one entry.

Returns

records -- A list of created records.

Return type

Sequence[AutoTVMRecords]

static extract_feature(inp)

Extract features from a measure input.

Parameters

inp (MeasureInput) -- AutoTVM measure input.

Returns

features -- A map from feature name to value.

Return type

Dict[str, Any]

static extract_feature_from_file(log_file_path: str, out_path: str)

Featurize tuning results in a log file and write to a file.

Parameters
  • log_file_path (str) -- The log file path.

  • out_path (str) -- The path to write generated features.

static gen_features(log_file_path: str, out_path: str)

Featurize tuning logs to be input features of the performance cost model. The process includes two phases. The first phase aggregates the tuning logs by AutoTVM templates (e.g., conv2d_nchw, conv2d_winograd, etc) and extracts features from the workload (e.g., shapes, attribtues, schedule configurations). The output of phase 1 is few JSON files. Since the number of AutoTVM templates is not many, phase 1 usually only outputs ~10 files. Then, phase 2 reads the JSON file one-by-one and does 3 tasks: 1) normalize numeric features, 2) enumerate string features, 3) output processed features to .csv files along with the metadata (e.g., mean and std of numeric features and the mapping of string features). Although writing the phase 1 output to files may slow down the process due to disk I/O, it avoids out-of-memory issue when processing a large number of tuning logs.

Parameters
  • log_file_path (str) -- The log file path. It can be a file path for a single file, or a directory of several log files.

  • out_path (str) -- The path to write generated features and artifacts.