tensorflow / tensorflow/tensorflow

`tf.pow` for complex64: `pow(0+0j, 0+0j)` returns `NaN+NaNj` in eager mode

Open
#117,802 2 comments 0 reactions 1 assignee View on GitHub

@Kayyuri is already working on this.

Since Sep 18, 2026.

2.21.0 awaiting PR merge comp:eager comp:ops type:bug
Dominant language
C++
Stars
200k
Forks
76.9k
Avg merge
2d 3h
Merged PRs (30d)
433

Description

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

TensorFlow 2.22.0-dev20260503

Custom code

Yes

OS platform and distribution

No response

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?

Summary

tf.pow(0+0j, 0+0j) returns NaN+NaNj in eager mode, while NumPy returns (1+0j). The eager implementation computes complex power via exp(b * log(a)), which hits log(0) = -inf and produces NaN.

Under XLA (jit_compile=True), tf.pow(0+0j, 0+0j) correctly returns 1+0j, matching NumPy.

Scope

All complex zero variants are affected:

Base Exp Eager XLA NumPy
0+0j 0+0j NaN+NaNj 1+0j 1+0j
-0+0j 0+0j NaN+NaNj 1+0j 1+0j
0-0j 0+0j NaN+NaNj 1+0j 1+0j

Root cause

TensorFlow's eager complex pow kernel computes pow(a, b) = exp(b * log(a)). When a = 0+0j, log(0+0j) = -inf + ..., and subsequent multiplication produces NaN. The special case pow(0, 0) = 1 (from IEEE 754 for real numbers and C99 for complex) is not handled.

Expected behavior

Eager should return (1+0j) for pow(0+0j, 0+0j), matching NumPy and XLA.

Environment

  • TensorFlow 2.22.0-dev20260503
  • CPU only
Standalone code to reproduce the issue
## Reproduction


import tensorflow as tf
import numpy as np

z = tf.constant([0+0j], dtype=tf.complex64)

print(tf.pow(z, z).numpy())
# [(nan+nanj)]  — eager: wrong

print(tf.function(lambda a, b: tf.pow(a, b), jit_compile=True)(z, z).numpy())
# [(1+0j)]  — XLA: correct

print(np.power(0+0j, 0+0j))
# (1+0j)  — NumPy reference


Reproduces on TF 2.22.0-dev20260503 (nightly), CPU.
Relevant log output

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.