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
cd85fd8a
Commit
cd85fd8a
authored
Aug 16, 2019
by
Hongkun Yu
Committed by
A. Unique TensorFlower
Aug 16, 2019
Browse files
Use get_primary_cpu_task from tpu_lib
PiperOrigin-RevId: 263874363
parent
b1d9ac5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
9 deletions
+3
-9
official/bert/model_training_utils.py
official/bert/model_training_utils.py
+2
-8
official/bert/run_classifier.py
official/bert/run_classifier.py
+1
-1
No files found.
official/bert/model_training_utils.py
View file @
cd85fd8a
...
...
@@ -25,18 +25,12 @@ from absl import logging
import
tensorflow
as
tf
from
tensorflow.python.util
import
object_identity
from
official.utils.misc
import
distribution_utils
from
official.utils.misc
import
tpu_lib
_SUMMARY_TXT
=
'training_summary.txt'
_MIN_SUMMARY_STEPS
=
10
def
get_primary_cpu_task
(
use_remote_tpu
=
False
):
"""Returns primary CPU task to which input pipeline Ops are put."""
# Remote Eager Borg job configures the TPU worker with job name 'worker'.
return
'/job:worker'
if
use_remote_tpu
else
''
def
_save_checkpoint
(
checkpoint
,
model_dir
,
checkpoint_prefix
):
"""Saves model to with provided checkpoint prefix."""
...
...
@@ -195,7 +189,7 @@ def run_customized_training_loop(
# To reduce unnecessary send/receive input pipeline operation, we place input
# pipeline ops in worker task.
with
tf
.
device
(
get_primary_cpu_task
(
use_remote_tpu
)):
with
tf
.
device
(
tpu_lib
.
get_primary_cpu_task
(
use_remote_tpu
)):
train_iterator
=
_get_input_iterator
(
train_input_fn
,
strategy
)
with
distribution_utils
.
get_strategy_scope
(
strategy
):
...
...
official/bert/run_classifier.py
View file @
cd85fd8a
...
...
@@ -210,7 +210,7 @@ def run_bert(strategy, input_meta_data):
run_eagerly
=
FLAGS
.
run_eagerly
)
if
FLAGS
.
model_export_path
:
with
tf
.
device
(
model_training_utils
.
get_primary_cpu_task
(
use_remote_tpu
)):
with
tf
.
device
(
tpu_lib
.
get_primary_cpu_task
(
use_remote_tpu
)):
model_saving_utils
.
export_bert_model
(
FLAGS
.
model_export_path
,
model
=
trained_model
)
return
trained_model
...
...
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