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

Method ExecuteGraphParallel

tensorflow/compiler/xla/service/service.cc:632–777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632Status Service::ExecuteGraphParallel(const ExecuteGraphParallelRequest* arg,
633 ExecuteParallelResponse* result) {
634 VLOG(1) << "running execute-graph-parallel request";
635
636 std::vector<std::vector<std::vector<const ShapedBuffer*>>> all_arguments;
637 std::vector<std::vector<se::StreamExecutor*>> all_executors;
638 std::vector<const HloModuleProto*> module_protos;
639 std::vector<std::unique_ptr<HloModuleConfig>> module_configs;
640 std::vector<string> computation_names;
641 std::vector<DeviceHandle> device_handles;
642
643 int num_requested_devices =
644 std::accumulate(arg->requests().begin(), arg->requests().end(), 0,
645 [](int a, const ExecuteGraphRequest& r) -> int {
646 return a + r.execution_options().device_handles_size();
647 });
648 if (num_requested_devices * options_.number_of_replicas() >
649 execute_backend_->device_count()) {
650 return FailedPrecondition(
651 "there are not enough stream executors to execute %d computations",
652 num_requested_devices);
653 }
654
655 for (int64 i = 0; i < arg->requests_size(); ++i) {
656 // Get the stream executor for the i'th computation. This stream executor
657 // is one of the executors to run the replicated computation.
658 const ExecutionOptions& execution_options =
659 arg->requests(i).execution_options();
660 const ExecuteGraphRequest& request = arg->requests(i);
661 TF_RET_CHECK(request.has_computation()) << "computations may not be empty";
662 TF_RET_CHECK(request.computation().has_host_program_shape())
663 << "program shape may not be empty";
664
665 // Get the executors.
666 TF_ASSIGN_OR_RETURN(auto executors, GetExecutors(execution_options,
667 arg->requests_size(), i));
668
669 // Get the replicated arguments.
670 TF_ASSIGN_OR_RETURN(auto replicated_arguments,
671 GetArguments(execution_options, request.arguments()));
672
673 // Create an HloModuleConfig object for the computation, given the shape of
674 // the program and the argument allocations. Here, we care only about the
675 // shapes of the arguments, so, it is sufficient to use the arguments of
676 // replica 0.
677 TF_ASSIGN_OR_RETURN(
678 std::unique_ptr<HloModuleConfig> module_config,
679 CreateModuleConfig(
680 ProgramShape{request.computation().host_program_shape()},
681 replicated_arguments.front(), request.execution_options()));
682 VLOG(3)
683 << "ExecuteGraphParallel created HloModuleConfig computation layout: "
684 << module_config->entry_computation_layout().ToString();
685
686 // Adds to the vectors to build and execute the computations after the loop.
687 all_arguments.push_back(replicated_arguments);
688 all_arguments.insert(all_arguments.end(), executors.size() - 1, {{}});
689 module_protos.push_back(&request.computation());

Callers

nothing calls this directly

Calls 15

FailedPreconditionFunction · 0.85
RecordArgumentsFunction · 0.85
RecordResultFunction · 0.85
DumpHloSnapshotIfEnabledFunction · 0.85
dumping_snapshotMethod · 0.80
hlo_protoMethod · 0.80
TF_ASSIGN_OR_RETURNFunction · 0.70
nameMethod · 0.65
mutable_outputMethod · 0.60
beginMethod · 0.45
endMethod · 0.45
number_of_replicasMethod · 0.45

Tested by

no test coverage detected