Improve hash_function used by TreeEnsemble (#22043)
### Description unordered_map are implemented in a different way on VisualStudio and gcc. It seems that inserting consecutive keys has a poor performance on Windows. ### Motivation and Context Improve the performance of onnxruntime when initializing trees.
This commit is contained in:
Родитель
e91ff9438b
Коммит
91c916f9c6
|
@ -23,7 +23,9 @@ struct TreeNodeElementId {
|
|||
}
|
||||
struct hash_fn {
|
||||
std::size_t operator()(const TreeNodeElementId& key) const {
|
||||
return static_cast<std::size_t>(static_cast<uint64_t>(key.tree_id) << 32 | static_cast<uint64_t>(key.node_id));
|
||||
// unordered_map has poor performance on Windows when inserting consecutive keys.
|
||||
// keys are usually inserted with key.node_id being incremented at each iteration.
|
||||
return static_cast<std::size_t>(static_cast<uint64_t>(key.tree_id) | static_cast<uint64_t>(key.node_id) << 32);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче