Ran into this whilst trying to parse the TensorProtos produced by Tensorflow.
For an example, Tensorflow returns the following protobuf (tensor_shape.dim.size is an int64) for a 1x1 tensor of type float that has value 3.0:
dtype: DT_FLOAT tensor_shape { dim { size: 1 } dim { size: 1 } } float_val: 3.0
with binary encoding as:
[8, 1, 18, 8, 18, 2, 8, 1, 18, 2, 8, 1, 42, 4, 0, 0, 64, 64], in hex:
'0x8 0x1 0x12 0x8 0x12 0x2 0x8 0x1 0x12 0x2 0x8 0x1 0x2a 0x4 0x0 0x0 0x40 0x40
When parsing this with protobufjs 6.0.0, I get RangeError: index out of range: 18 + 1 > 18
However, when parsing with protobufjs 5, the message is parsed correctly.
If I modify TensorProto to be
message TensorProto2 {
DataType dtype = 1;
TensorShapeProto tensor_shape = 2;
int32 version_number = 3;
bytes tensor_content = 4;
//repeated float float_val = 5 [packed = true];
}
The message is parsed correctly (but missing the floatVal, as it's been commented out)
Ran into this whilst trying to parse the TensorProtos produced by Tensorflow.
For an example, Tensorflow returns the following protobuf (tensor_shape.dim.size is an int64) for a 1x1 tensor of type float that has value 3.0:
dtype: DT_FLOAT tensor_shape { dim { size: 1 } dim { size: 1 } } float_val: 3.0with binary encoding as:
[8, 1, 18, 8, 18, 2, 8, 1, 18, 2, 8, 1, 42, 4, 0, 0, 64, 64], in hex:'0x8 0x1 0x12 0x8 0x12 0x2 0x8 0x1 0x12 0x2 0x8 0x1 0x2a 0x4 0x0 0x0 0x40 0x40When parsing this with protobufjs 6.0.0, I get
RangeError: index out of range: 18 + 1 > 18However, when parsing with protobufjs 5, the message is parsed correctly.
If I modify TensorProto to be
The message is parsed correctly (but missing the floatVal, as it's been commented out)