hello,I am a very beginner to tvm, and I am confused about the features using in the cost model.
I am now reading the code of tune_nnvm_cuda.py in tutorials,and notice it use xgboost as cost model,feature_type is the default ‘itervar’.
But then I have problems following the code and don’t know what the features are exactly.
PS: I have read the paper Learning to Optimize Tensor Programs , Section4 Context Relation Features for GBT, whether the features are those described in paer?
Python interface:
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name
"""Extract feature of iter vars
There are two types of feature
This file has been truncated. show original
C++ implementation and comments on the format:
itervar_map[var].touch_feature[buf] = x->second;
} else {
itervar_map[var].touch_feature[buf] = TouchPattern();
}
}
}
void TouchExtractor::ExitMem_() {
}
/*!
* \brief Get axis-based feature for all axes
* \param stmt The statement to be extracted
* \param bool Whether take log for numerical feature
* \param ret_feature The buffer where the return value is stored
*
* \note The format of return value is
* ((
* ('_itervar_', var),
* ('_attr_', length, nest_level, topdown, bottomup, one_hot_annotation),
* ('_arith_', add_ct, mul_ct, div_ct),
Context relation features are called “CurveSampleFeature” in the code
}
}
}
/*!
* \brief Get curve sample feature (relation feature) and flatten them into a one-dimensional vector.
* \param stmt The statement to be extracted
* \param sample_n The number of points used for sampling a curve (along one dimension)
* \param ret_feature The buffer where the return value is stored
*/
void GetCurveSampleFeatureFlatten(Stmt stmt, int sample_n, std::vector<float> *ret_feature) {
// extract touch feature
TouchExtractor touch_ext;
touch_ext.Analyze(stmt);
// sort according to order
std::vector<VarExpr> vars;
for (auto kv : touch_ext.itervar_map) {
vars.push_back(kv.first);
}
std::sort(vars.begin(), vars.end(), [&](const VarExpr &lhs, const VarExpr &rhs) -> bool {
Test (Examples):
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Test feature extraction"""
import numpy as np
This file has been truncated. show original
Thanks a lot, I will check them.