Change UNDEFINED to UNSPECIFIED in code handling unspecified built-in arguments.
PiperOrigin-RevId: 229926077
This commit is contained in:
parent
f9f39e43c8
commit
c5d6b96282
@ -37,7 +37,7 @@ from tensorflow.python.ops import list_ops
|
||||
from tensorflow.python.ops import math_ops
|
||||
|
||||
|
||||
UNDEFINED = object()
|
||||
UNSPECIFIED = object()
|
||||
|
||||
|
||||
def overload_of(f):
|
||||
@ -77,14 +77,14 @@ def _py_float(x):
|
||||
return float(x)
|
||||
|
||||
|
||||
def int_(x=0, base=UNDEFINED):
|
||||
def int_(x=0, base=UNSPECIFIED):
|
||||
if tensor_util.is_tensor(x):
|
||||
return _tf_int(x, base)
|
||||
return _py_int(x, base)
|
||||
|
||||
|
||||
def _tf_int(x, base):
|
||||
if base not in (10, UNDEFINED):
|
||||
if base not in (10, UNSPECIFIED):
|
||||
raise NotImplementedError('base {} not supported for int'.format(base))
|
||||
|
||||
# TODO(mdan): We shouldn't assume int32.
|
||||
@ -94,7 +94,7 @@ def _tf_int(x, base):
|
||||
|
||||
|
||||
def _py_int(x, base):
|
||||
if base is UNDEFINED:
|
||||
if base is UNSPECIFIED:
|
||||
return int(x)
|
||||
return int(x, base)
|
||||
|
||||
@ -167,7 +167,7 @@ def print_(*objects, **kwargs):
|
||||
|
||||
def _tf_py_func_print(objects, kwargs):
|
||||
"""Overload of print_ as a py_func implementation."""
|
||||
override_kwargs = {k: v for k, v in kwargs.items() if v is not UNDEFINED}
|
||||
override_kwargs = {k: v for k, v in kwargs.items() if v is not UNSPECIFIED}
|
||||
if 'flush' not in override_kwargs:
|
||||
# Defaulting to flushing the console in graph mode, which helps reduce
|
||||
# garbled output in IPython.
|
||||
@ -187,7 +187,7 @@ def _tf_py_func_print(objects, kwargs):
|
||||
print_wrapper, None, objects, use_dummy_return=True)
|
||||
|
||||
|
||||
def range_(start_or_stop, stop=UNDEFINED, step=UNDEFINED):
|
||||
def range_(start_or_stop, stop=UNSPECIFIED, step=UNSPECIFIED):
|
||||
if any(tensor_util.is_tensor(s) for s in (start_or_stop, stop, step)):
|
||||
return _tf_range(start_or_stop, stop, step)
|
||||
return _py_range(start_or_stop, stop, step)
|
||||
@ -200,10 +200,10 @@ def _tf_range(start_or_stop, stop, step):
|
||||
# graph construction error aligns the semantics with Python.
|
||||
|
||||
# TODO(mdan): We should optimize this when a full tensor is not required.
|
||||
if step is not UNDEFINED:
|
||||
if step is not UNSPECIFIED:
|
||||
# TODO(mdan): Add argument coercion similar to other cases.
|
||||
return math_ops.range(start_or_stop, stop, step)
|
||||
if stop is not UNDEFINED:
|
||||
if stop is not UNSPECIFIED:
|
||||
stop = math_ops.maximum(start_or_stop, stop)
|
||||
return math_ops.range(start_or_stop, stop)
|
||||
start_or_stop = math_ops.maximum(start_or_stop, 0)
|
||||
@ -211,9 +211,9 @@ def _tf_range(start_or_stop, stop, step):
|
||||
|
||||
|
||||
def _py_range(start_or_stop, stop, step):
|
||||
if step is not UNDEFINED:
|
||||
if step is not UNSPECIFIED:
|
||||
return range(start_or_stop, stop, step)
|
||||
if stop is not UNDEFINED:
|
||||
if stop is not UNSPECIFIED:
|
||||
return range(start_or_stop, stop)
|
||||
return range(start_or_stop)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user