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

Method AsFunctionDefInput

tensorflow/core/grappler/utils/functions.cc:451–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449}
450
451Status MakeFunctionDefHelper::AsFunctionDefInput(const string& graph_def_input,
452 string* func_def_input) const {
453 if (IsControlInput(graph_def_input)) {
454 *func_def_input = graph_def_input;
455 return Status::OK();
456 }
457
458 const SafeTensorId tensor = ParseTensorName(graph_def_input);
459 DCHECK_GE(tensor.index(), 0);
460
461 // Graph def input corresponds to one of the function inputs.
462 const auto is_input = input_nodes_.find(tensor.node());
463 if (is_input != input_nodes_.end()) {
464 DCHECK_EQ(tensor.index(), 0);
465 *func_def_input = tensor.node();
466 return Status::OK();
467 }
468
469 // Or it must be output from one of the function body nodes
470 const auto is_body_output = function_body_outputs_.find(tensor.node());
471 if (is_body_output != function_body_outputs_.end()) {
472 const tensorflow::NameRangeMap& outputs_range_map = is_body_output->second;
473
474 for (const auto& el : outputs_range_map) {
475 const auto& output_name = el.first;
476 const auto& output_range = el.second;
477 if (tensor.index() >= output_range.first &&
478 tensor.index() < output_range.second) {
479 *func_def_input = absl::StrCat(tensor.node(), ":", output_name, ":",
480 tensor.index() - output_range.first);
481 return Status::OK();
482 }
483 }
484 }
485
486 return errors::InvalidArgument("Unknown graph def input: ", graph_def_input);
487}
488
489Status MakeFunctionDefHelper::AsFunctionDefNode(
490 NodeDef* function_body_node) const {

Callers 1

MakeFunctionDefFunction · 0.80

Calls 8

IsControlInputFunction · 0.85
ParseTensorNameFunction · 0.85
InvalidArgumentFunction · 0.85
StrCatFunction · 0.50
indexMethod · 0.45
findMethod · 0.45
nodeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected