1 #ifndef CAFFE2_OPERATORS_CONV_OP_CACHE_H_ 2 #define CAFFE2_OPERATORS_CONV_OP_CACHE_H_ 5 #include <unordered_map> 8 #include "caffe2/core/logging.h" 9 #include "caffe2/core/tensor.h" 12 template <
typename TAlgorithm>
18 TAlgorithm getAlgorithm(
23 std::function<TAlgorithm()> generatingFunc);
26 std::unordered_map<int64_t, TAlgorithm> hash_;
29 template <
typename TAlgorithm>
34 std::function<TAlgorithm()> generatingFunc) {
38 std::hash<int64_t> hashFn;
39 for (
const auto num : tensorDimensions1) {
42 seed ^= hashFn(num) + 0x9e3779b9 + (seed << 6) + (seed >> 2) + 1;
45 for (
const auto num : tensorDimensions2) {
47 seed ^= hashFn(num) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
51 seed ^= hashFn(algorithmFlags) + 0x9e3779b9 + (seed << 6) + (seed >> 2) + 2;
54 return generatingFunc();
57 if (hash_.find(seed) == hash_.end()) {
58 TAlgorithm value = generatingFunc();
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...