Skip to content

Commit 29d9b46

Browse files
authored
[Op] Canonicalize SaveV2 Op device spec in distributed training. (#925)
Signed-off-by: 泊霆 <hujunqi.hjq@alibaba-inc.com>
1 parent fc4f9f5 commit 29d9b46

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tensorflow/python/training/saver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,12 @@ def _GroupByDevices(self, saveables):
550550
"""
551551
per_device = collections.defaultdict(lambda: [])
552552
for saveable in saveables:
553-
canonical_device = set(
554-
pydev.canonical_name(spec.tensor.device) for spec in saveable.specs)
553+
canonical_device = set()
554+
for spec in saveable.specs:
555+
device_name = pydev.canonical_name(spec.tensor.device)
556+
device_spec = pydev.DeviceSpec.from_string(device_name)
557+
device_spec.device_type = "CPU"
558+
canonical_device.add(device_spec.to_string())
555559
if len(canonical_device) != 1:
556560
raise ValueError("All tensors of a saveable object must be "
557561
"on the same device: %s" % saveable.name)

0 commit comments

Comments
 (0)