MCPcopy Create free account
hub / github.com/davisking/dlib / pick_best_algorithm

Function pick_best_algorithm

dlib/cuda/cudnn_dlibapi.cpp:765–785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

763 // cudnnConvolutionFwdAlgoPerf_t, pick the best one to use.
764 template <typename T>
765 decltype(std::declval<T>().algo) pick_best_algorithm(const std::vector<T> &perf_results)
766 {
767 DLIB_CASSERT(!perf_results.empty());
768 CHECK_CUDNN(perf_results[0].status);
769 if (dnn_prefer_fastest_algorithms())
770 return perf_results[0].algo;
771
772 // Otherwise we find the algorithm that has a good status and uses the least amount
773 // of memory.
774 size_t best_memory = std::numeric_limits<size_t>::max();
775 decltype(std::declval<T>().algo) best_alg;
776 for (auto&& perf : perf_results)
777 {
778 if (perf.status == CUDNN_STATUS_SUCCESS && perf.memory < best_memory)
779 {
780 best_memory = perf.memory;
781 best_alg = perf.algo;
782 }
783 }
784 return best_alg;
785 }
786
787 void tensor_conv::
788 select_best_algorithms (

Callers 1

Calls 3

maxFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected