Skip to content

argsort does not support complex128 tensors on CPU backend #99164

@springcrane

Description

@springcrane

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.17

Custom code

Yes

OS platform and distribution

Ubuntu 20.04

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

The operation fails with the following error:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Value for attr 'T' of complex128 is not in the list of allowed values: float, double, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64
; NodeDef: {{node TopKV2}}; Op<name=TopKV2>; Op<name=TopKV2>
Expected behavior
argsort should either support complex64/complex128 tensors on CPU, or raise a clear error indicating that the operation is not supported for complex types.

Standalone code to reproduce the issue

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
import tensorflow.experimental.numpy as tnp

# Generate random complex input data
real_part = tnp.random.randn(3, 4)
imag_part = tnp.random.randn(3, 4)
complex_data = tf.complex(real_part, imag_part)

# Attempt to apply argsort
sorted_indices = tnp.argsort(a=complex_data, kind='stable')

Relevant log output

Input complex data:
 [[-0.56195893-1.64089445j -1.54584942-0.36713052j -1.3005634 +1.6114282j
   0.55223823-0.18570225j]
 [ 1.14189741+0.47845684j  0.23988903-1.09895554j -0.87619739+0.73307129j
   1.04041324-0.80997881j]
 [ 1.14454671-0.10186608j  0.14604414+0.00396092j  1.10731772-0.09357997j
  -0.61830007-0.10900073j]]

tensorflow.python.framework.errors_impl.InvalidArgumentError: Value for attr 'T' of complex128 is not in the list of allowed values: float, double, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64
; NodeDef: {{node TopKV2}}; Op<name=TopKV2>

Metadata

Metadata

Assignees

Labels

2.17Issues related to 2.17 releasecomp:opsOPs related issuestype:bugBug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions