Add conversion for count_nonzero outside of package
PiperOrigin-RevId: 229158255
This commit is contained in:
parent
ac2f7471b9
commit
3ed46c325f
@ -1339,6 +1339,8 @@ def reduce_sum(input_tensor, axis=None, keepdims=False, name=None):
|
|||||||
@tf_export(v1=["math.count_nonzero", "count_nonzero"])
|
@tf_export(v1=["math.count_nonzero", "count_nonzero"])
|
||||||
@deprecation.deprecated_args(
|
@deprecation.deprecated_args(
|
||||||
None, "keep_dims is deprecated, use keepdims instead", "keep_dims")
|
None, "keep_dims is deprecated, use keepdims instead", "keep_dims")
|
||||||
|
@deprecation.deprecated_args(
|
||||||
|
None, "reduction_indices is deprecated, use axis instead", "axis")
|
||||||
def count_nonzero(input_tensor,
|
def count_nonzero(input_tensor,
|
||||||
axis=None,
|
axis=None,
|
||||||
keepdims=None,
|
keepdims=None,
|
||||||
|
@ -121,7 +121,6 @@ renames = {
|
|||||||
'tf.container': 'tf.compat.v1.container',
|
'tf.container': 'tf.compat.v1.container',
|
||||||
'tf.convert_to_tensor_or_indexed_slices': 'tf.compat.v1.convert_to_tensor_or_indexed_slices',
|
'tf.convert_to_tensor_or_indexed_slices': 'tf.compat.v1.convert_to_tensor_or_indexed_slices',
|
||||||
'tf.convert_to_tensor_or_sparse_tensor': 'tf.compat.v1.convert_to_tensor_or_sparse_tensor',
|
'tf.convert_to_tensor_or_sparse_tensor': 'tf.compat.v1.convert_to_tensor_or_sparse_tensor',
|
||||||
'tf.count_nonzero': 'tf.compat.v1.count_nonzero',
|
|
||||||
'tf.count_up_to': 'tf.compat.v1.count_up_to',
|
'tf.count_up_to': 'tf.compat.v1.count_up_to',
|
||||||
'tf.create_partitioned_variables': 'tf.compat.v1.create_partitioned_variables',
|
'tf.create_partitioned_variables': 'tf.compat.v1.create_partitioned_variables',
|
||||||
'tf.cross': 'tf.linalg.cross',
|
'tf.cross': 'tf.linalg.cross',
|
||||||
|
@ -119,6 +119,11 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec):
|
|||||||
"tf.load_file_system_library": {
|
"tf.load_file_system_library": {
|
||||||
"library_filename": "library_location",
|
"library_filename": "library_location",
|
||||||
},
|
},
|
||||||
|
"tf.count_nonzero": {
|
||||||
|
"input_tensor": "input",
|
||||||
|
"keep_dims": "keepdims",
|
||||||
|
"reduction_indices": "axis",
|
||||||
|
},
|
||||||
"tf.math.count_nonzero": {
|
"tf.math.count_nonzero": {
|
||||||
"input_tensor": "input",
|
"input_tensor": "input",
|
||||||
"keep_dims": "keepdims",
|
"keep_dims": "keepdims",
|
||||||
@ -511,6 +516,8 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec):
|
|||||||
"tf.sort",
|
"tf.sort",
|
||||||
"tf.contrib.framework.argsort":
|
"tf.contrib.framework.argsort":
|
||||||
"tf.argsort",
|
"tf.argsort",
|
||||||
|
"tf.count_nonzero":
|
||||||
|
"tf.math.count_nonzero",
|
||||||
"tf.manip.batch_to_space_nd":
|
"tf.manip.batch_to_space_nd":
|
||||||
"tf.batch_to_space",
|
"tf.batch_to_space",
|
||||||
"tf.quantize_v2":
|
"tf.quantize_v2":
|
||||||
|
@ -506,7 +506,7 @@ bazel-bin/tensorflow/tools/compatibility/update/generate_v2_reorders_map
|
|||||||
"tf.nn.dropout(x, 1 - (1 - func(3 + 4.)), name=\"foo\")\n",
|
"tf.nn.dropout(x, 1 - (1 - func(3 + 4.)), name=\"foo\")\n",
|
||||||
)
|
)
|
||||||
|
|
||||||
def testCountNonZeroChanges(self):
|
def testMathCountNonZeroChanges(self):
|
||||||
text = (
|
text = (
|
||||||
"tf.math.count_nonzero(input_tensor=input, dtype=dtype, name=name, "
|
"tf.math.count_nonzero(input_tensor=input, dtype=dtype, name=name, "
|
||||||
"reduction_indices=axis, keep_dims=keepdims)\n"
|
"reduction_indices=axis, keep_dims=keepdims)\n"
|
||||||
@ -518,6 +518,18 @@ bazel-bin/tensorflow/tools/compatibility/update/generate_v2_reorders_map
|
|||||||
)
|
)
|
||||||
self.assertEqual(new_text, expected_text)
|
self.assertEqual(new_text, expected_text)
|
||||||
|
|
||||||
|
def testCountNonZeroChanges(self):
|
||||||
|
text = (
|
||||||
|
"tf.count_nonzero(input_tensor=input, dtype=dtype, name=name, "
|
||||||
|
"reduction_indices=axis, keep_dims=keepdims)\n"
|
||||||
|
)
|
||||||
|
_, unused_report, unused_errors, new_text = self._upgrade(text)
|
||||||
|
expected_text = (
|
||||||
|
"tf.math.count_nonzero(input=input, dtype=dtype, name=name, "
|
||||||
|
"axis=axis, keepdims=keepdims)\n"
|
||||||
|
)
|
||||||
|
self.assertEqual(new_text, expected_text)
|
||||||
|
|
||||||
def testRandomMultinomialToRandomCategorical(self):
|
def testRandomMultinomialToRandomCategorical(self):
|
||||||
text = (
|
text = (
|
||||||
"tf.random.multinomial(logits, samples, seed, name, output_dtype)\n"
|
"tf.random.multinomial(logits, samples, seed, name, output_dtype)\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user