| 360 | } |
| 361 | |
| 362 | StatusOr<std::vector<std::unique_ptr<Executable>>> Service::BuildExecutables( |
| 363 | const std::vector<const HloModuleProto*>& module_protos, |
| 364 | std::vector<std::unique_ptr<HloModuleConfig>> module_configs, |
| 365 | Backend* backend, std::vector<std::vector<se::StreamExecutor*>> executors, |
| 366 | se::DeviceMemoryAllocator* device_allocator) { |
| 367 | VLOG(1) << StrFormat("BuildExecutable on service %p", this); |
| 368 | |
| 369 | // Dump computation proto state if flag is set. |
| 370 | std::vector<std::unique_ptr<HloProto>> hlo_protos; |
| 371 | for (int64 i = 0; i < module_protos.size(); ++i) { |
| 372 | auto hlo_proto = absl::make_unique<HloProto>(); |
| 373 | *hlo_proto->mutable_hlo_module() = *module_protos[i]; |
| 374 | hlo_protos.push_back(std::move(hlo_proto)); |
| 375 | } |
| 376 | |
| 377 | VLOG(1) << "Computations:"; |
| 378 | for (const HloModuleProto* proto : module_protos) { |
| 379 | VLOG(1) << proto->name(); |
| 380 | } |
| 381 | |
| 382 | CHECK_EQ(module_protos.size(), module_configs.size()); |
| 383 | auto module_group = |
| 384 | absl::make_unique<HloModuleGroup>(module_protos[0]->name()); |
| 385 | for (int64 i = 0; i < module_protos.size(); ++i) { |
| 386 | const HloModuleProto* proto = module_protos[i]; |
| 387 | const HloModuleConfig& config = *module_configs[i]; |
| 388 | TF_ASSIGN_OR_RETURN(auto module, CreateModuleFromProto(*proto, config)); |
| 389 | DumpHloModuleIfEnabled(*module, kBeforeOptimizationsDumpName); |
| 390 | module_group->push_back(std::move(module)); |
| 391 | } |
| 392 | |
| 393 | TF_ASSIGN_OR_RETURN( |
| 394 | std::vector<std::unique_ptr<Executable>> executables, |
| 395 | backend->compiler()->Compile(std::move(module_group), |
| 396 | std::move(executors), device_allocator)); |
| 397 | |
| 398 | for (size_t i = 0; i < module_protos.size(); ++i) { |
| 399 | const auto& debug_opts = module_configs[i]->debug_options(); |
| 400 | if (DumpingEnabledForHloModule(module_protos[i]->name(), debug_opts) && |
| 401 | debug_opts.xla_dump_hlo_snapshots()) { |
| 402 | executables[i]->set_hlo_proto(std::move(hlo_protos[i])); |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | return std::move(executables); |
| 407 | } |
| 408 | |
| 409 | StatusOr<std::vector<GlobalDataHandle>> |
| 410 | Service::ExecuteParallelAndRegisterResult( |
nothing calls this directly
no test coverage detected