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

Method AddOutputGlobals

tensorflow/python/framework/python_op_gen_internal.cc:771–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769}
770
771void GenPythonOp::AddOutputGlobals() {
772 // Prepare a NamedTuple type to hold the outputs, if there are multiple
773 if (num_outs_ > 1) {
774 // Prepare the list of output names
775 std::vector<string> out_names(num_outs_);
776 for (int i = 0; i < num_outs_; ++i) {
777 if (!api_def_.out_arg(i).rename_to().empty()) {
778 out_names[i] = api_def_.out_arg(i).rename_to();
779 } else {
780 out_names[i] = strings::StrCat("output", i);
781 }
782 }
783 string out_names_list =
784 strings::StrCat("[\"", absl::StrJoin(out_names, "\", \""), "\"]");
785
786 // Provide the output names as a Python list
787 string lower_op_name_outputs =
788 strings::StrCat("_", function_name_, "_outputs");
789 const string outputs_prefix = strings::StrCat(lower_op_name_outputs, " = ");
790 strings::StrAppend(&prelude_, "\n",
791 WordWrap(outputs_prefix, out_names_list, kRightMargin),
792 "\n");
793
794 strings::StrAppend(&prelude_, "_", op_def_.name(),
795 "Output = _collections.namedtuple(\n");
796 const string tuple_type_prefix = " ";
797 const string tuple_type_suffix = strings::StrCat(
798 "\"", op_def_.name(), "\", ", lower_op_name_outputs, ")");
799 strings::StrAppend(
800 &prelude_, WordWrap(tuple_type_prefix, tuple_type_suffix, kRightMargin),
801 "\n\n");
802 }
803 strings::StrAppend(&prelude_, "\n");
804}
805
806void GenPythonOp::AddDocStringOutputs() {
807 std::vector<string> output_type_string;

Callers

nothing calls this directly

Calls 5

WordWrapFunction · 0.85
nameMethod · 0.65
StrCatFunction · 0.50
StrAppendFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected