From 909142540d6a25908256822d6ad33ff8f1439e76 Mon Sep 17 00:00:00 2001 From: Lyaction Date: Fri, 12 Apr 2024 16:22:57 +0800 Subject: [PATCH] Get default type from variable scope. Signed-off-by: Lyaction --- tensorflow/python/ops/kv_variable_ops.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/ops/kv_variable_ops.py b/tensorflow/python/ops/kv_variable_ops.py index f606490560d..3e1608fceb8 100644 --- a/tensorflow/python/ops/kv_variable_ops.py +++ b/tensorflow/python/ops/kv_variable_ops.py @@ -743,7 +743,9 @@ def sparse_read(self, indices, name=None, ev_init_value=None, counts=None): default_value = ev_init_value is_use_default_value_tensor = True else: - default_value = ops.convert_to_tensor(1.0) + from tensorflow.python.ops import variable_scope + default_type = variable_scope.get_variable_scope().dtype + default_value = ops.convert_to_tensor(1.0, dtype=default_type) is_use_default_value_tensor = False if counts != None: value = gen_kv_variable_ops.kv_resource_gather_v1(self._handle,