MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RunFunction

Method RunFunction

tensorflow/core/kernels/partitioned_function_ops.cc:226–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void PartitionedCallOp::RunFunction(FunctionLibraryRuntime::Handle handle,
227 const std::vector<Tensor>& inputs,
228 FunctionLibraryRuntime* lib,
229 OpKernelContext* ctx, DoneCallback done) {
230 FunctionLibraryRuntime::Options run_opts;
231 ResourceMgr* resource_mgr = lib->device()->resource_manager();
232 ScopedStepContainer* step_container = new ScopedStepContainer(
233 run_opts.step_id, [resource_mgr](const string& name) {
234 resource_mgr->Cleanup(name).IgnoreError();
235 });
236 run_opts.step_container = step_container;
237 run_opts.cancellation_manager = ctx->cancellation_manager();
238 run_opts.stats_collector = ctx->stats_collector();
239 run_opts.collective_executor = ctx->collective_executor();
240 // TODO(akshayka): Consider selecting a runner on a per-device basis,
241 // i.e., using device-specific threadpools when available.
242 run_opts.runner = ctx->runner();
243 run_opts.source_device =
244 lib->device() == nullptr ? "" : lib->device()->name();
245 run_opts.allow_dead_tensors = true;
246
247 Rendezvous* rendez;
248 OP_REQUIRES_OK_ASYNC(
249 ctx,
250 ctx->create_rendezvous(run_opts.step_id,
251 ctx->function_library()->device_mgr(), &rendez),
252 done);
253 run_opts.rendezvous = rendez;
254
255 std::vector<Tensor>* rets = new std::vector<Tensor>;
256 const string& func_name = func_->name();
257 profiler::TraceMe trace_me(
258 [&] {
259 return absl::StrCat(
260 "PartitionedCallOp #parent_step_id=", ctx->step_id(),
261 ",function_step_id=", run_opts.step_id, "#");
262 },
263 /*level=*/2);
264 lib->Run(run_opts, handle, inputs, rets,
265 [rets, rendez, done, ctx, func_name,
266 step_container](const Status& status) {
267 if (!status.ok()) {
268 const string function_and_msg =
269 strings::StrCat(errors::FormatFunctionForError(func_name),
270 " ", status.error_message());
271 ctx->SetStatus(Status(status.code(), function_and_msg));
272 } else {
273 for (int i = 0; i < rets->size(); ++i) {
274 ctx->set_output(i, (*rets)[i]);
275 }
276 }
277 delete rets;
278 delete step_container;
279 rendez->Unref();
280 done();
281 });
282}
283

Callers

nothing calls this directly

Calls 15

FormatFunctionForErrorFunction · 0.85
stats_collectorMethod · 0.80
collective_executorMethod · 0.80
create_rendezvousMethod · 0.80
StatusClass · 0.70
nameMethod · 0.65
StrCatFunction · 0.50
resource_managerMethod · 0.45
deviceMethod · 0.45
IgnoreErrorMethod · 0.45
CleanupMethod · 0.45
cancellation_managerMethod · 0.45

Tested by

no test coverage detected