-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thresh_as_int parameter added #42
base: main
Are you sure you want to change the base?
Conversation
@@ -33,7 +33,7 @@ class ASTBuilder { | |||
ASTBuilder() : main_node_(nullptr) {} | |||
|
|||
/* \brief Initially build AST from model */ | |||
void BuildAST(treelite::Model const& model); | |||
void BuildAST(treelite::Model const& model, bool thresh_as_int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the new option thresh_as_int
is fine for now. But if we were to add more options to BuildAST, we should consider passing around the CompilerParam
struct instead, to avoid having too many function arguments.
return "(*( (("+new_dtype+"*)(data)) + "+std::to_string(node->split_index_)+" )" | ||
+negatstring+")"+op+"(("+new_dtype+")("+split_val_bin+"))"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use fmt::format
to format strings for the sake of legibility. It works like f-strings in Python.
return "(*( (("+new_dtype+"*)(data)) + "+std::to_string(node->split_index_)+" )" | |
+negatstring+")"+op+"(("+new_dtype+")("+split_val_bin+"))"; | |
return fmt::format("(*( (({new_dtype}*)(data)) + {split_index} ) {negatstring} ) {op} (( {new_dtype} )( {split_val_bin} ))", | |
"new_dtype"_a = new_dtype, "split_index"_a = node->split_index_, | |
"negatstring"_a = negatstring, "op"_a = op, | |
"new_dtype"_a = new_dtype, "split_val_bin"_a = split_val_bin); |
Added functionality to be able to interpret the thresholds as integers, using an optional parameter.
This increases the performance up to 30%, without loss of accuracy.
The implementation is based on the following paper:
https://ieeexplore.ieee.org/abstract/document/10546851