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

Function GetPythonOps

tensorflow/python/framework/python_op_gen.cc:967–1088  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965}
966
967string GetPythonOps(const OpList& ops, const ApiDefMap& api_defs,
968 const std::vector<string>& hidden_ops, bool require_shapes,
969 const string& source_file_name = "") {
970 string result;
971 // Header
972 // TODO(josh11b): Mention the library for which wrappers are being generated.
973 strings::StrAppend(&result, R"("""Python wrappers around TensorFlow ops.
974
975This file is MACHINE GENERATED! Do not edit.
976)");
977
978 // Mention the original source file so someone tracing back through
979 // generated Python code will know where to look next.
980 if (!source_file_name.empty()) {
981 strings::StrAppend(&result, "Original C++ source file: ");
982 strings::StrAppend(&result, source_file_name);
983 strings::StrAppend(&result, "\n");
984 }
985
986 strings::StrAppend(&result, R"("""
987
988import collections as _collections
989import six as _six
990
991from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
992from tensorflow.python.eager import context as _context
993from tensorflow.python.eager import core as _core
994from tensorflow.python.eager import execute as _execute
995from tensorflow.python.framework import dtypes as _dtypes
996from tensorflow.python.framework import errors as _errors
997from tensorflow.python.framework import tensor_shape as _tensor_shape
998
999from tensorflow.core.framework import op_def_pb2 as _op_def_pb2
1000# Needed to trigger the call to _set_call_cpp_shape_fn.
1001from tensorflow.python.framework import common_shapes as _common_shapes
1002from tensorflow.python.framework import op_def_registry as _op_def_registry
1003from tensorflow.python.framework import ops as _ops
1004from tensorflow.python.framework import op_def_library as _op_def_library
1005from tensorflow.python.util.deprecation import deprecated_endpoints
1006from tensorflow.python.util import dispatch as _dispatch
1007from tensorflow.python.util.tf_export import tf_export
1008from tensorflow.python.util.tf_export import kwarg_only as _kwarg_only
1009from tensorflow.tools.docs import doc_controls as _doc_controls
1010
1011)");
1012
1013 // We'll make a copy of ops that filters out descriptions.
1014 OpList cleaned_ops;
1015 auto out = cleaned_ops.mutable_op();
1016 out->Reserve(ops.op_size());
1017 for (const auto& op_def : ops.op()) {
1018 const auto* api_def = api_defs.GetApiDef(op_def.name());
1019
1020 if (api_def->visibility() == ApiDef::SKIP) {
1021 continue;
1022 }
1023 // An op is hidden if either its ApiDef visibility is HIDDEN
1024 // or it is in the hidden_ops list.

Callers 2

PrintPythonOpsFunction · 0.85
GetPythonWrappersFunction · 0.85

Calls 15

GenerateLowerCaseOpNameFunction · 0.85
IsPythonReservedFunction · 0.85
IsOpWithUnderscorePrefixFunction · 0.85
GetEagerPythonOpFunction · 0.85
AppendfFunction · 0.85
CEscapeFunction · 0.85
GetApiDefMethod · 0.80
c_strMethod · 0.80
nameMethod · 0.65
StrAppendFunction · 0.50
StrCatFunction · 0.50

Tested by

no test coverage detected