diff --git a/tensorflow/python/ops/array_ops.py b/tensorflow/python/ops/array_ops.py index d0efbdbaf8b..5a81442f3aa 100644 --- a/tensorflow/python/ops/array_ops.py +++ b/tensorflow/python/ops/array_ops.py @@ -269,7 +269,13 @@ def broadcast_static_shape(shape_x, shape_y): return common_shapes.broadcast_shape(shape_x, shape_y) -@tf_export("shape") +@tf_export("shape", v1=[]) +def shape_v2(input, out_type=dtypes.int32, name=None): + # pylint: disable=redefined-builtin + return shape(input, name, out_type) + + +@tf_export(v1=["shape"]) def shape(input, name=None, out_type=dtypes.int32): # pylint: disable=redefined-builtin """Returns the shape of a tensor. @@ -342,7 +348,13 @@ def shape_n(input, out_type=dtypes.int32, name=None): return gen_array_ops.shape_n(input, out_type=out_type, name=name) -@tf_export("size") +@tf_export("size", v1=[]) +def size_v2(input, out_type=dtypes.int32, name=None): + # pylint: disable=redefined-builtin + return size(input, name, out_type) + + +@tf_export(v1=["size"]) def size(input, name=None, out_type=dtypes.int32): # pylint: disable=redefined-builtin """Returns the size of a tensor. diff --git a/tensorflow/python/ops/sparse_ops.py b/tensorflow/python/ops/sparse_ops.py index 80d93f3de1d..8a7cfd45b2c 100644 --- a/tensorflow/python/ops/sparse_ops.py +++ b/tensorflow/python/ops/sparse_ops.py @@ -185,8 +185,14 @@ def sparse_eye(num_rows, dense_shape=[num_rows, num_columns]) +@tf_export("sparse.concat", "sparse_concat", v1=[]) +def sparse_concat_v2(axis, sp_inputs, expand_nonconcat_dim=False, + concat_dim=None, name=None): + return sparse_concat(axis, sp_inputs, name, expand_nonconcat_dim, concat_dim) + + # pylint: disable=protected-access -@tf_export("sparse.concat", "sparse_concat") +@tf_export(v1=["sparse.concat", "sparse_concat"]) @deprecation.deprecated_endpoints("sparse_concat") @deprecation.deprecated_args( None, "concat_dim is deprecated, use axis instead", "concat_dim") diff --git a/tensorflow/tools/api/golden/v2/tensorflow.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.pbtxt index 9ce326edd2b..87ce1b2328b 100644 --- a/tensorflow/tools/api/golden/v2/tensorflow.pbtxt +++ b/tensorflow/tools/api/golden/v2/tensorflow.pbtxt @@ -1058,7 +1058,7 @@ tf_module { } member_method { name: "shape" - argspec: "args=[\'input\', \'name\', \'out_type\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + argspec: "args=[\'input\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " } member_method { name: "shape_n" @@ -1082,7 +1082,7 @@ tf_module { } member_method { name: "size" - argspec: "args=[\'input\', \'name\', \'out_type\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + argspec: "args=[\'input\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " } member_method { name: "slice" @@ -1094,7 +1094,7 @@ tf_module { } member_method { name: "sparse_concat" - argspec: "args=[\'axis\', \'sp_inputs\', \'name\', \'expand_nonconcat_dim\', \'concat_dim\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + argspec: "args=[\'axis\', \'sp_inputs\', \'expand_nonconcat_dim\', \'concat_dim\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\', \'None\'], " } member_method { name: "sparse_to_dense" diff --git a/tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt index 9c9c4d838e9..cf63924bb16 100644 --- a/tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt +++ b/tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt @@ -14,7 +14,7 @@ tf_module { } member_method { name: "concat" - argspec: "args=[\'axis\', \'sp_inputs\', \'name\', \'expand_nonconcat_dim\', \'concat_dim\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + argspec: "args=[\'axis\', \'sp_inputs\', \'expand_nonconcat_dim\', \'concat_dim\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\', \'None\'], " } member_method { name: "cross" diff --git a/tensorflow/tools/compatibility/tf_upgrade_v2.py b/tensorflow/tools/compatibility/tf_upgrade_v2.py index 82044ff43fe..35592918aee 100644 --- a/tensorflow/tools/compatibility/tf_upgrade_v2.py +++ b/tensorflow/tools/compatibility/tf_upgrade_v2.py @@ -58,6 +58,7 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec): # pylint: disable=line-too-long # Add additional renames not in renames_v2.py here. self.symbol_renames.update({ + "tf.sparse_concat": "tf.sparse.concat", }) # pylint: enable=line-too-long @@ -75,11 +76,10 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec): # IMPORTANT: order here should correspond to OLD argument order. # We just prepend "arg_name=" to all arguments in function calls. self.function_reorders = { - "tf.argmax": ["input", "axis", "output_type", "name"], - "tf.argmin": ["input", "axis", "output_type", "name"], + "tf.argmax": ["input", "axis", "name", "dimension", "output_type"], + "tf.argmin": ["input", "axis", "name", "dimension", "output_type"], "tf.boolean_mask": ["tensor", "mask", "name", "axis"], - "tf.convert_to_tensor": ["value", "dtype", "preferred_dtype", "name"], - "tf.pad": ["tensor", "paddings", "mode", "name", "constant_values"], + "tf.convert_to_tensor": ["value", "dtype", "name", "preferred_dtype"], "tf.nn.pool": [ "input", "window_shape", "pooling_type", "padding", "dilation_rate", "strides", "name", "data_format" @@ -88,6 +88,12 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec): "input", "depthwise_filter", "pointwise_filter", "strides", "padding", "data_format", "dilations", "name" ], + "tf.pad": ["tensor", "paddings", "mode", "name", "constant_values"], + "tf.shape": ["input", "name", "out_type"], + "tf.size": ["input", "name", "out_type"], + "tf.sparse.concat": [ + "axis", "sp_inputs", "name", "expand_nonconcat_dim", "concat_dim" + ], } # Specially handled functions.