aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/ops/variable_scope.py
diff options
context:
space:
mode:
authorGravatar Akshay Agrawal <akshayka@google.com>2018-01-10 13:08:52 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-10 13:14:34 -0800
commit47e06b7e53963cc45ee236cf86cc089185f47d32 (patch)
tree46c29753e626ac4b5fb19e2193027eb80f7a9020 /tensorflow/python/ops/variable_scope.py
parent3dc58f798660b98a0198b33edefb6f9f2aa7d827 (diff)
Support nesting EagerTemplate objects.
* Nesting is implemented by sharing a single EagerVariableStore among a top-level EagerTemplate and all children EagerTemplate objects that are nested underneath it. Variables added to an EagerTemplate object are also added to all EagerTemplate objects under which it is nested. * This change also simplifies the implementation of __call__ for both Template and EagerTemplate. PiperOrigin-RevId: 181506600
Diffstat (limited to 'tensorflow/python/ops/variable_scope.py')
-rw-r--r--tensorflow/python/ops/variable_scope.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tensorflow/python/ops/variable_scope.py b/tensorflow/python/ops/variable_scope.py
index e46ff529de..411d45ca1c 100644
--- a/tensorflow/python/ops/variable_scope.py
+++ b/tensorflow/python/ops/variable_scope.py
@@ -1217,8 +1217,15 @@ class EagerVariableStore(object):
```
"""
- def __init__(self):
- self._store = _VariableStore()
+ def __init__(self, store=None):
+ if store is not None:
+ if not store._store_eager_variables: # pylint: disable=protected-access
+ raise ValueError("Cannot construct EagerVariableStore from a "
+ "VariableStore object that does not hold eager "
+ "variables.")
+ self._store = store
+ else:
+ self._store = _VariableStore()
self._store._store_eager_variables = True # pylint: disable=protected-access
def as_default(self):