Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
d1ed379e
"tests/pytorch/vscode:/vscode.git/clone" did not exist on "fa5ff2fceb1855c1e162dfb3a2bdb54fbc43c265"
Commit
d1ed379e
authored
Nov 19, 2021
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Nov 19, 2021
Browse files
Internal change
PiperOrigin-RevId: 411069186
parent
bd7732da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
official/common/distribute_utils_test.py
official/common/distribute_utils_test.py
+22
-0
No files found.
official/common/distribute_utils_test.py
View file @
d1ed379e
...
@@ -14,10 +14,13 @@
...
@@ -14,10 +14,13 @@
"""Tests for distribution util functions."""
"""Tests for distribution util functions."""
import
sys
import
tensorflow
as
tf
import
tensorflow
as
tf
from
official.common
import
distribute_utils
from
official.common
import
distribute_utils
TPU_TEST
=
'test_tpu'
in
sys
.
argv
[
0
]
class
DistributeUtilsTest
(
tf
.
test
.
TestCase
):
class
DistributeUtilsTest
(
tf
.
test
.
TestCase
):
"""Tests for distribute util functions."""
"""Tests for distribute util functions."""
...
@@ -51,6 +54,9 @@ class DistributeUtilsTest(tf.test.TestCase):
...
@@ -51,6 +54,9 @@ class DistributeUtilsTest(tf.test.TestCase):
self
.
assertIn
(
'GPU'
,
ds
.
extended
.
worker_devices
[
0
])
self
.
assertIn
(
'GPU'
,
ds
.
extended
.
worker_devices
[
0
])
def
test_mirrored_strategy
(
self
):
def
test_mirrored_strategy
(
self
):
# CPU only.
_
=
distribute_utils
.
get_distribution_strategy
(
num_gpus
=
0
)
# 5 GPUs.
ds
=
distribute_utils
.
get_distribution_strategy
(
num_gpus
=
5
)
ds
=
distribute_utils
.
get_distribution_strategy
(
num_gpus
=
5
)
self
.
assertEquals
(
ds
.
num_replicas_in_sync
,
5
)
self
.
assertEquals
(
ds
.
num_replicas_in_sync
,
5
)
self
.
assertEquals
(
len
(
ds
.
extended
.
worker_devices
),
5
)
self
.
assertEquals
(
len
(
ds
.
extended
.
worker_devices
),
5
)
...
@@ -78,10 +84,26 @@ class DistributeUtilsTest(tf.test.TestCase):
...
@@ -78,10 +84,26 @@ class DistributeUtilsTest(tf.test.TestCase):
self
.
assertIsInstance
(
self
.
assertIsInstance
(
ds
,
tf
.
distribute
.
experimental
.
MultiWorkerMirroredStrategy
)
ds
,
tf
.
distribute
.
experimental
.
MultiWorkerMirroredStrategy
)
with
self
.
assertRaisesRegex
(
ValueError
,
'When used with `multi_worker_mirrored`, valid values.*'
):
_
=
distribute_utils
.
get_distribution_strategy
(
'multi_worker_mirrored'
,
all_reduce_alg
=
'dummy'
)
def
test_no_strategy
(
self
):
def
test_no_strategy
(
self
):
ds
=
distribute_utils
.
get_distribution_strategy
(
'off'
)
ds
=
distribute_utils
.
get_distribution_strategy
(
'off'
)
self
.
assertIs
(
ds
,
tf
.
distribute
.
get_strategy
())
self
.
assertIs
(
ds
,
tf
.
distribute
.
get_strategy
())
def
test_tpu_strategy
(
self
):
if
not
TPU_TEST
:
self
.
skipTest
(
'Only Cloud TPU VM instances can have local TPUs.'
)
with
self
.
assertRaises
(
ValueError
):
_
=
distribute_utils
.
get_distribution_strategy
(
'tpu'
)
ds
=
distribute_utils
.
get_distribution_strategy
(
'tpu'
,
tpu_address
=
'local'
)
self
.
assertIsInstance
(
ds
,
tf
.
distribute
.
TPUStrategy
)
def
test_invalid_strategy
(
self
):
def
test_invalid_strategy
(
self
):
with
self
.
assertRaisesRegexp
(
with
self
.
assertRaisesRegexp
(
ValueError
,
ValueError
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment