MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / get_algorithm

Function get_algorithm

dnn/src/common/algo_chooser.h:25–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 */
24template <class Opr, typename... Args>
25typename Opr::AlgoBase* get_algorithm(Opr* opr, Args&&... args) {
26 typename Opr::AlgorithmDesc ret;
27 // first check self configured algorithm
28 auto set = opr->execution_policy().algo;
29 if (set.valid()) {
30 ret = set;
31 } else {
32 TensorLayoutArray layouts{{args...}};
33 AlgorithmCache::Key key{opr->handle(), opr->get_opr_type(),
34 layouts.data(), layouts.size(),
35 &opr->param(), sizeof(opr->param())};
36 // then get from global algorithm cache
37 auto rst = AlgorithmCache::instance().get(key);
38 if (rst.policy.algo.valid()) {
39 ret = rst.policy.algo;
40 } else {
41 // finally get pre-defined heuristic algorithm
42 ret = opr->get_algorithm_info_heuristic(
43 std::forward<Args>(args)...,
44 std::numeric_limits<size_t>::max(), AlgoAttribute::DEFAULT,
45 AlgoAttribute::DEFAULT)
46 .desc;
47 }
48 }
49 return static_cast<typename Opr::AlgoBase*>(opr->get_algorithm_from_desc(ret));
50}
51
52/*!
53 * \brief get user-configured algorithm, or heuristic algorithm. used in opencl

Callers 15

execMethod · 0.85
execMethod · 0.85
execMethod · 0.85
execMethod · 0.85
execMethod · 0.85
execMethod · 0.85
opr_impl.hFile · 0.85
execMethod · 0.85
exec_preprocessMethod · 0.85

Calls 10

maxFunction · 0.85
validMethod · 0.45
handleMethod · 0.45
get_opr_typeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
paramMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected