Skip to content

Commit

Permalink
Avoid attempting variable equality checks implied by python in.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 590992962
  • Loading branch information
jamesmullenbach authored and tensorflower-gardener committed Dec 14, 2023
1 parent 39ac369 commit 5359b3c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tf_keras/optimizers/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,13 @@ def _trackable_children(self, save_type="checkpoint", **kwargs):
for var in val:
if hasattr(var, "_sharded_container"):
sv = var._sharded_container()
if sv not in sv_vals:
# Use unique id to check existence. `in` would
# attempt element-wise variable value
# comparison.
if not any(
sv._unique_id == other_sv._unique_id
for other_sv in sv_vals
):
sv_vals.append(sv)
else:
sv_vals.append(var)
Expand Down

0 comments on commit 5359b3c

Please sign in to comment.