- Notifications
You must be signed in to change notification settings - Fork75.1k
Open
Labels
Description
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
Yes
Source
source
TensorFlow version
tf-2.19
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?
Callingtf.raw_ops.ResourceSparseApplyAdagradV2 with a grad tensor whose shape is incompatible with indices and the underlying resource variable can lead to a crash, instead of raising a clear Python exception.
The bug can be reproduced on tf-2.19. Here is thegist.
Standalone code to reproduce the issue
# BUG: tf.raw_ops.ResourceSparseApplyAdagradV2, grad shape mismatchimport tensorflow as tf# Create resource variablevar = tf.Variable(tf.ones([3, 3], dtype=tf.float32))# Create accumulatorsaccum = tf.Variable(tf.zeros([3, 3], dtype=tf.float32))# Sparse indices and valuesindices = tf.constant([0, 2], dtype=tf.int64)values = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], dtype=tf.float32)# Learning rate and epsilonlr = tf.constant(0.01, dtype=tf.float32)epsilon = tf.constant(1e-8, dtype=tf.float32)# Invoke the operationresult = tf.raw_ops.ResourceSparseApplyAdagradV2( var=var.handle, accum=accum.handle, lr=lr, epsilon=epsilon, grad=tf.reshape(values, [-1]),# Mismatched shape, crash# grad=values, # success indices=indices, use_locking=False, update_slots=True)
Relevant log output
> 2025-12-17 15:21:00.264948: F tensorflow/core/framework/tensor_shape.cc:357] Check failed: d<dims() (1 vs. 1)> [1] 3374216 abort (core dumped)