这是indexloc提供的服务,不要输入任何密码
Skip to content

tf.pow returns inconsistent value on CPU vs GPU #97125

@jiren-the-gray

Description

@jiren-the-gray

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.20.0-dev20250716

Custom code

Yes

OS platform and distribution

Linux Ubuntu 24.04

Mobile device

No response

Python version

3.12

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

tf.pow returns inconsistent values when using int64 tensors on CPU vs CUDA. The CPU value matches the value calculated by numpy.

Also reproducible with 2.19.0 (colab)

Standalone code to reproduce the issue

import tensorflow as tf
import numpy as np

print(tf.__version__)   # 2.20.0-dev20250716

x = tf.constant([-48], dtype=tf.int64)
y = tf.constant([66], dtype=tf.int64)

with tf.device('/cpu:0'):
    output_cpu = tf.pow(x=x, y=y)
    print("Output on CPU:", output_cpu)  # 0

with tf.device('/gpu:0'):
    output_gpu = tf.pow(x=x, y=y)
    print("Output on GPU:", output_gpu)  # 2304

output_np = np.power(x.numpy(), y.numpy())
print("Output with NumPy:", output_np)  # 0

Relevant log output

2.20.0-dev20250716
Output on CPU: tf.Tensor([0], shape=(1,), dtype=int64)
Output on GPU: tf.Tensor([2304], shape=(1,), dtype=int64)
Output with NumPy: [0]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions