Skip to content

Commit 3bdda3f

Browse files
lingvo-botcopybara-github
authored andcommitted
Prepare for update to python3.10
PiperOrigin-RevId: 487889252
1 parent 0ca2767 commit 3bdda3f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lingvo/core/checkpointer_eager_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def testEagerEMACheckpointCompatibility(self):
116116
eager_v2_logdir = os.path.join(self.get_temp_dir(), 'eager_v2')
117117
mdl = cfg.Instantiate()
118118

119-
@tf.function
119+
@tf.function(autograph=False)
120120
def _Update():
121121
with py_utils.GradientTape(persistent=True):
122122
mdl.ConstructFPropBPropGraph()
@@ -207,7 +207,7 @@ def testEagerCheckpointConsumptionCheck(self):
207207
eager_v2_logdir = os.path.join(self.get_temp_dir(), 'eager_v2')
208208
mdl = cfg.Instantiate()
209209

210-
@tf.function
210+
@tf.function(autograph=False)
211211
def _Update():
212212
with py_utils.GradientTape(persistent=True):
213213
mdl.ConstructFPropBPropGraph()

lingvo/core/layers_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5730,6 +5730,9 @@ class DeterministicDropoutTest(test_utils.TestCase, parameterized.TestCase):
57305730
def testDeterministicDropoutLayer(self):
57315731

57325732
with self.session(graph=tf.Graph()):
5733+
# Explicitly reset step seed as `self.session(graph=tf.Graph())` does not
5734+
# reset the default graph id in Eager mode.
5735+
py_utils.ResetStepSeed()
57335736
tf.random.set_seed(12345)
57345737
params = layers.DeterministicDropoutLayer.Params().Set(
57355738
name='drop', keep_prob=0.7)
@@ -5758,6 +5761,9 @@ def testDeterministicDropoutLayer(self):
57585761
with contextlib.ExitStack() as context_stack:
57595762
g = _ResetTfStatus(self, context_stack)
57605763
with self.session(graph=g):
5764+
# Explicitly reset step seed as `self.session(graph=tf.Graph())` does not
5765+
# reset the default graph id in Eager mode.
5766+
py_utils.ResetStepSeed()
57615767
tf.random.set_seed(12345)
57625768
params = layers.DeterministicDropoutLayer.Params().Set(
57635769
name='drop', keep_prob=0.7)

lingvo/core/optimizer_eager_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _Apply1(proj_layer, opt):
151151
# Get `snapshots` of the variables
152152
vars2 = [v.read_value() for v in proj_layer.vars.Flatten()]
153153

154-
@tf.function
154+
@tf.function(autograph=False)
155155
def _Apply2(proj_layer, opt):
156156
inputs1 = np_input1
157157
output1 = proj_layer.FPropDefaultTheta(inputs1, in_padding1)

0 commit comments

Comments
 (0)