| 582 | } |
| 583 | |
| 584 | void LogDump(int log_level, const string& message, const Model& model) { |
| 585 | namespace port = toco::port; |
| 586 | const auto& dump_options = *GraphVizDumpOptions::singleton(); |
| 587 | |
| 588 | DumpGraphvizVideoFrame(model); |
| 589 | if (!dump_options.dump_graphviz.empty()) { |
| 590 | string graphviz_dump; |
| 591 | |
| 592 | DumpGraphviz(model, &graphviz_dump, message); |
| 593 | const auto result = port::file::SetContents( |
| 594 | port::file::JoinPath( |
| 595 | dump_options.dump_graphviz, |
| 596 | absl::StrCat("toco_", absl::StrReplaceAll(message, {{" ", "_"}}), |
| 597 | ".dot")), |
| 598 | graphviz_dump, port::file::Defaults()); |
| 599 | QCHECK(result.ok()) << result.error_message(); |
| 600 | } |
| 601 | |
| 602 | if (!VLOG_IS_ON(log_level)) { |
| 603 | return; |
| 604 | } |
| 605 | VLOG(log_level) << "BEGIN DUMP OF TOCO MODEL (" << message << ")"; |
| 606 | LogSummary(log_level, model); |
| 607 | std::unordered_set<string> already_printed_arrays; |
| 608 | for (const auto& op : model.operators) { |
| 609 | for (const auto& input : op->inputs) { |
| 610 | if (!already_printed_arrays.count(input)) { |
| 611 | already_printed_arrays.insert(input); |
| 612 | LogArray(log_level, model, input); |
| 613 | } |
| 614 | } |
| 615 | VLOG(log_level) << HelpfulOperatorTypeName(*op) << " :"; |
| 616 | VLOG(log_level) << " " << FormatArraysList(model, op->inputs) << " -> " |
| 617 | << FormatArraysList(model, op->outputs); |
| 618 | if (op->fused_activation_function != FusedActivationFunctionType::kNone) { |
| 619 | VLOG(log_level) << " (with fused activation function)"; |
| 620 | } |
| 621 | for (const auto& output : op->outputs) { |
| 622 | if (!already_printed_arrays.count(output)) { |
| 623 | already_printed_arrays.insert(output); |
| 624 | LogArray(log_level, model, output); |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | VLOG(log_level) << "END DUMP OF TOCO MODEL (" << message << ")"; |
| 629 | } |
| 630 | |
| 631 | // Note remaining raw-array extension in ProcessTensorFlowReshapeOperator(). |
| 632 | void ExtendShape(Shape* shape, int new_shape_size) { |
no test coverage detected