Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 committed Aug 30, 2023
1 parent 882d8b8 commit 532f175
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rust/src/utils/tfrecord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,10 @@ fn append_primitive_from_slice<T>(
) where
T: arrow::datatypes::ArrowPrimitiveType,
{
// Safety: we are trusting that the data in the buffer are valid for the
// datatype T::Native, as claimed by the file. There isn't anywhere for
// TensorProto to tell us the original endianness, so it's possible there
// could be a mismatch here.
let (prefix, middle, suffix) = unsafe { slice.align_to::<T::Native>() };
for val in prefix.chunks_exact(T::get_byte_width()) {
builder.append_value(parse_val(val));
Expand Down

0 comments on commit 532f175

Please sign in to comment.