tensorflow icon indicating copy to clipboard operation
tensorflow copied to clipboard

Inconsistencies between the implementation and documentation of tf.slice

Open Redempt1onzzZZ opened this issue 1 year ago • 1 comments

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

v2.19.0-rc0-6-ge36baa30292 2.19.0

Custom code

Yes

OS platform and distribution

Linux Ubuntu 22.04

Mobile device

No response

Python version

3.11.11

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

NVIDIA H100 - 80GB

Current behavior?

Like https://github.com/tensorflow/tensorflow/issues/92955, in the doc of tf.strided_slice, it shows that begin and sizes should be an int32 or int64 Tensor. While in the real implementation, int16 is also allowed in these three parameters.

Standalone code to reproduce the issue

import tensorflow as tf

a = tf.constant([[[1, 1, 1], [2, 2, 2]],
                 [[3, 3, 3], [4, 4, 4]],
                 [[5, 5, 5], [6, 6, 6]]],dtype=tf.int16)
b = tf.constant([1,0,0],dtype=tf.int16)
c = tf.constant([2,1,3],dtype=tf.int16)
e = tf.strided_slice(a,b,c)
print(e)

Relevant log output

tf.Tensor([[[3 3 3]]], shape=(1, 1, 3), dtype=int16)

Redempt1onzzZZ avatar Dec 02 '25 07:12 Redempt1onzzZZ

Hi @Redempt1onzzZZ, I was able to reproduce this issue with TensorFlow 2.20 using this Colab gist. I also noticed that you have already raised a PR for it. Once the PR is merged, the issue should be resolved. Thank you for contributing to TensorFlow!

avmohansai avatar Dec 09 '25 06:12 avmohansai