Skip to content

Commit

Permalink
Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
clebert committed Aug 23, 2023
1 parent 4b4620e commit 82a59a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/attention.zig
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ pub const Attention = struct {
head: usize,
kv_cache_layer_offset: usize,
) void {
@setFloatMode(.Optimized);

const checkpoint = self.checkpoint;
const kv_dim = checkpoint.kv_dim;
const head_size = checkpoint.head_size;
Expand Down
2 changes: 2 additions & 0 deletions src/feed_forward.zig
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub const FeedForward = struct {
}

pub fn forward(self: *const Self, layer: usize) !void {
@setFloatMode(.Optimized);

const checkpoint = self.checkpoint;
const dim = checkpoint.dim;
const hidden_dim = checkpoint.hidden_dim;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/random.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub fn random(state: *u64) f32 {
@setFloatMode(.Optimized);

return @as(f32, @floatFromInt(xorshift(state) >> 8)) / 16777216;
}

Expand Down

0 comments on commit 82a59a1

Please sign in to comment.