YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
style: cargo fmt --all with stable rustfmt 1.9.0
Louis Beaumont7957bdfdaf15
diff --git a/crates/screenpipe-rfdetr-mlx/src/deformable_attn/mod.rs b/crates/screenpipe-rfdetr-mlx/src/deformable_attn/mod.rsindex 1240a5220..d709f6fd1 100644--- a/crates/screenpipe-rfdetr-mlx/src/deformable_attn/mod.rs+++ b/crates/screenpipe-rfdetr-mlx/src/deformable_attn/mod.rs@@ -23,13 +23,13 @@ const W: i32 = 24;/// Diagnostic outputs for [`deformable_attn_single_scale_debug`].pub struct DefAttnDebug {- pub v_nchw: Array, // (B*M, D, H, W)- pub grids: Array, // (B*M, Lq, P, 2)- pub sampled: Array, // (B*M, D, Lq, P)- pub aw_mul: Array, // (B*M, 1, Lq, P)- pub weighted: Array, // (B*M, D, Lq, P)- pub summed: Array, // (B*M, D, Lq)- pub output: Array, // (B, Lq, M*D)+ pub v_nchw: Array, // (B*M, D, H, W)+ pub grids: Array, // (B*M, Lq, P, 2)+ pub sampled: Array, // (B*M, D, Lq, P)+ pub aw_mul: Array, // (B*M, 1, Lq, P)+ pub weighted: Array, // (B*M, D, Lq, P)+ pub summed: Array, // (B*M, D, Lq)+ pub output: Array, // (B, Lq, M*D)}/// Same as [`deformable_attn_single_scale`] but exposes every intermediate@@ -47,7 +47,9 @@ pub fn deformable_attn_single_scale_debug(debug_assert_eq!(hw, H * W);debug_assert_eq!(c, N_HEADS * HEAD_DIM);- let v_t = value.transpose_axes(&[0, 2, 1]).map_err(err("v transpose"))?;+ let v_t = value+ .transpose_axes(&[0, 2, 1])+ .map_err(err("v transpose"))?;let v_zero = ops::zeros::<f32>(&[b, c, hw]).map_err(err("v zero"))?;let v = v_t.add(&v_zero).map_err(err("v materialize"))?;let v = v@@ -64,8 +66,8 @@ pub fn deformable_attn_single_scale_debug(let grids_t = grids.transpose_axes(&[0, 2, 1, 3, 4]).map_err(err("grids perm"))?;- let grids_zero = ops::zeros::<f32>(&[b, N_HEADS, lq, N_POINTS, 2])- .map_err(err("grids zero"))?;+ let grids_zero =+ ops::zeros::<f32>(&[b, N_HEADS, lq, N_POINTS, 2]).map_err(err("grids zero"))?;let grids = grids_t.add(&grids_zero).map_err(err("grids materialize"))?;let grids = grids.reshape(&[b * N_HEADS, lq, N_POINTS, 2])@@ -97,8 +99,7 @@ pub fn deformable_attn_single_scale_debug(let perm = four_d.transpose_axes(&[0, 3, 1, 2]).map_err(err("final perm"))?;- let final_zero = ops::zeros::<f32>(&[b, lq, N_HEADS, HEAD_DIM])- .map_err(err("final zero"))?;+ let final_zero = ops::zeros::<f32>(&[b, lq, N_HEADS, HEAD_DIM]).map_err(err("final zero"))?;let materialized = perm.add(&final_zero).map_err(err("final materialize"))?;let output = materialized.reshape(&[b, lq, N_HEADS * HEAD_DIM])@@ -144,7 +145,9 @@ pub fn deformable_attn_single_scale(// `transpose_axes` returns a strided view and mlx-rs's optimizer// folds `multiply(&one)` away. `contiguous` is cheaper than the// earlier `add(zeros_of_target_shape)` workaround.- let v_t = value.transpose_axes(&[0, 2, 1]).map_err(err("v transpose"))?;+ let v_t = value+ .transpose_axes(&[0, 2, 1])+ .map_err(err("v transpose"))?;let v = crate::util::contiguous(&v_t)?;let v = v.reshape(&[b, N_HEADS, HEAD_DIM, hw])diff --git a/crates/screenpipe-rfdetr-mlx/src/lib.rs b/crates/screenpipe-rfdetr-mlx/src/lib.rsindex 627c410da..142c592e5 100644--- a/crates/screenpipe-rfdetr-mlx/src/lib.rs+++ b/crates/screenpipe-rfdetr-mlx/src/lib.rs@@ -158,17 +158,24 @@ impl RfDetr {let bb_outs = self.backbone.as_ref().unwrap().forward(x_nchw)?;// Force evaluation so timing reflects actual compute time.for o in &bb_outs {- o.eval().map_err(|e| Error::Inference(format!("eval bb: {e}")))?;+ o.eval()+ .map_err(|e| Error::Inference(format!("eval bb: {e}")))?;}let t_bb = t0.elapsed().as_secs_f64() * 1000.0;let t1 = std::time::Instant::now();let proj_flat = self.projector.as_ref().unwrap().forward_flat(&bb_outs)?;- proj_flat.eval().map_err(|e| Error::Inference(format!("eval proj: {e}")))?;+ proj_flat+ .eval()+ .map_err(|e| Error::Inference(format!("eval proj: {e}")))?;let t_proj = t1.elapsed().as_secs_f64() * 1000.0;let t2 = std::time::Instant::now();let (boxes, logits) = self.decoder.as_ref().unwrap().forward(&proj_flat)?;- boxes.eval().map_err(|e| Error::Inference(format!("eval boxes: {e}")))?;- logits.eval().map_err(|e| Error::Inference(format!("eval logits: {e}")))?;+ boxes+ .eval()+ .map_err(|e| Error::Inference(format!("eval boxes: {e}")))?;+ logits+ .eval()+ .map_err(|e| Error::Inference(format!("eval logits: {e}")))?;let t_dec = t2.elapsed().as_secs_f64() * 1000.0;let t_total = t0.elapsed().as_secs_f64() * 1000.0;Ok((boxes, logits, [t_bb, t_proj, t_dec, t_total]))@@ -248,7 +255,11 @@ impl RfDetr {score: best_score,});}- out.sort_by(|a, b| b.score.partial_cmp(&a.score).unwrap_or(std::cmp::Ordering::Equal));+ out.sort_by(|a, b| {+ b.score+ .partial_cmp(&a.score)+ .unwrap_or(std::cmp::Ordering::Equal)+ });Ok(out)}}diff --git a/crates/screenpipe-rfdetr-mlx/src/transformer.rs b/crates/screenpipe-rfdetr-mlx/src/transformer.rsindex f763931f8..b91d2d2fe 100644--- a/crates/screenpipe-rfdetr-mlx/src/transformer.rs+++ b/crates/screenpipe-rfdetr-mlx/src/transformer.rs@@ -47,8 +47,7 @@ fn linear(x: &Array, w_in_out: &Array, b: &Array) -> Result<Array> {}fn linear_no_bias(x: &Array, w_in_out: &Array) -> Result<Array> {- ops::matmul(x, w_in_out)- .map_err(|e| Error::Inference(format!("matmul: {e}")))+ ops::matmul(x, w_in_out).map_err(|e| Error::Inference(format!("matmul: {e}")))}/// Per-token Linear + LN that turns the projector output into the@@ -116,10 +115,10 @@ impl Mlp3 {/// Sigmoid + center→corner bbox decoding (RF-DETR uses bbox_reparam=True).fn sigmoid(x: &Array) -> Result<Array> {- let neg = x.negative()+ let neg = x+ .negative().map_err(|e| Error::Inference(format!("sigmoid neg: {e}")))?;- let exp = ops::exp(&neg)- .map_err(|e| Error::Inference(format!("sigmoid exp: {e}")))?;+ let exp = ops::exp(&neg).map_err(|e| Error::Inference(format!("sigmoid exp: {e}")))?;let one_plus_exp = exp.add(&Array::from_f32(1.0)).map_err(|e| Error::Inference(format!("sigmoid 1+exp: {e}")))?;