Open
Conversation
hcho3
requested changes
Feb 19, 2025
|
|
||
| /* \brief Initially build AST from model */ | ||
| void BuildAST(treelite::Model const& model); | ||
| void BuildAST(treelite::Model const& model, bool thresh_as_int); |
Collaborator
There was a problem hiding this comment.
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.
Comment on lines
+70
to
+71
| return "(*( (("+new_dtype+"*)(data)) + "+std::to_string(node->split_index_)+" )" | ||
| +negatstring+")"+op+"(("+new_dtype+")("+split_val_bin+"))"; |
Collaborator
There was a problem hiding this comment.
Let's use fmt::format to format strings for the sake of legibility. It works like f-strings in Python.
Suggested change
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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