Update saver.py
Fix device placement of save_op for ResourceVariable.
This commit is contained in:
parent
6155633318
commit
0c11bcb5f3
@ -126,13 +126,10 @@ class BaseSaverBuilder(object):
|
||||
def f():
|
||||
with ops.device(v.device):
|
||||
x = v.read_value()
|
||||
# To allow variables placed on non-CPU devices to be checkpointed,
|
||||
# we copy them to CPU on the same machine first.
|
||||
device_spec = pydev.DeviceSpec().parse_from_string(v.device)
|
||||
device_spec.merge_from(
|
||||
pydev.DeviceSpec().parse_from_string("/device:CPU:0"))
|
||||
with ops.device(device_spec.to_string()):
|
||||
return array_ops.identity(x)
|
||||
# To allow variables placed on non-CPU devices to be checkpointed,
|
||||
# we copy them to CPU on the same machine first.
|
||||
with ops.device("/device:CPU:0"):
|
||||
return array_ops.identity(x)
|
||||
return f
|
||||
|
||||
self.handle_op = var.handle
|
||||
|
Loading…
Reference in New Issue
Block a user