Skip to content

Commit 11f4d83

Browse files
girvingtensorflower-gardener
authored andcommitted
DecodeRaw should use int64 for sizes, not int
Change: 116802454
1 parent 0c4be88 commit 11f4d83

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tensorflow/core/kernels/decode_raw_op.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class DecodeRawOp : public OpKernel {
3535

3636
void Compute(OpKernelContext* context) override {
3737
const auto& input = context->input(0);
38-
int str_size = -1;
38+
int64 str_size = -1;
3939
auto flat_in = input.flat<string>();
40-
for (int i = 0; i < flat_in.size(); ++i) {
40+
for (int64 i = 0; i < flat_in.size(); ++i) {
4141
const string& in_str = flat_in(i);
4242
if (str_size == -1) {
4343
str_size = in_str.size();
@@ -62,7 +62,7 @@ class DecodeRawOp : public OpKernel {
6262
errors::InvalidArgument("Input to DecodeRaw has length ", str_size,
6363
" that is not a multiple of ", sizeof(T),
6464
", the size of ", DataTypeString(out_type_)));
65-
const int added_dim = str_size / sizeof(T);
65+
const int64 added_dim = str_size / sizeof(T);
6666
out_shape.AddDim(added_dim);
6767
Tensor* output_tensor = nullptr;
6868
OP_REQUIRES_OK(
@@ -76,7 +76,7 @@ class DecodeRawOp : public OpKernel {
7676
little_endian_ ? "true" : "false"));
7777
// Endianness matches, so just copy each string byte-for-byte.
7878
T* out_data = out.data();
79-
for (int i = 0; i < flat_in.size(); ++i) {
79+
for (int64 i = 0; i < flat_in.size(); ++i) {
8080
const T* in_data = reinterpret_cast<const T*>(flat_in(i).data());
8181
memcpy(out_data, in_data, str_size);
8282
out_data += added_dim;

0 commit comments

Comments
 (0)