| 187 | } |
| 188 | |
| 189 | bool MLGOHeuristics::add_heuristic_tree(HeuristicTree &&t) |
| 190 | { |
| 191 | if (_indices.size() >= _max_num_trees) |
| 192 | { |
| 193 | ARM_COMPUTE_LOG_INFO_MSG_WITH_FORMAT_CORE("Exceeding the max number of trees allowed: %zu", _max_num_trees); |
| 194 | return false; |
| 195 | } |
| 196 | // PRE: correctness of t is guaranteed by the tree construction process |
| 197 | // Ensure unique id |
| 198 | const auto id = t.id(); |
| 199 | if (_indices.find(id) != _indices.end()) |
| 200 | { |
| 201 | ARM_COMPUTE_LOG_INFO_MSG_WITH_FORMAT_CORE("Cannot add redundant trees; tree id %zu already exists", id); |
| 202 | return false; |
| 203 | } |
| 204 | |
| 205 | // Ensure unique index |
| 206 | const auto index = t.index(); |
| 207 | if (_trees.find(index) != _trees.end()) |
| 208 | { |
| 209 | ARM_COMPUTE_LOG_INFO_MSG_CORE("Cannot add redundant trees; tree index already exists"); |
| 210 | return false; |
| 211 | } |
| 212 | |
| 213 | _indices[id] = index; |
| 214 | _trees[index] = std::move(t); |
| 215 | _tree_valid[id] = false; |
| 216 | return true; |
| 217 | } |
| 218 | |
| 219 | bool MLGOHeuristics::reload_from_file(const std::string &filename) |
| 220 | { |