| 133 | } |
| 134 | |
| 135 | void TensorProducerImpl::Produce(const TensorGenerator::Consumer& consumer) { |
| 136 | TensorProducerContext* ctx = new TensorProducerContext; |
| 137 | ctx->frame.reset(new TensorProducerCallFrame); |
| 138 | ctx->f_opts.reset(new FunctionLibraryRuntime::Options); |
| 139 | ctx->step_container.reset(new ScopedStepContainer( |
| 140 | ctx->f_opts->step_id, [this](const string& name) { |
| 141 | lib_->device()->resource_manager()->Cleanup(name).IgnoreError(); |
| 142 | })); |
| 143 | ctx->f_opts->step_container = ctx->step_container.get(); |
| 144 | ctx->f_opts->runner = &runner_; |
| 145 | ctx->cancellation_manager.reset(new CancellationManager); |
| 146 | ctx->f_opts->cancellation_manager = ctx->cancellation_manager.get(); |
| 147 | CancellationManager c_mgr; |
| 148 | ctx->f_opts->cancellation_manager = &c_mgr; |
| 149 | |
| 150 | Ref(); |
| 151 | lib_->Run(*ctx->f_opts, f_handle_, ctx->frame.get(), |
| 152 | [this, ctx, consumer] (const Status& st) { |
| 153 | consumer(st, ctx->frame->GetRet()); |
| 154 | delete ctx; |
| 155 | Unref(); |
| 156 | }); |
| 157 | } |
| 158 | |
| 159 | } // namespace |
| 160 |
no test coverage detected