Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/tvm/auto_scheduler/compute_dag.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class AccessAnalyzerNode : public Object {
using OperationMap = std::unordered_map<te::Operation, T, ObjectPtrHash, ObjectPtrEqual>;

/*! \brief Map an operation to all operations it reads from.
* For each operation pair, use a two-dimentional array for multiple multi-dimentional accesses
* For each operation pair, use a two-dimensional array for multiple multi-dimensional accesses
* The inner vector represents the indices of multi-dimensional access.*/
OperationMap<OperationMap<std::vector<std::vector<PrimExpr>>>> read_from;
/*! \brief Map an operation to all operations it is read by.
* For each operation pair, use a two-dimentional array for multiple multi-dimentional accesses
* For each operation pair, use a two-dimensional array for multiple multi-dimensional accesses
* The inner vector represents the indices of multi-dimensional access.*/
OperationMap<OperationMap<std::vector<std::vector<PrimExpr>>>> read_by;
/*! \brief Store the number of common outer iterators for operation pairs that have
Expand All @@ -67,7 +67,7 @@ class AccessAnalyzerNode : public Object {
* (e.g., injective, broadcast and elementwise ops without reduction) */
OperationMap<bool> is_simple_access;
/*! \brief Store whether the operation is strictly inlineable
* (e.g., injective, broadcast and elementwise without reduction, branch or expenive operations)
* (e.g., injective, broadcast and elementwise without reduction, branch or expensive operations)
*/
OperationMap<bool> is_strictly_inlineable;
/*! \brief Store whether the operation needs multi-level tiling
Expand Down Expand Up @@ -98,8 +98,8 @@ class AccessAnalyzer : public ObjectRef {
TVM_DLL bool IsSimpleAccess(const te::Operation& op) const;

/*!
* \brief Return whether this operation is strictly inlinable
* (e.g., injective, broadcast and elementwise without reduction, branch or expenive operations)
* \brief Return whether this operation is strictly inlineable
* (e.g., injective, broadcast and elementwise without reduction, branch or expensive operations)
* \param op The operation
*/
TVM_DLL bool IsStrictlyInlineable(const te::Operation& op) const;
Expand Down Expand Up @@ -265,7 +265,7 @@ class ComputeDAG : public ObjectRef {
* \brief Since some steps may change the ComputeDAG (e.g. CacheRead/CacheWrite), the initial
* ComputeDAG may not be up-to-date. This function replays the given transform steps from the
* initial state and returns an up-to-date ComputeDAG.
* \param steps The steps to be replaied. Usually we'll filter out the unused steps to speed up
* \param steps The steps to be replayed. Usually we'll filter out the unused steps to speed up
* the replay process, since we only intend to get a ComputeDAG with the up-to-date op stage
* structure.
* \return The up-to-date ComputeDAG.
Expand Down
4 changes: 2 additions & 2 deletions include/tvm/auto_scheduler/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ void GetPerStoreFeaturesFromFile(const std::string& filename, int max_lines, int

/*!
* \brief Get per-store features from measurement input/result pairs
* \param inputs The meaurement inputs
* \param inputs The measurement inputs
* \param results The measurement results
* \param skip_first_n_feature_extraction Skip feature extraction for the first n meaurement pairs
* \param skip_first_n_feature_extraction Skip feature extraction for the first n measurement pairs
* \param max_n_bufs The maximum number of extracted buffers for one statement
* \param features The returned feature vector. The innermost vector contains the
* feature vectors for all BufferStoreNode statements
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/auto_scheduler/loop_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ namespace std {

/*!
* \brief The equal_to function for auto_scheduler::State.
* This function checkes the equality by looking at the lowered string format of states.
* This function checks the equality by looking at the lowered string format of states.
* If two states with different transform history have the same lowered string format,
* they will be considered being equal.
*/
Expand Down
16 changes: 8 additions & 8 deletions include/tvm/auto_scheduler/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ enum class MeasureErrorNO : int {
/*! \brief Timeout during run. */
kRunTimeoutError = 7,
/*! \brief Unknown error. */
kUnknonwError = 8,
kUnknownError = 8,
};

// Inputs and results of one measurement
Expand Down Expand Up @@ -104,7 +104,7 @@ class MeasureInput : public ObjectRef {
public:
/*!
* \brief The constructor.
* \param task The SearchTeask of this measure.
* \param task The SearchTask of this measure.
* \param state The State to be measured.
*/
MeasureInput(SearchTask task, State state);
Expand Down Expand Up @@ -353,7 +353,7 @@ class LocalRunner : public ProgramRunner {
public:
/*!
* \brief The constructor. See the corresponding class in python/tvm/auto_scheduler/measure.py
* for more detailed parameter explaination.
* for more detailed parameter explanation.
* \param timeout The timeout limit (in second) for each run.
* This is used in a wrapper of the multiprocessing.Process.join().
* \param number The number of times to run the generated code for taking average.
Expand Down Expand Up @@ -401,7 +401,7 @@ class RPCRunner : public ProgramRunner {
public:
/*!
* \brief The constructor. See the corresponding class in python/tvm/auto_scheduler/measure.py
* for more detailed parameter explaination.
* for more detailed parameter explanation.
* \param key The key of the device registered in the RPC tracker.
* \param host The host address of the RPC Tracker.
* \param port The port of RPC Tracker.
Expand Down Expand Up @@ -445,7 +445,7 @@ class ProgramMeasurerNode : public Object {
/*! \brief Verbosity level. 0 for silent, 1 to output information during program measuring. */
int verbose;
/*! \brief The number of max continuous error. */
int max_continous_error;
int max_continuous_error;

/*! \brief Reset book keeping variables */
void Reset();
Expand All @@ -472,7 +472,7 @@ class ProgramMeasurerNode : public Object {
Array<MeasureResult>* results);

/*! \brief The default max continuous error setting. */
static const int DEFAULT_MAX_CONTINOUS_ERROR = 150;
static const int DEFAULT_MAX_CONTINUOUS_ERROR = 150;

static constexpr const char* _type_key = "auto_scheduler.ProgramMeasurer";
TVM_DECLARE_FINAL_OBJECT_INFO(ProgramMeasurerNode, Object);
Expand All @@ -491,11 +491,11 @@ class ProgramMeasurer : public ObjectRef {
* \param callbacks MeasureCallback to be called after each measure batch.
* \param verbose Verbosity level. 0 for silent, 1 to output information during program
* measuring.
* \param max_continous_error The number of allowed maximum continuous error.
* \param max_continuous_error The number of allowed maximum continuous error.
*/
ProgramMeasurer(ProgramBuilder builder, ProgramRunner runner,
Optional<Array<MeasureCallback>> callbacks, int verbose,
int max_continous_error = -1);
int max_continuous_error = -1);

TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(ProgramMeasurer, ObjectRef, ProgramMeasurerNode);
};
Expand Down
8 changes: 4 additions & 4 deletions python/tvm/auto_scheduler/cost_model/cost_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def predict(self, search_task, states):
----------
search_task : SearchTask
The search task of states
statse : List[State]
states : List[State]
The input states

Returns
Expand Down Expand Up @@ -126,7 +126,7 @@ def predict(self, task, states):
----------
search_task : SearchTask
The search task of states
statse : List[State]
states : List[State]
The input states

Returns
Expand All @@ -143,7 +143,7 @@ def predict_stages(self, task, states):
----------
search_task : SearchTask
The search task of states
statse : List[State]
states : List[State]
The input states

Returns
Expand All @@ -166,7 +166,7 @@ def predict_stages(self, task, states):
...
int n_stage_i; // the number of stages in states[i]
float stage_scores_1[n_stage_i]; // the scores for all stages in states[i]
... // untill i == N - 1
... // until i == N - 1
}
To implement this format, we also store int as float, so we can store all numbers
into a single float array.
Expand Down
29 changes: 0 additions & 29 deletions python/tvm/auto_scheduler/cost_model/xgb_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(self):
def get(self, key, matrix, default=None):
"""
Get an attribute of a xgb.DMatrix

Parameters
----------
key: str
Expand All @@ -59,7 +58,6 @@ def get(self, key, matrix, default=None):
def set(self, key, matrix, value):
"""
Set an attribute for a xgb.DMatrix

Parameters
----------
key: str
Expand All @@ -77,15 +75,12 @@ def set(self, key, matrix, value):

class XGBModel(PythonBasedModel):
"""Train a XGBoost model to predict the normalized throughputs of programs.

Let the normalized throughput be the score of a program (higher is better). We predict
the (approximiate) score of a program = the sum of the scores of all stages in this program.
i.e. score(P) = score_s0 + score_s1 + ... + score_sn,
where score_si is the score of Stage i in Program P.

We extract feature for each stage and let the xgboost predict the score for each stage.
We then sum up the predictions as the score of the whole program.

We use RMSE as the loss function. i.e. loss(P, y) = 1/2 * (score(P) - y)^2,
where P is the program and y is the normalized throughput according to
the ground truth (measurement).
Expand Down Expand Up @@ -123,7 +118,6 @@ def __init__(self, verbose_eval=25, num_warmup_sample=100, seed=None):
def update(self, inputs, results):
"""Update the cost model according to new measurement results (training data).
XGBoost does not support incremental training, so we re-train a new model every time.

Parameters
----------
inputs : List[MeasureInput]
Expand Down Expand Up @@ -175,14 +169,12 @@ def update(self, inputs, results):

def predict(self, task, states):
"""Predict the scores of states

Parameters
----------
search_task : SearchTask
The search task of states
statse : List[State]
The input states

Returns
-------
scores: List[float]
Expand All @@ -205,24 +197,20 @@ def predict(self, task, states):

def predict_stages(self, task, states):
"""Predict the scores of all stages in states. This is the breakdown version of `predict`.

Parameters
----------
search_task : SearchTask
The search task of states
statse : List[State]
The input states

Returns
-------
scores: List[float]
The predicted scores for all stages in all states in the packed format

Note
----
For faster data copy between c++ and python, the python part returns scores in a
single flatten array using a packed format. The c++ part then unpacks the flatten array.

The packed format is:
{
float scores[N]; // scores[i] is the score for states[i].
Expand Down Expand Up @@ -269,7 +257,6 @@ def predict_stages(self, task, states):
def update_from_file(self, file_name, n_lines=None):
"""Load measure records from a log file to update the cost model.
This function can be used to pre-train the cost model with history log files.

Parameters
----------
file_name: str
Expand All @@ -283,7 +270,6 @@ def update_from_file(self, file_name, n_lines=None):

def save(self, file_name: str):
"""Save the model to a file

Parameters
----------
file_name: str
Expand All @@ -293,7 +279,6 @@ def save(self, file_name: str):

def load(self, file_name: str):
"""Load the model from a file

Parameters
----------
file_name: str
Expand All @@ -307,12 +292,10 @@ def load(self, file_name: str):

def feature_to_pack_sum_xgbmatrix(xs):
"""Convert an extracted multi-stage feature vector to a xgbmatrx in pack-sum format

Parameters
----------
xs: np.ndarray
The feature vector

Returns
-------
dmatrix: xgb.DMatrix
Expand All @@ -333,7 +316,6 @@ def feature_to_pack_sum_xgbmatrix(xs):

def pack_sum_xgbmatrix(xs, ys, gids=None, weights=None):
"""Convert (feature, label) pairs into a xgb matrix with pack-sum format

Parameters
----------
xs: np.ndarray
Expand All @@ -344,7 +326,6 @@ def pack_sum_xgbmatrix(xs, ys, gids=None, weights=None):
Group id (task id)
weights: Optional[np.ndarray]
The weight of samples

Returns
-------
dmatrix: xgb.DMatrix
Expand Down Expand Up @@ -390,14 +371,12 @@ def pack_sum_xgbmatrix(xs, ys, gids=None, weights=None):

def predict_throughput_pack_sum(raw_preds, pack_ids):
"""Predict the throughputs for predictions in pack-sum format

Parameters
----------
raw_preds: np.ndarray
The raw predictions
pack_ids: List[int]
The pack id for predictions

Returns
-------
throughputs: np.ndarray
Expand All @@ -410,14 +389,12 @@ def predict_throughput_pack_sum(raw_preds, pack_ids):
def pack_sum_square_error(preds, dtrain):
"""Implement square error loss on pack-sum format as
a custom objective function for xgboost.

Parameters
----------
preds: np.ndarray
The predicitons
dtrain: xgb.DMatrix
The training set

Returns
-------
gradient: np.ndarray
Expand All @@ -441,14 +418,12 @@ def pack_sum_square_error(preds, dtrain):

def pack_sum_rmse(raw_preds, labels):
"""Evaluate RMSE (rooted mean square error) in the pack-sum format

Parameters
----------
raw_preds: np.ndarray
The raw prediction
labels: xgb.DMatrix
The groud-truth label matrix

Returns
-------
name: str
Expand All @@ -462,27 +437,23 @@ def pack_sum_rmse(raw_preds, labels):

def pack_sum_average_peak_score(N):
"""Return the evaluation function for average-peak-score@N

Parameters
----------
N: int
The "N" in "average-peak-score@N"

Returns
-------
The evaluation function
"""

def feval(preds, labels):
"""Evaluate average-peak-score@N in the pack-sum format

Parameters
----------
raw_preds: np.ndarray
The raw prediction
labels: xgb.DMatrix
The groud-truth label matrix

Returns
-------
name: str
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/auto_scheduler/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def unpack_feature(byte_arr: bytearray) -> Tuple[np.ndarray, np.ndarray, np.ndar
float features_i[size[i]]; // The features for record i
... // until i == n - 1

float throuputs[sizes[n]]; // The normalized throughputs for n records
float throughputs[sizes[n]]; // The normalized throughputs for n records
int task_ids[size[n+1]; // The task ids for n records

}
Expand Down
Loading