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

Method profile

src/gopt/impl/global_layout_transform/profiler_impl.cpp:406–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406ProfilerImpl::ProfilingResult ProfilerImpl::profile(const Problem& problem) const {
407 ConstVarPropogate cvprop{ConstVarType::IMMUTABLE_AND_PARAM};
408 {
409 auto cb = [&cvprop](OperatorNodeBase* opr) { cvprop.add_opr(opr); };
410 DepOprIter iter{cb};
411 for (auto&& o : problem.graph_partition().output()) {
412 iter.add(o->owner_opr());
413 }
414 }
415
416 static const ThinHashMap<Typeinfo*, size_t> format_aware_input_tensors = {
417#define cb(_Opr, _arity) {_Opr::typeinfo(), _arity}
418 cb(Convolution, 2),
419 cb(ConvBiasForward, 4),
420 cb(ConvolutionBackwardData, 2),
421 cb(PoolingForward, 1),
422 cb(WarpPerspective, 1),
423 cb(Resize, 1),
424#undef cb
425 };
426 static const ThinHashSet<Typeinfo*> skip_opr_types = {
427 TypeCvt::typeinfo(), Elemwise::typeinfo(), ElemwiseMultiType::typeinfo()};
428 ThinHashSet<VarNode*> vars;
429 ThinHashSet<OperatorNodeBase*> oprs;
430 ThinHashSet<OperatorNodeBase*> skip_oprs;
431 for (auto&& opr : problem.graph_partition().all_oprs()) {
432 if (cvprop.is_const(opr))
433 continue;
434 bool skip = true;
435 for (auto&& i : opr->input()) {
436 skip &= problem.graph_partition().input().count(i) > 0 ||
437 skip_oprs.count(i->owner_opr()) > 0;
438 }
439 auto find = format_aware_input_tensors.find(opr->dyn_typeinfo());
440 skip &= find == format_aware_input_tensors.end();
441 if (skip)
442 skip_oprs.insert(opr);
443 oprs.insert(opr);
444 if (find == format_aware_input_tensors.end()) {
445 for (auto&& i : opr->input()) {
446 if (!cvprop.is_const(i)) {
447 vars.insert(i);
448 }
449 }
450 } else {
451 size_t nr_input_tensor = std::min(find->second, opr->input().size());
452 for (size_t i = 0; i < nr_input_tensor; ++i) {
453 if (!cvprop.is_const(opr->input(i))) {
454 vars.insert(opr->input(i));
455 }
456 }
457 }
458 for (auto&& ov : opr->usable_output()) {
459 vars.insert(ov);
460 }
461 }
462
463 auto base_format = problem.base_format();

Callers 2

TESTFunction · 0.45
solveMethod · 0.45

Calls 15

profileFunction · 0.85
instFunction · 0.85
all_oprsMethod · 0.80
is_constMethod · 0.80
base_formatMethod · 0.80
emplace_backMethod · 0.80
base_configMethod · 0.80
cbFunction · 0.70
minFunction · 0.50
add_oprMethod · 0.45
outputMethod · 0.45
addMethod · 0.45

Tested by 1

TESTFunction · 0.36