Skip to content

Commit

Permalink
Improve Tensor.read
Browse files Browse the repository at this point in the history
  • Loading branch information
clebert committed Oct 16, 2023
1 parent 3136d74 commit 53c3c6b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/tensor.zig
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ pub fn Tensor(comptime n_dims: comptime_int) type {

pub fn read(self: *const Self, file: std.fs.File) !void {
const buffer: [*]u8 = @ptrCast(self.data);
const n_bytes = self.data.len * @sizeOf(f32);
const n_bytes_read = try file.reader().readAll(buffer[0..n_bytes]);

if (n_bytes_read != n_bytes) {
return error.UnexpectedEndOfFile;
}
try file.reader().readNoEof(buffer[0 .. self.data.len * @sizeOf(f32)]);
}

pub fn slice(self: *const Self, index: usize) Tensor(n_dims - 1) {
Expand Down

0 comments on commit 53c3c6b

Please sign in to comment.