Fix constructor of CommunicationOptions

Fix 

PiperOrigin-RevId: 341888489
Change-Id: I625f2e5412a217a95e3306fc6345f378b932071b
This commit is contained in:
Ran Chen 2020-11-11 12:37:55 -08:00 committed by TensorFlower Gardener
parent 303958a211
commit 659aca25da
2 changed files with 9 additions and 2 deletions
tensorflow/python/distribute

View File

@ -81,7 +81,11 @@ class _OptionsExported(object):
"""
def __new__(cls, *args, **kwargs):
return Options.__new__(Options, *args, **kwargs)
# We expose a dummy class so that we can separate internal and public APIs.
# Note that __init__ won't be called on the returned object if it's a
# different class [1].
# [1] https://docs.python.org/3/reference/datamodel.html#object.__new__
return Options(*args, **kwargs)
def __init__(self,
bytes_per_pack=0,

View File

@ -25,8 +25,11 @@ from tensorflow.python.eager import test
class OptionsTest(test.TestCase):
def testCreateOptionsViaExportedAPI(self):
options = collective_util._OptionsExported()
options = collective_util._OptionsExported(bytes_per_pack=1)
self.assertIsInstance(options, collective_util.Options)
self.assertEqual(options.bytes_per_pack, 1)
with self.assertRaises(ValueError):
collective_util._OptionsExported(bytes_per_pack=-1)
def testCreateOptionsViaHints(self):
with self.assertLogs() as cm: