Fix constructor of CommunicationOptions
Fix #44768 PiperOrigin-RevId: 341888489 Change-Id: I625f2e5412a217a95e3306fc6345f378b932071b
This commit is contained in:
parent
303958a211
commit
659aca25da
tensorflow/python/distribute
@ -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,
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user