TODO(suharshs): Add stats collection support to partial run.
| 270 | |
| 271 | // TODO(suharshs): Add stats collection support to partial run. |
| 272 | void Worker::DoPartialRunGraph(CallOptions* opts, |
| 273 | RunGraphRequestWrapper* request, |
| 274 | MutableRunGraphResponseWrapper* response, |
| 275 | StatusCallback done) { |
| 276 | const int64 step_id = request->step_id(); |
| 277 | const string& graph_handle = request->graph_handle(); |
| 278 | TRACEPRINTF("PartialRunGraph: %lld", step_id); |
| 279 | Status s = recent_request_ids_.TrackUnique( |
| 280 | request->request_id(), "PartialRunGraph (Worker)", request); |
| 281 | if (!s.ok()) { |
| 282 | done(s); |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | std::shared_ptr<WorkerSession> session; |
| 287 | if (request->create_worker_session_called()) { |
| 288 | s = env_->session_mgr->WorkerSessionForSession(request->session_handle(), |
| 289 | &session); |
| 290 | } else { |
| 291 | session = env_->session_mgr->LegacySession(); |
| 292 | } |
| 293 | if (!s.ok()) { |
| 294 | done(s); |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | std::map<std::string, bool> is_send_dead; |
| 299 | GraphMgr::NamedTensors in; |
| 300 | GraphMgr::NamedTensors* out = new GraphMgr::NamedTensors; |
| 301 | s = PrepareRunGraph(request, &in, out); |
| 302 | // NOTE(jiankeng.pt): tensor in worker side is not dead. |
| 303 | for (size_t i = 0; i < request->num_sends(); ++i) { |
| 304 | is_send_dead.insert({request->send_key(i), false}); |
| 305 | } |
| 306 | auto finish = [done, out, opts](const Status& s) { |
| 307 | opts->ClearCancelCallback(); |
| 308 | delete out; |
| 309 | done(s); |
| 310 | }; |
| 311 | if (!s.ok()) { |
| 312 | finish(s); |
| 313 | return; |
| 314 | } |
| 315 | |
| 316 | CancellationManager* cm = nullptr; |
| 317 | bool is_new_partial_run = partial_run_mgr_.FindOrCreate(step_id, &cm); |
| 318 | |
| 319 | // Before we start doing anything, we set the RPC cancellation. |
| 320 | opts->SetCancelCallback([this, cm, step_id]() { |
| 321 | LOG(INFO) << "Cancellation requested for PartialRunGraph."; |
| 322 | cm->StartCancel(); |
| 323 | AbortStep(step_id); |
| 324 | }); |
| 325 | |
| 326 | // If this is a new partial run request, the request will need to start the |
| 327 | // executors. |
| 328 | if (is_new_partial_run) { |
| 329 | CancellationToken token; |
nothing calls this directly
no test coverage detected