8000 Merge branch 'r2.11' into cherry2.11picks · IBMZ-Linux-OSS-Python/tensorflow@501d2d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 501d2d2

Browse files
Merge branch 'r2.11' into cherry2.11picks
2 parents 038f2ea + 6541ff6 commit 501d2d2

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

tensorflow/compiler/tests/tensor_list_ops_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,17 @@ def testZerosLikeForTensorList(self):
236236
self.assertAllEqual(z.shape.as_list(), [None])
237237
self.assertAllEqual(z, [0.0, 0.0])
238238

239+
def testInvalidSplitLength(self):
240+
with self.session(), self.test_scope():
241+
tensor_list_split = list_ops.tensor_list_split(
242+
tensor=[1], element_shape=[-1], lengths=[0]
243+
)
244+
with self.assertRaisesRegex(
245+
errors.UnimplementedError, "All lengths must be positive"
246+
):
247+
self.evaluate(tensor_list_split)
248+
249+
239250
if __name__ == "__main__":
240251
os.environ["TF_XLA_FLAGS"] = ("--tf_xla_min_cluster_size=2 " +
241252
os.environ.get("TF_XLA_FLAGS", ""))

tensorflow/compiler/tf2xla/kernels/tensor_list_ops.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ class TensorListSplitOp : public XlaOpKernel {
553553
OP_REQUIRES(ctx, len == length,
554554
errors::Unimplemented("All lengths have to be the same"));
555555
}
556+
OP_REQUIRES(ctx, length,
557+
errors::Unimplemented("All lengths must be positive"));
556558
OP_REQUIRES(
557559
ctx, element_dims[0] % length == 0,
558560
errors::Unimplemented("Buffer size has to be a multiple of length"));

tensorflow/core/kernels/image/decode_image_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class DecodeImageV2Op : public OpKernel {
452452
// allocation til after dtype conversion is done. `gif`::Decode` supports
453453
// uint8 only.
454454
Tensor* output = nullptr;
455-
ptrdiff_t buffer_size = 0;
455+
int64_t buffer_size = 0;
456456
string error_string;
457457
uint8* buffer = gif::Decode(
458458
input.data(), input.size(),

tensorflow/core/lib/gif/gif_io.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ uint8* Decode(const void* srcdata, int datasize,
105105
uint8* const dstdata =
106106
allocate_output(target_num_frames, width, height, channel);
107107
if (!dstdata) return nullptr;
108-
for (ptrdiff_t k = 0; k < target_num_frames; k++) {
108+
for (int64_t k = 0; k < target_num_frames; k++) {
109109
uint8* this_dst = dstdata + k * width * channel * height;
110110

111111
SavedImage* this_image = &gif_file->SavedImages[k];
@@ -125,10 +125,10 @@ uint8* Decode(const void* srcdata, int datasize,
125125

126126
if (k > 0) {
127127
uint8* last_dst = dstdata + (k - 1) * width * channel * height;
128-
for (ptrdiff_t i = 0; i < height; ++i) {
128+
for (int64_t i = 0; i < height; ++i) {
129129
uint8* p_dst = this_dst + i * width * channel;
130130
uint8* l_dst = last_dst + i * width * channel;
131-
for (ptrdiff_t j = 0; j < width; ++j) {
131+
for (int64_t j = 0; j < width; ++j) {
132132
p_dst[j * channel + 0] = l_dst[j * channel + 0];
133133
p_dst[j * channel + 1] = l_dst[j * channel + 1];
134134
p_dst[j * channel + 2] = l_dst[j * channel + 2];
@@ -141,9 +141,9 @@ uint8* Decode(const void* srcdata, int datasize,
141141
// If the first frame does not fill the entire canvas then fill the
142142
// unoccupied canvas with zeros (black).
143143
if (k == 0) {
144-
for (ptrdiff_t i = 0; i < height; ++i) {
144+
for (int64_t i = 0; i < height; ++i) {
145145
uint8* p_dst = this_dst + i * width * channel;
146-
for (ptrdiff_t j = 0; j < width; ++j) {
146+
for (int64_t j = 0; j < width; ++j) {
147147
p_dst[j * channel + 0] = 0;
148148
p_dst[j * channel + 1] = 0;
149149
p_dst[j * channel + 2] = 0;
@@ -165,9 +165,9 @@ uint8* Decode(const void* srcdata, int datasize,
165165
return nullptr;
166166
}
167167

168-
for (ptrdiff_t i = imgTop; i < imgBottom; ++i) {
168+
for (int64_t i = imgTop; i < imgBottom; ++i) {
169169
uint8* p_dst = this_dst + i * width * channel;
170-
for (ptrdiff_t j = imgLeft; j < imgRight; ++j) {
170+
for (int64_t j = imgLeft; j < imgRight; ++j) {
171171
GifByteType color_index =
172172
this_image->RasterBits[(i - img_desc->Top) * (img_desc->Width) +
173173
(j - img_desc->Left)];

tensorflow/core/lib/gif/gif_io_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void TestDecodeGif(Env* env, DecodeGifTestCase testcase) {
5252
w = width;
5353
h = height;
5454
c = channels;
55-
return new uint8[ptrdiff_t(frame_cnt) * height * width * channels];
55+
return new uint8[int64_t(frame_cnt) * height * width * channels];
5656
},
5757
&error_string));
5858
ASSERT_NE(imgdata, nullptr);

0 commit comments

Comments
 (0)
0