aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/__init__.py')
-rw-r--r--tensorflow/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tensorflow/__init__.py b/tensorflow/__init__.py
index 4fc5d8e816..ec7cd91e7e 100644
--- a/tensorflow/__init__.py
+++ b/tensorflow/__init__.py
@@ -21,3 +21,18 @@ from __future__ import division
from __future__ import print_function
from tensorflow.python import *
+
+
+# Lazily import the `tf.contrib` module. This avoids loading all of the
+# dependencies of `tf.contrib` at `import tensorflow` time.
+class _LazyContribLoader(object):
+
+ def __getattr__(self, item):
+ global contrib
+ # Replace the lazy loader with the imported module itself.
+ import importlib # pylint: disable=g-import-not-at-top
+ contrib = importlib.import_module('tensorflow.contrib')
+ return getattr(contrib, item)
+
+
+contrib = _LazyContribLoader()