| 636 | InstantiatedCapturedFunction::~InstantiatedCapturedFunction() {} |
| 637 | |
| 638 | Status InstantiatedCapturedFunction::Run(IteratorContext* ctx, |
| 639 | std::vector<Tensor>&& args, |
| 640 | std::vector<Tensor>* rets) const { |
| 641 | auto& info = captured_func_->short_circuit_info(); |
| 642 | if (!info.indices.empty()) { |
| 643 | return RunShortCircuit(info, std::move(args), captured_func_, rets); |
| 644 | } |
| 645 | |
| 646 | FunctionLibraryRuntime::Options f_opts; |
| 647 | ScopedStepContainer step_container( |
| 648 | f_opts.step_id, [this](const string& name) { |
| 649 | lib_->device()->resource_manager()->Cleanup(name).IgnoreError(); |
| 650 | }); |
| 651 | f_opts.step_container = &step_container; |
| 652 | f_opts.runner = ctx->runner(); |
| 653 | f_opts.create_rendezvous = ShouldCreateRendezvous(); |
| 654 | CancellationManager cancellation_manager; |
| 655 | f_opts.cancellation_manager = &cancellation_manager; |
| 656 | std::function<void()> deregister_fn; |
| 657 | TF_RETURN_IF_ERROR(ConnectCancellationManagers( |
| 658 | cancellation_manager_, &cancellation_manager, &deregister_fn)); |
| 659 | auto cleanup = gtl::MakeCleanup(std::move(deregister_fn)); |
| 660 | |
| 661 | OwnedArgsCallFrame frame(std::move(args), &captured_func_->captured_inputs(), |
| 662 | ret_types_); |
| 663 | Notification n; |
| 664 | Status s; |
| 665 | lib_->Run(f_opts, f_handle_, &frame, [&n, &s](Status func_status) { |
| 666 | s.Update(func_status); |
| 667 | n.Notify(); |
| 668 | }); |
| 669 | n.WaitForNotification(); |
| 670 | TF_RETURN_IF_ERROR(s); |
| 671 | return frame.ConsumeRetvals(rets); |
| 672 | } |
| 673 | |
| 674 | Status InstantiatedCapturedFunction::RunWithBorrowedArgs( |
| 675 | IteratorContext* ctx, const std::vector<Tensor>& args, |