| 965 | } |
| 966 | |
| 967 | string 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 | |
| 975 | This 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 | |
| 988 | import collections as _collections |
| 989 | import six as _six |
| 990 | |
| 991 | from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow |
| 992 | from tensorflow.python.eager import context as _context |
| 993 | from tensorflow.python.eager import core as _core |
| 994 | from tensorflow.python.eager import execute as _execute |
| 995 | from tensorflow.python.framework import dtypes as _dtypes |
| 996 | from tensorflow.python.framework import errors as _errors |
| 997 | from tensorflow.python.framework import tensor_shape as _tensor_shape |
| 998 | |
| 999 | from tensorflow.core.framework import op_def_pb2 as _op_def_pb2 |
| 1000 | # Needed to trigger the call to _set_call_cpp_shape_fn. |
| 1001 | from tensorflow.python.framework import common_shapes as _common_shapes |
| 1002 | from tensorflow.python.framework import op_def_registry as _op_def_registry |
| 1003 | from tensorflow.python.framework import ops as _ops |
| 1004 | from tensorflow.python.framework import op_def_library as _op_def_library |
| 1005 | from tensorflow.python.util.deprecation import deprecated_endpoints |
| 1006 | from tensorflow.python.util import dispatch as _dispatch |
| 1007 | from tensorflow.python.util.tf_export import tf_export |
| 1008 | from tensorflow.python.util.tf_export import kwarg_only as _kwarg_only |
| 1009 | from 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. |
no test coverage detected