Skip to content
Open
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "conifer/externals/nlohmann"]
path = conifer/externals/nlohmann
url = https://github.com/nlohmann/json.git
[submodule "conifer/externals/Vitis_HLS"]
path = conifer/externals/Vitis_HLS
url = https://github.com/Xilinx/hls-utilities.git
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
recursive-include conifer/backends *
recursive-include conifer/externals *
16 changes: 8 additions & 8 deletions conifer/backends/cpp/include/conifer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class OpAdd {
T operator()(T a, T b) { return a + b; }
};

template <typename T, typename U>
std::function<bool (T, U)> createSplit(const std::string& op) {
std::function<bool (T, U)> split;
template <typename T>
std::function<bool (T, T)> createSplit(const std::string& op) {
std::function<bool (T, T)> split;
if (op == "<") {
split = [](const T& a, const U& b) { return a < b; };
split = [](const T& a, const T& b) { return a < b; };
} else if (op == "<=") {
split = [](const T& a, const U& b) { return a <= b; };
split = [](const T& a, const T& b) { return a <= b; };
} else {
throw std::invalid_argument("Invalid operator string: " + op);
}
Expand All @@ -69,7 +69,7 @@ class DecisionTree{
std::vector<U> value_;
std::vector<double> threshold;
std::vector<double> value;
std::function<bool (T, U)> split;
std::function<bool (T, T)> split;

public:

Expand All @@ -84,7 +84,7 @@ class DecisionTree{
return value_[i];
}

void init_(std::function<bool (T, U)> split){
void init_(std::function<bool (T, T)> split){
/* Since T, U types may not be readable from the JSON, read them to double and the cast them here */
this->split = split;
std::transform(threshold.begin(), threshold.end(), std::back_inserter(threshold_),
Expand Down Expand Up @@ -124,7 +124,7 @@ class BDT{
nlohmann::json j = nlohmann::json::parse(ifs);
from_json(j, *this);
auto splitting_convention = j.value("splitting_convention", "<="); // read the splitting convention with default value of "<=" if it's unspecified
auto split = createSplit<T,U>(splitting_convention);
auto split = createSplit<T>(splitting_convention);
/* Do some transformation to initialise things into the proper emulation T, U types */
if(n_classes == 2) n_classes = 1;
std::transform(init_predict.begin(), init_predict.end(), std::back_inserter(init_predict_),
Expand Down
1 change: 1 addition & 0 deletions conifer/externals/Vitis_HLS
Submodule Vitis_HLS added at 78b0c3
Loading