Skip to content

Commit 5eabe5f

Browse files
authored
[Embedding] Make Embedding backward compatible with previous saved_model. (#963)
Signed-off-by: 泊霆 <hujunqi.hjq@alibaba-inc.com> Co-authored-by: 泊霆 <hujunqi.hjq@alibaba-inc.com>
1 parent 2f938dc commit 5eabe5f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tensorflow/python/ops/kv_variable_ops.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,16 @@ def _init_from_proto(self, variable_def, import_scope=None):
530530
cache_op = op
531531
elif self._initializer_op.type == "InitializeKvVariableOp":
532532
init_op = self._initializer_op
533-
534-
self._init_op_for_restore = g.as_graph_element(
533+
if variable_def.initialize_op_for_restore:
534+
self._init_op_for_restore = g.as_graph_element(
535535
ops.prepend_name_scope(
536536
variable_def.initialize_op_for_restore,
537537
import_scope=import_scope))
538+
else: #Backward compatibility with 2306
539+
self._init_op_for_restore = g.as_graph_element(
540+
ops.prepend_name_scope(
541+
variable_def.initializer_name,
542+
import_scope=import_scope))
538543
self._trainable = getattr(variable_def, "trainable", True)
539544
if variable_def.snapshot_name:
540545
self._cached_value = g.as_graph_element(

0 commit comments

Comments
 (0)