Go to the documentation of this file. 8 #ifndef TREELITE_COMPILER_NATIVE_QNODE_TEMPLATE_H_ 9 #define TREELITE_COMPILER_NATIVE_QNODE_TEMPLATE_H_ 15 const char*
const qnode_template =
20 * \brief function to convert a feature value into bin index. 21 * \param val feature value, in floating-point 22 * \param fid feature identifier 23 * \return bin index corresponding to given feature value 25 static inline int quantize({threshold_type} val, unsigned fid) {{ 26 const size_t offset = th_begin[fid]; 27 const {threshold_type}* array = &threshold[offset]; 28 int len = th_len[fid]; 32 {threshold_type} mval; 33 // It is possible th_begin[i] == [total_num_threshold]. This means that 34 // all features i, (i+1), ... are not used for any of the splits in the model. 35 // So in this case, just return something 36 if (offset == {total_num_threshold} || val < array[0]) {{ 39 while (low + 1 < high) {{ 40 mid = (low + high) / 2; 44 }} else if (val < mval) {{ 50 if (array[low] == val) {{ 52 }} else if (high == len) {{ 60 const char*
const quantize_loop_template =
62 for (int i = 0; i < {num_feature}; ++i) {{ 63 if (data[i].missing != -1 && !is_categorical[i]) {{ 64 data[i].qvalue = quantize(data[i].fvalue, i); 72 #endif // TREELITE_COMPILER_NATIVE_QNODE_TEMPLATE_H_