Add colocation back for optimizer v2.
PiperOrigin-RevId: 259403870
This commit is contained in:
parent
e547d262a5
commit
f8c912d2b7
@ -474,9 +474,12 @@ class OptimizerV2(trackable.Trackable):
|
|||||||
update_ops = []
|
update_ops = []
|
||||||
with backend.name_scope(name or self._name):
|
with backend.name_scope(name or self._name):
|
||||||
for grad, var in grads_and_vars:
|
for grad, var in grads_and_vars:
|
||||||
scope_name = ("" if ops.executing_eagerly_outside_functions() else
|
scope_name = ("update" if ops.executing_eagerly_outside_functions() else
|
||||||
"_" + var.op.name)
|
"update_" + var.op.name)
|
||||||
with backend.name_scope("update" + scope_name):
|
# Colocate the update with variables to avoid unnecessary communication
|
||||||
|
# delays. See b/136304694.
|
||||||
|
with backend.name_scope(
|
||||||
|
scope_name), distribution.extended.colocate_vars_with(var):
|
||||||
update_ops.extend(
|
update_ops.extend(
|
||||||
distribution.extended.update(
|
distribution.extended.update(
|
||||||
var, apply_grad_to_update_var, args=(grad,), group=False))
|
var, apply_grad_to_update_var, args=(grad,), group=False))
|
||||||
|
Loading…
Reference in New Issue
Block a user