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

Function RealMain

tensorflow/compiler/xla/tools/interactive_graphviz.cc:656–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654}
655
656void RealMain(const Options& opts) {
657 if (!isatty(fileno(stdin))) {
658 LOG(ERROR) << "\n\n*****************************************\n"
659 << "This is an interactive tool, but stdin is not a tty.\n"
660 << "*****************************************\n\n";
661 }
662
663 CheckFlags(opts);
664
665 std::unique_ptr<HloModule> module;
666 if (!opts.hlo_snapshot.empty()) {
667 HloSnapshot snapshot;
668 TF_CHECK_OK(tensorflow::ReadBinaryProto(tensorflow::Env::Default(),
669 opts.hlo_snapshot, &snapshot))
670 << "Can't open, read, or parse HloSnapshot proto at "
671 << opts.hlo_snapshot;
672 auto config =
673 HloModule::CreateModuleConfigFromProto(snapshot.hlo().hlo_module(),
674 xla::GetDebugOptionsFromFlags())
675 .ValueOrDie();
676 module = HloModule::CreateFromProto(snapshot.hlo().hlo_module(), config)
677 .ValueOrDie();
678 } else if (!opts.hlo_proto.empty()) {
679 module = HloRunner::ReadModuleFromBinaryProtoFile(
680 opts.hlo_proto, xla::GetDebugOptionsFromFlags())
681 .ValueOrDie();
682 } else if (!opts.hlo_text.empty()) {
683 module = HloRunner::ReadModuleFromHloTextFile(
684 opts.hlo_text, xla::GetDebugOptionsFromFlags())
685 .ValueOrDie();
686 }
687
688 // If a platform was specified, compile the module for that platform.
689 if (!opts.platform.empty()) {
690 se::Platform* platform =
691 PlatformUtil::GetPlatform(opts.platform).ValueOrDie();
692 LOG(INFO) << "Compiling module for " << platform->Name();
693
694 se::StreamExecutor* executor =
695 platform->ExecutorForDevice(/*ordinal=*/0).ValueOrDie();
696 auto compiler = Compiler::GetForPlatform(platform).ValueOrDie();
697 module = compiler
698 ->RunHloPasses(std::move(module), executor,
699 /*device_allocator=*/nullptr)
700 .ValueOrDie();
701 auto executable = compiler
702 ->RunBackend(std::move(module), executor,
703 /*device_allocator=*/nullptr)
704 .ValueOrDie();
705 InteractiveDumpGraphs(opts, executable->module());
706 } else {
707 InteractiveDumpGraphs(opts, *module);
708 }
709}
710
711} // namespace
712} // namespace tools

Callers 1

mainFunction · 0.70

Calls 11

CheckFlagsFunction · 0.85
ReadBinaryProtoFunction · 0.85
DefaultFunction · 0.85
GetDebugOptionsFromFlagsFunction · 0.85
InteractiveDumpGraphsFunction · 0.85
emptyMethod · 0.45
NameMethod · 0.45
ExecutorForDeviceMethod · 0.45
RunHloPassesMethod · 0.45
RunBackendMethod · 0.45
moduleMethod · 0.45

Tested by

no test coverage detected