Skip to content

Commit 722d9e5

Browse files
saberkuntensorflower-gardener
authored andcommitted
Clearly demarcate contrib symbols from standard tf symbols by importing them directly.
PiperOrigin-RevId: 285618209
1 parent e5c71d5 commit 722d9e5

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

official/recommendation/neumf_model.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def neumf_model_fn(features, labels, mode, params):
115115
beta2=params["beta2"],
116116
epsilon=params["epsilon"])
117117
if params["use_tpu"]:
118-
# TODO(seemuch): remove this contrib import
119-
optimizer = tf.contrib.tpu.CrossShardOptimizer(optimizer)
118+
optimizer = tf.compat.v1.tpu.CrossShardOptimizer(optimizer)
120119

121120
mlperf_helper.ncf_print(key=mlperf_helper.TAGS.MODEL_HP_LOSS_FN,
122121
value=mlperf_helper.TAGS.BCE)
@@ -274,7 +273,7 @@ def _get_estimator_spec_with_metrics(logits, # type: tf.Tensor
274273
use_tpu_spec)
275274

276275
if use_tpu_spec:
277-
return tf.contrib.tpu.TPUEstimatorSpec(
276+
return tf.estimator.tpu.TPUEstimatorSpec(
278277
mode=tf.estimator.ModeKeys.EVAL,
279278
loss=cross_entropy,
280279
eval_metrics=(metric_fn, [in_top_k, ndcg, metric_weights]))

official/utils/misc/distribution_utils.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -283,29 +283,13 @@ def set_up_synthetic_data():
283283
_monkey_patch_dataset_method(tf.distribute.MirroredStrategy)
284284
_monkey_patch_dataset_method(
285285
tf.distribute.experimental.MultiWorkerMirroredStrategy)
286-
# TODO(tobyboyd): Remove when contrib.distribute is all in core.
287-
if hasattr(tf, 'contrib'):
288-
_monkey_patch_dataset_method(tf.contrib.distribute.MirroredStrategy)
289-
_monkey_patch_dataset_method(tf.contrib.distribute.OneDeviceStrategy)
290-
_monkey_patch_dataset_method(
291-
tf.contrib.distribute.CollectiveAllReduceStrategy)
292-
else:
293-
print('Contrib missing: Skip monkey patch tf.contrib.distribute.*')
294286

295287

296288
def undo_set_up_synthetic_data():
297289
_undo_monkey_patch_dataset_method(tf.distribute.OneDeviceStrategy)
298290
_undo_monkey_patch_dataset_method(tf.distribute.MirroredStrategy)
299291
_undo_monkey_patch_dataset_method(
300292
tf.distribute.experimental.MultiWorkerMirroredStrategy)
301-
# TODO(tobyboyd): Remove when contrib.distribute is all in core.
302-
if hasattr(tf, 'contrib'):
303-
_undo_monkey_patch_dataset_method(tf.contrib.distribute.MirroredStrategy)
304-
_undo_monkey_patch_dataset_method(tf.contrib.distribute.OneDeviceStrategy)
305-
_undo_monkey_patch_dataset_method(
306-
tf.contrib.distribute.CollectiveAllReduceStrategy)
307-
else:
308-
print('Contrib missing: Skip remove monkey patch tf.contrib.distribute.*')
309293

310294

311295
def configure_cluster(worker_hosts=None, task_index=-1):

0 commit comments

Comments
 (0)