| 584 | |
| 585 | template <class PropagatorStateType> |
| 586 | void ExecutorState<PropagatorStateType>::RunAsync(Executor::DoneCallback done) { |
| 587 | MaybeCollectKernelStats(); |
| 588 | |
| 589 | TaggedNodeSeq ready; |
| 590 | |
| 591 | // Ask the device to fill in the device context map. |
| 592 | Device* device = immutable_state_.params().device; |
| 593 | const Status get_context_status = |
| 594 | device->TryGetDeviceContext(&device_context_); |
| 595 | if (!get_context_status.ok()) { |
| 596 | delete this; |
| 597 | done(get_context_status); |
| 598 | return; |
| 599 | } |
| 600 | |
| 601 | // Initialize the ready queue. |
| 602 | ready.reserve(immutable_state_.root_nodes().size()); |
| 603 | propagator_.ActivateRoots(immutable_state_.root_nodes(), &ready); |
| 604 | num_outstanding_ops_ = ready.size(); |
| 605 | if (ready.empty()) { |
| 606 | delete this; |
| 607 | done(Status::OK()); |
| 608 | } else { |
| 609 | done_cb_ = std::move(done); |
| 610 | // Schedule to run all the ready ops in thread pool. |
| 611 | ScheduleReady(&ready, nullptr); |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | // State kept alive for executing an asynchronous node in another |
| 616 | // thread. NOTE: We need to make a copy of p.input and p.input_alloc_attrs for |
no test coverage detected