Skip to content

Commit

Permalink
fix (mostly) safe lstm perf
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuseZ4 committed Oct 2, 2024
1 parent 1fe64c0 commit 7f26f43
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions enzyme/benchmarks/ReverseMode/lstm/src/safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ fn lstm_model(
let (a, b) = gates.split_at_mut(2 * hsize);
let ((forget, ingate), (outgate, change)) = (a.split_at_mut(hsize), b.split_at_mut(hsize));

assert_eq!(weight.len(), 4 * hsize);
assert_eq!(bias.len(), 4 * hsize);
assert_eq!(hidden.len(), hsize);
assert!(cell.len() >= hsize);
assert!(input.len() >= hsize);
debug_assert_eq!(weight.len(), 4 * hsize);
debug_assert_eq!(bias.len(), 4 * hsize);
debug_assert_eq!(hidden.len(), hsize);
debug_assert!(cell.len() >= hsize);
debug_assert!(input.len() >= hsize);
// caching input
for i in 0..hsize {
forget[i] = sigmoid(input[i] * weight[i] + bias[i]);
Expand Down Expand Up @@ -130,7 +130,7 @@ pub(crate) fn lstm_objective(
let mut ypred = vec![0.0; b];
let mut ynorm = vec![0.0; b];

assert!(b > 0);
debug_assert!(b > 0);

let limit = (c - 1) * b;
for j in 0..(c - 1) {
Expand Down

0 comments on commit 7f26f43

Please sign in to comment.