Skip to content

tf.experimental.numpy.float_power does not promote to float: int inputs stay int, negative int exponents raise #129237

Closed

Description

@bodapatisaikrishna

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

binary

TensorFlow version

tf-nightly 2.23.0-dev20261014 (git v1.12.1-146947-gfcb676979cd)

Custom code

Yes

OS platform and distribution

macOS 15.7.2 (arm64)

Mobile device

No response

Python version

3.11.7

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

np.float_power always computes in at least float64 (or complex128). That is its whole purpose compared with np.power. tnp.float_power is just an alias for power (np_math_ops.py#L419-L420), so:

  • tnp.float_power([2, 3], 2) returns int64 (NumPy: float64)
  • tnp.float_power(np.float32(2), 2) returns float32 (NumPy: float64)
  • tnp.float_power(2, -1) raises InvalidArgumentError: Integers to negative integer powers are not allowed (NumPy: 0.5)

Expected: inputs promoted to float64/complex128 before pow (or at least to np_utils.result_type(float) when float64 is disabled).

Standalone code to reproduce the issue

import numpy as np
import tensorflow.experimental.numpy as tnp

print(np.float_power([2, 3], 2).dtype, tnp.float_power([2, 3], 2).dtype)  # float64 vs int64
print(np.float_power(np.float32(2), 2).dtype, tnp.float_power(np.float32(2), 2).dtype)  # float64 vs float32
print(np.float_power(2, -1))
print(tnp.float_power(2, -1))  # InvalidArgumentError: Integers to negative integer powers are not allowed

Relevant log output

float64 <dtype: 'int64'>
float64 <dtype: 'float32'>
0.5
...
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__Pow_device_/job:localhost/replica:0/task:0/device:CPU:0}} Integers to negative integer powers are not allowed [Op:Pow] name:

Activity

  1. added
    comp:ops
    2.21.0
    on Oct 19, 2026
  2. Kayyuri commented on Oct 19, 2026

    @Kayyuri

    Hi @bodapatisaikrishna,
    Thanks for reporting this issue and submitting a fix for TensorFlow. Once the PR is merged, the issue will be resolved. We appreciate your contribution.

  3. added a commit that references this issue on Oct 23, 2026
    adefc9a
  4. google-ml-butler commented on Oct 23, 2026

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

2.21.0awaiting PR mergecomp:opstype:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions