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

Method AddEagerFastPathExecute

tensorflow/python/framework/python_op_gen.cc:727–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

725}
726
727void GenEagerPythonOp::AddEagerFastPathExecute() {
728 string fastpath_execute_params = strings::StrCat(
729 "_ctx._context_handle, _ctx._thread_local_data.device_name, \"",
730 op_def_.name(), "\", ", "name, _ctx.post_execution_callbacks");
731 string fallback_params;
732
733 for (int i = 0; i < api_def_.in_arg_size(); i++) {
734 const string param_name = param_names_[i].GetRenameTo();
735 strings::StrAppend(&fastpath_execute_params, ", ", param_name);
736 if (!fallback_params.empty()) strings::StrAppend(&fallback_params, ", ");
737 strings::StrAppend(&fallback_params, param_name);
738 }
739
740 for (const auto& attr : api_def_.attr()) {
741 if (inferred_attrs_.find(attr.name()) == inferred_attrs_.end()) {
742 strings::StrAppend(&fastpath_execute_params, ", \"", attr.name(), "\", ",
743 attr.rename_to());
744
745 if (!fallback_params.empty()) strings::StrAppend(&fallback_params, ", ");
746 strings::StrAppend(&fallback_params, attr.rename_to(), "=",
747 attr.rename_to());
748 }
749 }
750
751 if (!fallback_params.empty()) strings::StrAppend(&fallback_params, ", ");
752 strings::StrAppend(&fallback_params, "name=name");
753
754 strings::StrAppend(&result_, " try:\n");
755 strings::StrAppend(
756 &result_, " ",
757 "_result = _pywrap_tensorflow.TFE_Py_FastPathExecute(\n",
758 WordWrap(strings::StrCat(" "),
759 strings::StrCat(fastpath_execute_params, ")"), kRightMargin),
760 "\n");
761
762 if (op_def_.output_arg_size() > 1) {
763 const string output_tuple_name =
764 strings::StrCat("_", op_def_.name(), "Output");
765 strings::StrAppend(&result_, " ", "_result = ", output_tuple_name,
766 "._make(_result)\n");
767 }
768 strings::StrAppend(&result_, " ", "return _result\n");
769
770 // Handle fallback.
771 if (!fallback_params.empty()) strings::StrAppend(&fallback_params, ", ");
772 strings::StrAppend(&fallback_params, "ctx=_ctx");
773 strings::StrAppend(&result_, " ", "except _core._FallbackException:\n");
774 strings::StrAppend(&result_, " try:\n");
775 strings::StrAppend(
776 &result_, " ", "return ", function_name_, kEagerFallbackSuffix,
777 "(\n",
778 WordWrap(strings::StrCat(" "),
779 strings::StrCat(fallback_params, ")"), kRightMargin),
780 "\n");
781 strings::StrAppend(&result_, " except _core._SymbolicException:\n");
782 strings::StrAppend(&result_,
783 " pass # Add nodes to the TensorFlow graph.\n");
784 AddDispatch(" ");

Callers

nothing calls this directly

Calls 9

WordWrapFunction · 0.85
GetRenameToMethod · 0.80
attrMethod · 0.80
nameMethod · 0.65
StrCatFunction · 0.50
StrAppendFunction · 0.50
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected