Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit 6d44045

Browse files
adarobMesh TensorFlow Team
authored andcommitted
Make mesh_tensorflow's call of get_replicated_var_handle backward-compatible with tf <= 2.8.0. Fixes google-research/text-to-text-transfer-transformer#1020.
PiperOrigin-RevId: 448301001
1 parent b631ad5 commit 6d44045

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

mesh_tensorflow/tpu_variables.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from __future__ import print_function
2121

2222
import contextlib
23+
import inspect
2324

2425
# pylint: disable=g-direct-tensorflow-import
2526
from tensorflow.python.framework import ops
@@ -82,9 +83,13 @@ def handle(self):
8283
if tpu_context is None:
8384
return self._primary_var.handle
8485

85-
# Using variable name as handle id.
86-
return tpu_context.get_replicated_var_handle(self._name, self._name,
87-
self._vars)
86+
# TODO(adarob): Remove backward-compatibility when TF 2.10 is released.
87+
if 'handle_id' not in inspect.signature(
88+
tpu_context.get_replicated_var_handle).parameters:
89+
return tpu_context.get_replicated_var_handle(
90+
name=self._name, vars_=self._vars)
91+
return tpu_context.get_replicated_var_handle(
92+
name=self._name, handle_id=self._name, vars_=self._vars)
8893

8994
@contextlib.contextmanager
9095
def _assign_dependencies(self):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='mesh-tensorflow',
8-
version='0.1.20',
8+
version='0.1.21',
99
description='Mesh TensorFlow',
1010
author='Google Inc.',
1111
author_email='[email protected]',

0 commit comments

Comments
 (0)