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

Method RunFunction

tensorflow/core/kernels/data/dataset_test_base.cc:452–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450}
451
452Status DatasetOpsTestBase::RunFunction(
453 const FunctionDef& fdef, test::function::Attrs attrs,
454 const std::vector<Tensor>& args,
455 const GraphConstructorOptions& graph_options, std::vector<Tensor*> rets) {
456 std::unique_ptr<Executor> exec;
457 InstantiationResult result;
458 auto GetOpSig = [](const string& op, const OpDef** sig) {
459 return OpRegistry::Global()->LookUpOpDef(op, sig);
460 };
461 TF_RETURN_IF_ERROR(InstantiateFunction(fdef, attrs, GetOpSig, &result));
462
463 DataTypeVector arg_types = result.arg_types;
464 DataTypeVector ret_types = result.ret_types;
465
466 std::unique_ptr<Graph> g(new Graph(OpRegistry::Global()));
467 TF_RETURN_IF_ERROR(
468 ConvertNodeDefsToGraph(graph_options, result.nodes, g.get()));
469
470 const int version = g->versions().producer();
471 LocalExecutorParams params;
472 params.function_library = flr_;
473 params.device = device_.get();
474 params.create_kernel = [this, version](const NodeDef& ndef,
475 OpKernel** kernel) {
476 return CreateNonCachedKernel(device_.get(), this->flr_, ndef, version,
477 kernel);
478 };
479 params.delete_kernel = [](OpKernel* kernel) {
480 DeleteNonCachedKernel(kernel);
481 };
482 params.rendezvous_factory = [](const int64, const DeviceMgr* device_mgr,
483 Rendezvous** r) {
484 *r = new IntraProcessRendezvous(device_mgr);
485 return Status::OK();
486 };
487
488 Executor* cur_exec;
489 TF_RETURN_IF_ERROR(NewLocalExecutor(params, std::move(g), &cur_exec));
490 exec.reset(cur_exec);
491 FunctionCallFrame frame(arg_types, ret_types);
492 TF_RETURN_IF_ERROR(frame.SetArgs(args));
493 Executor::Args exec_args;
494 exec_args.call_frame = &frame;
495 exec_args.runner = runner_;
496 exec_args.cost_runner = cost_runner_;
497 TF_RETURN_IF_ERROR(exec->Run(exec_args));
498 std::vector<Tensor> computed;
499 TF_RETURN_IF_ERROR(frame.GetRetvals(&computed));
500 if (computed.size() != rets.size()) {
501 return errors::InvalidArgument(
502 "The result does not match the expected number of return outpus",
503 ". Expected: ", rets.size(), ". Actual: ", computed.size());
504 }
505 for (int i = 0; i < rets.size(); ++i) {
506 *(rets[i]) = computed[i];
507 }
508 return Status::OK();
509}

Callers

nothing calls this directly

Calls 14

InstantiateFunctionFunction · 0.85
ConvertNodeDefsToGraphFunction · 0.85
CreateNonCachedKernelFunction · 0.85
DeleteNonCachedKernelFunction · 0.85
NewLocalExecutorFunction · 0.85
InvalidArgumentFunction · 0.85
LookUpOpDefMethod · 0.80
SetArgsMethod · 0.80
GetRetvalsMethod · 0.80
getMethod · 0.45
versionsMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected