tensorflow: tf.saturate_cast errors for tf.complex type tensor

Click to expand!

Issue Type

Bug

Source

binary

Tensorflow Version

2.10.0

Custom Code

No

OS Platform and Distribution

Ubuntu 20.04.5 LTS

Mobile device

No response

Python version

3.8.10

Bazel version

No response

GCC/Compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current Behaviour?

From code below, the tf.saturate_cast need to check dtype's min
https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/math_ops.py#L713-L743

However, from code below, min is not support for complex64 or complex128
https://github.com/tensorflow/tensorboard/blob/master/tensorboard/compat/tensorflow_stub/dtypes.py#L188-L194

The documentation for tf.saturate_cast said it support any tensor or dtype desired. Therefore, either code or documentation need to be changed
https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/ops/math_ops.py#L716-L729

Standalone code to reproduce the issue

Code like: 

import tensorflow as tf
arg_0_tensor = tf.complex(tf.random.uniform([2, 1], dtype=tf.float32),tf.random.uniform([2, 1], dtype=tf.float32))
arg_0_tensor = tf.saturate_cast(arg_0_tensor,dtype=tf.float32)

Relevant log output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/dtypes.py", line 110, in min
    raise TypeError(f"Cannot find minimum value of {self} with "
TypeError: Cannot find minimum value of <dtype: 'complex64'> with type <dtype: 'complex64'>.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for reporting the issue, I have updated the document with the above PR to show the list of supported dtypes in the args.