From ca5f5a79c4cba2a0b7e43b1fee487f97867e1290 Mon Sep 17 00:00:00 2001 From: FL33TW00D Date: Thu, 3 Oct 2024 16:53:26 +0200 Subject: [PATCH] chore: cleaning --- crates/ratchet-core/src/cpu/rope.rs | 37 ++--------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/crates/ratchet-core/src/cpu/rope.rs b/crates/ratchet-core/src/cpu/rope.rs index 8021a8a3..f7c4271e 100644 --- a/crates/ratchet-core/src/cpu/rope.rs +++ b/crates/ratchet-core/src/cpu/rope.rs @@ -228,40 +228,7 @@ fn rope(src: Vec, shape: &Shape, dim: usize, base: f32, offset: usize) -> V println!("R1: {:?}", r1); println!("R2: {:?}", r2); - vec![] -} - -fn rope_2(src: Vec, shape: &Shape, dim: usize, base: f32, offset: usize) -> Vec { - println!("Ratchet RoPE"); - let [batches, num_heads, seq_len, head_dim] = shape.try_into().unwrap(); - let el_count = batches * num_heads * seq_len * head_dim; + if dim < shape[3] {} - let theta = compute_theta(dim, seq_len, base, offset); - let (sin, cos): (Vec, Vec) = theta.iter().map(|i| i.sin_cos()).unzip(); - - println!("cos: {:?}", cos); - println!("sin: {:?}", sin); - - let src = transpose(src, &shape, 1, 2).unwrap(); - let mut dst = vec![0.0; el_count]; - let t = num_heads; - let h = seq_len; - let d = head_dim; - src.chunks(t * h * d) - .zip(dst.chunks_mut(t * h * d)) - .for_each(|(src, dst)| { - for i_t in 0..t { - for i_d in 0..d / 2 { - let i_cs = i_t * (d / 2) + i_d; - for i_h in 0..h { - let i1 = i_t * h * d + i_h * d + i_d; - let i2 = i1 + d / 2; - dst[i1] = src[i1] * cos[i_cs] - src[i2] * sin[i_cs]; - dst[i2] = src[i1] * sin[i_cs] + src[i2] * cos[i_cs]; - } - } - } - }); - - transpose(dst, &shape, 1, 2).unwrap() + vec![] }