| 857 | // could not benchmark the algorithms and had to guess. |
| 858 | template <typename find_type, typename get_workspace_size_type> |
| 859 | int choose_algorithm ( |
| 860 | const algorithm_cache::key_type& key, |
| 861 | const size_t which, |
| 862 | find_type find, |
| 863 | get_workspace_size_type get_workspace_size, |
| 864 | size_t& workspace_size_in_bytes |
| 865 | ) |
| 866 | { |
| 867 | auto& cache = chosen_algorithms(); |
| 868 | const auto cached = cache.find(key); |
| 869 | auto algorithms = cached ? *cached : algorithm_cache::value_type{{ -1, -1, -1 }}; |
| 870 | if (algorithms[which] >= 0) |
| 871 | { |
| 872 | try |
| 873 | { |
| 874 | workspace_size_in_bytes = get_workspace_size(algorithms[which]); |
| 875 | return algorithms[which]; |
| 876 | } |
| 877 | catch (dlib::cudnn_error&) |
| 878 | { |
| 879 | // Sometimes the values stored in the cache do not quite work - so let's get a |
| 880 | // fresh estimate, instead of using a cached value. |
| 881 | } |
| 882 | } |
| 883 | bool benchmarked = true; |
| 884 | algorithms[which] = find(benchmarked); |
| 885 | workspace_size_in_bytes = get_workspace_size(algorithms[which]); |
| 886 | if (benchmarked) |
| 887 | cache.insert(key, algorithms); |
| 888 | return algorithms[which]; |
| 889 | } |
| 890 | |
| 891 | std::tuple<int,int,int,int,long,long,long,long,long,long,long> tensor_conv:: |
| 892 | algorithm_cache_key ( |
no test coverage detected