提交 fe4328b4 编写于 作者: S Sergei Lebedev 提交者: TensorFlower Gardener

Inlined `Variable._AsTensor`

Both implementations used `Variable.value`.

PiperOrigin-RevId: 225416178
上级 6742cc2a
......@@ -890,7 +890,7 @@ def _SliceHelperVar(var, slice_spec):
"""
return _slice_helper(var._AsTensor(), slice_spec, var)
return _slice_helper(var.value(), slice_spec, var)
ops.Tensor._override_operator("__getitem__", _slice_helper)
......
......@@ -809,9 +809,6 @@ class ResourceVariable(variables.RefVariable):
return ResourceVariable(
variable_def=variable_def, import_scope=import_scope)
def _AsTensor(self):
return self.value()
def _ref(self):
"""Unsupported."""
raise NotImplementedError("ResourceVariable does not implement _ref()")
......
......@@ -932,7 +932,7 @@ class Variable(six.with_metaclass(VariableMetaclass,
def _run_op(a, *args, **kwargs):
# pylint: disable=protected-access
return tensor_oper(a._AsTensor(), *args, **kwargs)
return tensor_oper(a.value(), *args, **kwargs)
functools.update_wrapper(_run_op, tensor_oper)
setattr(cls, operator, _run_op)
......@@ -1603,16 +1603,6 @@ class RefVariable(VariableV1):
"""Conversion function for Graph.as_graph_element()."""
return self._variable
def _AsTensor(self): # pylint: disable=invalid-name
"""Converts this variable to a Tensor.
See `tf.Variable.value`.
Returns:
A `Tensor` containing the value of the variable.
"""
return self._snapshot
def value(self):
"""Returns the last snapshot of this variable.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册