aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-04-05 05:39:21 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-04-05 05:42:54 -0700
commit361a13cf0c2b65d26f6e2b5b68875adfcea98dd0 (patch)
tree72bab20a90d24e973a1593daa0a3c1bb8acc498a
parent1fda7645d132b71b9084b01945795e97e582adcd (diff)
Create a separate operators module that is to contain all Python constructs that we override: control flow, builtins, operators, etc.
PiperOrigin-RevId: 191729654
-rw-r--r--tensorflow/contrib/autograph/impl/BUILD1
-rw-r--r--tensorflow/contrib/autograph/impl/config.py17
-rw-r--r--tensorflow/contrib/autograph/operators/BUILD25
-rw-r--r--tensorflow/contrib/autograph/operators/__init__.py24
4 files changed, 61 insertions, 6 deletions
diff --git a/tensorflow/contrib/autograph/impl/BUILD b/tensorflow/contrib/autograph/impl/BUILD
index 0de479741a..54424e2647 100644
--- a/tensorflow/contrib/autograph/impl/BUILD
+++ b/tensorflow/contrib/autograph/impl/BUILD
@@ -26,6 +26,7 @@ py_library(
visibility = ["//tensorflow:__subpackages__"],
deps = [
"//tensorflow/contrib/autograph/converters",
+ "//tensorflow/contrib/autograph/operators",
"//tensorflow/contrib/autograph/pyct",
"//tensorflow/contrib/autograph/pyct/static_analysis",
"//tensorflow/contrib/autograph/utils",
diff --git a/tensorflow/contrib/autograph/impl/config.py b/tensorflow/contrib/autograph/impl/config.py
index 543c1486e6..26326465e2 100644
--- a/tensorflow/contrib/autograph/impl/config.py
+++ b/tensorflow/contrib/autograph/impl/config.py
@@ -41,10 +41,15 @@ DEFAULT_UNCOMPILED_MODULES = set((
NO_SIDE_EFFECT_CONSTRUCTORS = set(('tensorflow',))
-# TODO(mdan): Also allow controlling the generated names (for testability).
+# TODO(mdan): Also allow controlling the generated names.
+# TODO(mdan); Consolidate all internal imports into a single __ag module.
COMPILED_IMPORT_STATEMENTS = (
- 'from __future__ import print_function', 'import tensorflow as tf',
- 'from tensorflow.contrib.autograph.impl import api as '
- 'autograph_api',
- 'from tensorflow.contrib.autograph import utils as '
- 'autograph_utils')
+ 'from __future__ import print_function',
+ 'import tensorflow as tf',
+ 'from tensorflow.contrib.autograph.impl import api'
+ ' as autograph_api',
+ 'from tensorflow.contrib.autograph import utils'
+ ' as autograph_utils',
+ 'from tensorflow.contrib.autograph import operators'
+ ' as __ops',
+)
diff --git a/tensorflow/contrib/autograph/operators/BUILD b/tensorflow/contrib/autograph/operators/BUILD
new file mode 100644
index 0000000000..7856c253bd
--- /dev/null
+++ b/tensorflow/contrib/autograph/operators/BUILD
@@ -0,0 +1,25 @@
+licenses(["notice"]) # Apache 2.0
+
+exports_files(["LICENSE"])
+
+filegroup(
+ name = "all_files",
+ srcs = glob(
+ ["**/*"],
+ exclude = [
+ "**/METADATA",
+ "**/OWNERS",
+ ],
+ ),
+ visibility = ["//tensorflow:__subpackages__"],
+)
+
+py_library(
+ name = "operators",
+ srcs = [
+ "__init__.py",
+ ],
+ srcs_version = "PY2AND3",
+ visibility = ["//tensorflow:__subpackages__"],
+ deps = [],
+)
diff --git a/tensorflow/contrib/autograph/operators/__init__.py b/tensorflow/contrib/autograph/operators/__init__.py
new file mode 100644
index 0000000000..c3f4cab69e
--- /dev/null
+++ b/tensorflow/contrib/autograph/operators/__init__.py
@@ -0,0 +1,24 @@
+# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
+"""This module implements operators that we overload.
+
+Note that "operator" is used loosely here, and includes control structures like
+conditionals and loops, implemented in functional form, using for example
+closures for the body.
+"""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function