MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ShowInternal

Method ShowInternal

tensorflow/core/profiler/internal/tfprof_code.cc:466–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464}
465
466const ShowMultiNode* TFCode::ShowInternal(const Options& opts,
467 Timeline* timeline) {
468 root_->ResetTotalStats();
469 if (opts.output_type == kOutput[3]) {
470 if (opts.select.size() != 1) {
471 fprintf(stderr, "Can only select 1 attribute for pprof output.\n");
472 return root_.get();
473 }
474 string select = *opts.select.begin();
475 if (select != kShown[0] && select != kShown[1] && select != kShown[2] &&
476 select != kShown[3] && select != kShown[9] && select != kShown[10] &&
477 select != kShown[11] && select != kShown[12] && select != kShown[13]) {
478 fprintf(stderr, "pprof doesn't support -select=%s\n", select.c_str());
479 return root_.get();
480 }
481 }
482 if (opts.account_displayed_op_only) {
483 fprintf(stderr, "Note: code view ignores account_displayed_op_only\n");
484 }
485
486 std::vector<CodeNode*> roots = Account(root_->children, opts);
487 root_->show_children.clear();
488 for (CodeNode* n : roots) {
489 root_->AggregateTotalStats(n);
490 }
491
492 if (opts.start_name_regexes.size() != 1 ||
493 opts.start_name_regexes[0] != ".*") {
494 roots = SearchRoot(roots, opts.start_name_regexes);
495 }
496
497 root_->show_children.assign(roots.begin(), roots.end());
498
499 CodeNode* root = PrintScope({root_.get()}, opts, 1, 0)[0];
500
501 root->formatted_str = FormatLegend(opts) + root->formatted_str;
502
503 if (opts.output_type == kOutput[3]) {
504 std::vector<uint64> call_ids;
505 pprof_profile_.reset(new PprofProfileImpl(&opts));
506 Format(root, root->show_children, opts, &root->formatted_str,
507 root->mutable_proto(), &call_ids);
508 Status s = pprof_profile_->WritePprofProfile(
509 opts.output_options.at(kPprofOpts[0]));
510 if (!s.ok()) {
511 fprintf(stderr, "%s\n", s.ToString().c_str());
512 }
513 } else {
514 Format(root, root->show_children, opts, &root->formatted_str,
515 root->mutable_proto(), nullptr);
516 if (timeline) {
517 timeline->GenerateCodeTimeline(root);
518 }
519 }
520 return root;
521}
522
523void TFCode::Format(const CodeNode* root, const std::vector<CodeNode*>& nodes,

Callers

nothing calls this directly

Calls 15

ResetTotalStatsMethod · 0.80
c_strMethod · 0.80
AggregateTotalStatsMethod · 0.80
WritePprofProfileMethod · 0.80
GenerateCodeTimelineMethod · 0.80
FormatEnum · 0.50
sizeMethod · 0.45
getMethod · 0.45
beginMethod · 0.45
clearMethod · 0.45
assignMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected