Out-of-bounds `x[i]` returns a value with `jit_compile=True` but fails in eager mode: `slice index 6 of dimension 0 out of bounds`
Los mantenedores suelen responder en 2 días
@Venkat6871 ya está trabajando en esto.
Desde el 3/10/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
Yes
Source
binary
TensorFlow version
tf-nightly 2.23.0-dev20261002 (v1.12.1-146002-ged9781322a7); also reproduced with 2.22.0-dev0 built from source at commit 59e32224ffb065b4832b9b4ed9b93235a38aab94
Custom code
Yes
OS platform and distribution
Linux Ubuntu 24.04.3 LTS
Mobile device
No response
Python version
3.11.15
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
CUDA 12.9 / cuDNN 9.27.0 (from pip install tf-nightly[and-cuda]), driver 580.126.09
GPU model and memory
NVIDIA GeForce RTX 4060 Laptop GPU, 8 GB
Current behavior?
The Keras model below loops i from 0 to 7 over a 6-element input and reads x[i]. In eager mode x[6] fails with INVALID_ARGUMENT: slice index 6 of dimension 0 out of bounds. With jit_compile=True the model runs without an error (3 of 3 runs) and returns [1. 2. 3. 4. 5. 6. 6. 6.]: the out-of-bounds reads return the last element.
Expected: the call fails with the same InvalidArgumentError as in eager mode instead of returning values for the out-of-bounds indices.
To reproduce, save the code below as DusAccumulatorZeroInitElimination_4.py and run python DusAccumulatorZeroInitElimination_4.py on a GPU machine (the program sets jit_compile=True itself). The eager reference runs the same file with tf.config.run_functions_eagerly(True):
python -c "import tensorflow as tf; tf.config.run_functions_eagerly(True); exec(open('DusAccumulatorZeroInitElimination_4.py').read())"
Both outputs are under Relevant log output.
Standalone code to reproduce the issue
import tensorflow as tf
class Model(tf.keras.Model):
def __init__(self, N):
"""
N : int static trip count (e.g., 8).
"""
super(Model, self).__init__()
self.N = N
@tf.function(jit_compile=True)
def call(self, x):
N = self.N
dtype = x.dtype
# Buffer initialised with zeros, shape [N] (broadcast of scalar zero)
init_buf = tf.zeros([N], dtype=dtype)
# Induction variable starts at 0
i0 = tf.constant(0)
limit = tf.constant(N, dtype=tf.int32)
def cond(i, buf):
return i < limit
def body(i, buf):
# Element to write at position i (shape updated to [1])
update = tf.reshape(x[i], [1])
# Indices for tensor_scatter_nd_update: [[i]]
indices = tf.reshape(i, [1, 1])
# Overwrite buffer at index i (translates to dynamic-update-slice)
new_buf = tf.tensor_scatter_nd_update(buf, indices, update)
return i + 1, new_buf
_, final_buf = tf.while_loop(cond, body, [i0, init_buf])
return final_buf
# Example usage
N = 8
m = Model(N)
x = tf.constant([1., 2., 3., 4., 5., 6.], shape=[6])
y = m(x)
print(y)
Relevant log output
$ python DusAccumulatorZeroInitElimination_4.py
tf.Tensor([1. 2. 3. 4. 5. 6. 6. 6.], shape=(8,), dtype=float32)
$ python -c "import tensorflow as tf; tf.config.run_functions_eagerly(True); exec(open('DusAccumulatorZeroInitElimination_4.py').read())"
tensorflow.python.framework.errors_impl.InvalidArgumentError: Exception encountered when calling Model.call().
{{function_node __wrapped__StridedSlice_device_/job:localhost/replica:0/task:0/device:GPU:0}} slice index 6 of dimension 0 out of bounds. [Op:StridedSlice] name: model/strided_slice/
Arguments received by Model.call():
• x=tf.Tensor(shape=(6,), dtype=float32)
- Lenguaje dominante
- C++
- Estrellas
- 201k
- Forks
- 78.4k
- Merge medio
- 3 d 1 h
- PR fusionados (30 d)
- 433
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de tensorflow/tensorflow
-
[RFC] Add codespell spelling presubmit for changed Python/Markdown filesPosiblemente ocupada @Venkat6871 la tomó hace 1 día. Abiertotype:feature
tensorflow/tensorflow#130085 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
tf.math.polyval fails for Python int coefficients with a float xPosiblemente ocupada @Venkat6871 la tomó hace 4 días. Abierto2.20.0 awaiting PR merge comp:ops type:bug
tensorflow/tensorflow#130023 · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
tf.Tensor.__dlpack__ rejects a matching dl_device instead of using the zero-copy pathPosiblemente ocupada @Kayyuri la tomó hace 3 días. Abiertoawaiting PR merge comp:core type:bug
tensorflow/tensorflow#129993 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
Feature Request: Standalone Training Loop Support for Android on CPU (NPU + GPGPU solutions are discussed too)Posiblemente ocupada @Venkat6871 la tomó hace 6 días. Abiertotype:feature
tensorflow/tensorflow#129927 · 13 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
[Sparse] Support SparseTensorValue in tf.sparse.bincount and validate_sparse_weightsPosiblemente ocupada @Venkat6871 la tomó hace 6 días. Abiertoawaiting PR merge comp:ops type:feature
tensorflow/tensorflow#129921 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 2 días
Todos los issues de tensorflow/tensorflow
Issues similares
-
Upstream changes to reviewAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
rhalbersma/xstd-ints#395 ·
Los mantenedores suelen responder en 1 día
-
[Bug] Root filesystem scope (/) incorrectly rejects all descendant pathsPosiblemente ocupada @mugenkyou la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
neutralinojs/neutralino.js#304 · 1 comentario ·
-
CLI: enforce absolute ADB device paths in file and directory commandsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
FuSa
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
tenstorrent/tt-umd#3851 ·
Los mantenedores suelen responder en 3 días
-
zq prints a raw SQL 'no such table: index_default' error when the index has no default indexAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
mattgodbolt/zindex#67 ·
Los mantenedores suelen responder en 1 día