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 (fix CQ check)
Louis Beaumont9db3426044be
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 87c246f92..a1411aad6 100755--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -59,6 +59,7 @@ mod owned_browser;// injects via WKHTTPCookieStore; other platforms compile to a stub// `cookies_for_host` that returns empty until Windows (DPAPI + AES-256-// GCM + WebView2) and Linux (libsecret + webkit2gtk) readers land.+mod monitor_events;mod owned_browser_cookies;mod permission_events;mod permissions;@@ -1879,6 +1880,8 @@ async fn main() {}});+ crate::monitor_events::start();+#[cfg(target_os = "macos")]crate::window::reset_to_regular_and_refresh_tray(&app_handle);diff --git a/crates/screenpipe-db/src/write_queue.rs b/crates/screenpipe-db/src/write_queue.rsindex d9ca38f90..336a1c266 100644--- a/crates/screenpipe-db/src/write_queue.rs+++ b/crates/screenpipe-db/src/write_queue.rs@@ -1345,7 +1345,9 @@ async fn execute_single_write(fn send_error_to_all(batch: &mut Vec<PendingWrite>, error: sqlx::Error) {let err_str = error.to_string();for pw in batch.drain(..) {- let _ = pw.respond.send(Err(sqlx::Error::Protocol(err_str.clone().into())));+ let _ = pw+ .respond+ .send(Err(sqlx::Error::Protocol(err_str.clone().into())));}// Log the original error that caused the batch failureerror!("write_queue: batch failed: {}", error);diff --git a/crates/screenpipe-db/tests/db_config_test.rs b/crates/screenpipe-db/tests/db_config_test.rsindex fa8a9b7ca..bdb9acee1 100644--- a/crates/screenpipe-db/tests/db_config_test.rs+++ b/crates/screenpipe-db/tests/db_config_test.rs@@ -72,37 +72,37 @@ async fn write_pool_size_increased_for_all_tiers() {// Regression test for issue SCREENPIPE-CLI-FZ: connection pool timeout// Verifies that the write pool size has been increased to handle// high-volume UI event batches without timing out.-+let high_config = DbConfig::default();assert!(high_config.write_pool_max >= 8,"high-tier write_pool_max should be at least 8, was {}",high_config.write_pool_max);-+let mid_config = DbConfig::for_tier(screenpipe_config::DeviceTier::Mid);assert!(mid_config.write_pool_max >= 6,"mid-tier write_pool_max should be at least 6, was {}",mid_config.write_pool_max);-+let low_config = DbConfig::for_tier(screenpipe_config::DeviceTier::Low);assert!(low_config.write_pool_max >= 4,"low-tier write_pool_max should be at least 4, was {}",low_config.write_pool_max);-+// Verify all pool configs initialize without errorlet _high_db = DatabaseManager::new("sqlite::memory:", high_config).await.expect("high-tier DB with increased write pool should initialize");-+let _mid_db = DatabaseManager::new("sqlite::memory:", mid_config).await.expect("mid-tier DB with increased write pool should initialize");-+let _low_db = DatabaseManager::new("sqlite::memory:", low_config).await.expect("low-tier DB with increased write pool should initialize");diff --git a/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rs b/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rsindex c87a4b9a3..8042f94e0 100644--- a/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rs+++ b/crates/screenpipe-engine/src/vision_manager/monitor_watcher.rs@@ -217,6 +217,13 @@ pub async fn start_monitor_watcher(let active_ids: HashSet<u32> =vision_manager.active_monitors().await.into_iter().collect();+ // Empty active set on a populated known set means this is steady-state+ // boot, not a hot-plug — suppress the notification so the user doesn't+ // get "started recording 4 monitors" on every restart.+ let initial_pass = active_ids.is_empty() && known_monitors.is_empty();+ let mut added: Vec<serde_json::Value> = Vec::new();+ let mut removed: Vec<u32> = Vec::new();+// Detect newly connected monitors (filtered by user selection)for monitor in ¤t_monitors {let monitor_id = monitor.id();@@ -237,11 +244,21 @@ pub async fn start_monitor_watcher(known_monitors.insert(monitor_id);}- if let Err(e) = vision_manager.start_monitor(monitor_id).await {- warn!(- "Failed to start recording on monitor {}: {:?}",- monitor_id, e- );+ match vision_manager.start_monitor(monitor_id).await {+ Ok(()) => {+ added.push(serde_json::json!({+ "id": monitor_id,+ "name": monitor.name(),+ "width": monitor.width(),+ "height": monitor.height(),+ }));+ }+ Err(e) => {+ warn!(+ "Failed to start recording on monitor {}: {:?}",+ monitor_id, e+ );+ }}}}@@ -250,15 +267,28 @@ pub async fn start_monitor_watcher(for monitor_id in &active_ids {if !current_ids.contains(monitor_id) {info!("Monitor {} disconnected, stopping recording", monitor_id);- if let Err(e) = vision_manager.stop_monitor(*monitor_id).await {- warn!(+ match vision_manager.stop_monitor(*monitor_id).await {+ Ok(()) => removed.push(*monitor_id),+ Err(e) => warn!("Failed to stop recording on monitor {}: {:?}",monitor_id, e- );+ ),}}}+ if !initial_pass && (!added.is_empty() || !removed.is_empty()) {+ let active_count = vision_manager.active_monitors().await.len();+ let _ = screenpipe_events::send_event(+ "monitor_topology_changed",+ serde_json::json!({+ "added": added,+ "removed": removed,+ "active_count": active_count,+ }),+ );+ }+// Wait for the next display reconfiguration event. On macOS the// CG display callback (registered in `sleep_monitor`) fires// instantly on connect/disconnect/resolution changes, so pollingdiff --git a/crates/screenpipe-redact/src/pipeline.rs b/crates/screenpipe-redact/src/pipeline.rsindex 9d995ed58..04d61842f 100644--- a/crates/screenpipe-redact/src/pipeline.rs+++ b/crates/screenpipe-redact/src/pipeline.rs@@ -351,6 +351,9 @@ mod tests {assert!(out.redacted.contains("[email protected]"));assert!(out.redacted.contains("415-555-0142"));assert!(out.redacted.contains("[SECRET]"));- assert!(out.spans.iter().all(|s| s.label == crate::SpanLabel::Secret));+ assert!(out+ .spans+ .iter()+ .all(|s| s.label == crate::SpanLabel::Secret));}}diff --git a/crates/screenpipe-rfdetr-mlx/src/backbone/projector.rs b/crates/screenpipe-rfdetr-mlx/src/backbone/projector.rsindex 6e161db02..c27c6f037 100644--- a/crates/screenpipe-rfdetr-mlx/src/backbone/projector.rs+++ b/crates/screenpipe-rfdetr-mlx/src/backbone/projector.rs@@ -51,12 +51,7 @@ struct ConvLnSilu {}impl ConvLnSilu {- fn load(- w: &Weights,- prefix: &str,- stride: (i32, i32),- padding: (i32, i32),- ) -> Result<Self> {+ fn load(w: &Weights, prefix: &str, stride: (i32, i32), padding: (i32, i32)) -> Result<Self> {Ok(Self {weight: conv_w(w, &format!("{prefix}.conv.weight"))?,ln_w: w.get(&format!("{prefix}.bn.weight"))?.deep_clone(),@@ -105,9 +100,9 @@ impl Bottleneck {////// Input/output are NHWC tensors of shape `(B, H, W, C_in/out)`.struct C2fBlock {- cv1: ConvLnSilu, // c_in → 2*hidden, 1×1- bottlenecks: Vec<Bottleneck>, // n×Bottleneck(hidden, hidden)- cv2: ConvLnSilu, // (2 + n)*hidden → c_out, 1×1+ cv1: ConvLnSilu, // c_in → 2*hidden, 1×1+ bottlenecks: Vec<Bottleneck>, // n×Bottleneck(hidden, hidden)+ cv2: ConvLnSilu, // (2 + n)*hidden → c_out, 1×1}impl C2fBlock {@@ -117,15 +112,19 @@ impl C2fBlock {.map(|i| Bottleneck::load(w, &format!("{prefix}.m.{i}"))).collect::<Result<Vec<_>>>()?;let cv2 = ConvLnSilu::load(w, &format!("{prefix}.cv2"), (1, 1), (0, 0))?;- Ok(Self { cv1, bottlenecks, cv2 })+ Ok(Self {+ cv1,+ bottlenecks,+ cv2,+ })}/// NHWC in → NHWC out.fn forward(&self, x: &Array) -> Result<Array> {// cv1 maps c_in → 2*hidden, then split along channel dim.let y0 = self.cv1.forward(x)?;- let parts = ops::split(&y0, 2, 3)- .map_err(|e| Error::Inference(format!("C2f cv1 split: {e}")))?;+ let parts =+ ops::split(&y0, 2, 3).map_err(|e| Error::Inference(format!("C2f cv1 split: {e}")))?;// y[-1] is fed forward; we collect all parts for the final concat.let mut chunks: Vec<Array> = parts;for b in &self.bottlenecks {@@ -201,8 +200,7 @@ impl Projector {pub fn forward_flat(&self, encoder_outs: &[Array; 4]) -> Result<Array> {let nhwc = self.forward(encoder_outs)?;let s = nhwc.shape();- nhwc- .reshape(&[s[0], s[1] * s[2], s[3]])+ nhwc.reshape(&[s[0], s[1] * s[2], s[3]]).map_err(|e| Error::Inference(format!("Projector flatten: {e}")))}}@@ -243,8 +241,7 @@ pub fn test_concat_unwindowed(encoder_outs: &[Array; 4]) -> Result<Array> {.map(unwindow_to_nhwc).collect::<Result<Vec<_>>>()?;let refs: Vec<&Array> = unwindowed.iter().collect();- ops::concatenate_axis(&refs, 3)- .map_err(|e| Error::Inference(format!("test concat: {e}")))+ ops::concatenate_axis(&refs, 3).map_err(|e| Error::Inference(format!("test concat: {e}")))}/// Reverses the encoder's window partition to recover an `(B, 24, 24, 384)`diff --git a/crates/screenpipe-rfdetr-mlx/src/decoder/mod.rs b/crates/screenpipe-rfdetr-mlx/src/decoder/mod.rsindex f2fc961cd..6a2ba2fed 100644--- a/crates/screenpipe-rfdetr-mlx/src/decoder/mod.rs+++ b/crates/screenpipe-rfdetr-mlx/src/decoder/mod.rs@@ -61,8 +61,12 @@ fn relu(x: &Array) -> Result<Array> {fn sigmoid(x: &Array) -> Result<Array> {let neg = x.negative().map_err(err("sigmoid neg"))?;let exp = ops::exp(&neg).map_err(err("sigmoid exp"))?;- let one_plus = exp.add(&Array::from_f32(1.0)).map_err(err("sigmoid 1+exp"))?;- Array::from_f32(1.0).divide(&one_plus).map_err(err("sigmoid div"))+ let one_plus = exp+ .add(&Array::from_f32(1.0))+ .map_err(err("sigmoid 1+exp"))?;+ Array::from_f32(1.0)+ .divide(&one_plus)+ .map_err(err("sigmoid div"))}fn exp_(x: &Array) -> Result<Array> {@@ -111,7 +115,9 @@ fn gen_sineembed_4d(pos: &Array, dim_per_axis: usize) -> Result<Array> {let mut encoded_parts: Vec<Array> = Vec::with_capacity(4);for p in parts {// p: (B, Lq, 1)- let scaled = p.multiply(&Array::from_f32(pi2)).map_err(err("scale pi2"))?;+ let scaled = p+ .multiply(&Array::from_f32(pi2))+ .map_err(err("scale pi2"))?;// scaled / dim_t → (B, Lq, dim)let inner = scaled.divide(&dim_t_arr).map_err(err("inner"))?;// Take sin at even indices, cos at odd. We compute sin and cos for the@@ -132,7 +138,12 @@ fn gen_sineembed_4d(pos: &Array, dim_per_axis: usize) -> Result<Array> {encoded_parts.push(flat);}// Upstream order: (pos_y, pos_x, pos_w, pos_h) — y first!- let order = [&encoded_parts[1], &encoded_parts[0], &encoded_parts[2], &encoded_parts[3]];+ let order = [+ &encoded_parts[1],+ &encoded_parts[0],+ &encoded_parts[2],+ &encoded_parts[3],+ ];ops::concatenate_axis(&order, -1).map_err(err("4D concat"))}@@ -220,8 +231,8 @@ impl DecoderSelfAttn {let k4 = head_split(&k)?;let v4 = head_split(&v)?;let scale = 1.0 / (SA_HEAD_DIM as f32).sqrt();- let ctx = fast::scaled_dot_product_attention(&q4, &k4, &v4, scale, None)- .map_err(err("sdpa"))?;+ let ctx =+ fast::scaled_dot_product_attention(&q4, &k4, &v4, scale, None).map_err(err("sdpa"))?;let ctx_t = ctx.transpose_axes(&[0, 2, 1, 3]).map_err(err("ctx tp"))?;let ctx_t = crate::util::contiguous(&ctx_t)?;let ctx_flat = ctx_t.reshape(&[b, lq, DIM]).map_err(err("ctx flat"))?;@@ -251,9 +262,7 @@ impl DecoderCrossAttn {attention_weights_w: w.get(&format!("{p}.attention_weights.weight"))?.deep_clone(),- attention_weights_b: w- .get(&format!("{p}.attention_weights.bias"))?- .deep_clone(),+ attention_weights_b: w.get(&format!("{p}.attention_weights.bias"))?.deep_clone(),value_proj_w: w.get(&format!("{p}.value_proj.weight"))?.deep_clone(),value_proj_b: w.get(&format!("{p}.value_proj.bias"))?.deep_clone(),output_proj_w: w.get(&format!("{p}.output_proj.weight"))?.deep_clone(),@@ -266,7 +275,12 @@ impl DecoderCrossAttn {/// `reference_points`: `(B, Lq, 1, 4)` (single level, cxcywh)./// `memory`: `(B, HW, D)` flattened encoder output./// Returns `(B, Lq, D)` — pre-residual.- pub fn forward(&self, query: &Array, reference_points: &Array, memory: &Array) -> Result<Array> {+ pub fn forward(+ &self,+ query: &Array,+ reference_points: &Array,+ memory: &Array,+ ) -> Result<Array> {let (value, locations, aw_2d) =self.compute_def_attn_inputs(query, reference_points, memory)?;let gathered = deformable_attn_single_scale(&value, &locations, &aw_2d)?;@@ -280,7 +294,8 @@ impl DecoderCrossAttn {reference_points: &Array,memory: &Array,) -> Result<Array> {- let (value, locations, aw_2d) = self.compute_def_attn_inputs(query, reference_points, memory)?;+ let (value, locations, aw_2d) =+ self.compute_def_attn_inputs(query, reference_points, memory)?;deformable_attn_single_scale(&value, &locations, &aw_2d)}@@ -306,7 +321,8 @@ impl DecoderCrossAttn {// Reference points (B, Lq, 1, 4) -> cxcy (B, Lq, 1, 2), wh (B, Lq, 1, 2).// split_sections returns strided views; materialize via the// `mlx_contiguous` op so subsequent reshapes are guaranteed clean.- let ref_parts = ops::split_sections(reference_points, &[2], -1).map_err(err("ref split"))?;+ let ref_parts =+ ops::split_sections(reference_points, &[2], -1).map_err(err("ref split"))?;let ref_cxcy_flat = crate::util::contiguous(&ref_parts[0])?;let ref_wh_flat = crate::util::contiguous(&ref_parts[1])?;let ref_cxcy = ref_cxcy_flat@@ -411,7 +427,9 @@ impl DecoderLayer {let after_sa = ln(&after_sa, &self.norm1_w, &self.norm1_b)?;// Cross-attn + residual + LN.let q_with_pos = after_sa.add(query_pos).map_err(err("q_with_pos"))?;- let ca_out = self.cross_attn.forward(&q_with_pos, refpoints_input, memory)?;+ let ca_out = self+ .cross_attn+ .forward(&q_with_pos, refpoints_input, memory)?;let after_ca = after_sa.add(&ca_out).map_err(err("after_ca add"))?;let after_ca = ln(&after_ca, &self.norm2_w, &self.norm2_b)?;// FFN + residual + LN.@@ -501,14 +519,12 @@ impl Decoder {let max_score = ops::max_axis(&enc_class, -1, false).map_err(err("max class"))?;let neg_score = max_score.negative().map_err(err("neg score"))?;let argsort = ops::argsort_axis(&neg_score, -1).map_err(err("argsort"))?;- let argsort_split = ops::split_sections(&argsort, &[NUM_QUERIES], -1)- .map_err(err("argsort split"))?;+ let argsort_split =+ ops::split_sections(&argsort, &[NUM_QUERIES], -1).map_err(err("argsort split"))?;let topk_idx = &argsort_split[0];let enc_bbox_delta = self.enc_bbox_head.forward(&memory)?;- let parts = ops::split_sections(&enc_bbox_delta, &[2], -1)- .map_err(err("bbox split"))?;- let prop_parts = ops::split_sections(&proposals, &[2], -1)- .map_err(err("prop split"))?;+ let parts = ops::split_sections(&enc_bbox_delta, &[2], -1).map_err(err("bbox split"))?;+ let prop_parts = ops::split_sections(&proposals, &[2], -1).map_err(err("prop split"))?;let cxcy = parts[0].multiply(&prop_parts[1]).map_err(err("delta cxcy mul"))?@@ -524,8 +540,8 @@ impl Decoder {let topk_idx_dbg = topk_idx.clone();let learned = self.refpoint_embed.deep_clone();let lr_parts = ops::split_sections(&learned, &[2], -1).map_err(err("learned split"))?;- let ts_parts = ops::split_sections(&refpoint_embed_ts, &[2], -1)- .map_err(err("ts split"))?;+ let ts_parts =+ ops::split_sections(&refpoint_embed_ts, &[2], -1).map_err(err("ts split"))?;let new_cxcy = lr_parts[0].multiply(&ts_parts[1]).map_err(err("rp cxcy mul"))?@@ -534,8 +550,8 @@ impl Decoder {let new_wh = exp_(&lr_parts[1])?.multiply(&ts_parts[1]).map_err(err("rp wh mul"))?;- let refpoint_embed = ops::concatenate_axis(&[&new_cxcy, &new_wh], -1)- .map_err(err("rp concat"))?;+ let refpoint_embed =+ ops::concatenate_axis(&[&new_cxcy, &new_wh], -1).map_err(err("rp concat"))?;let mut output = self.query_feat.deep_clone();let s = refpoint_embed.shape();let refpoints_input = refpoint_embed@@ -588,16 +604,14 @@ impl Decoder {let neg_score = max_score.negative().map_err(err("neg score"))?;let argsort = ops::argsort_axis(&neg_score, -1).map_err(err("argsort"))?;// (B, 576) → take first 300 along axis -1.- let argsort_split = ops::split_sections(&argsort, &[NUM_QUERIES], -1)- .map_err(err("argsort split"))?;+ let argsort_split =+ ops::split_sections(&argsort, &[NUM_QUERIES], -1).map_err(err("argsort split"))?;let topk_idx = &argsort_split[0]; // (B, 300) int// bbox delta + reparam — operates on `enc_memory` (post-Linear+LN).let enc_bbox_delta = self.enc_bbox_head.forward(&enc_memory)?;- let parts = ops::split_sections(&enc_bbox_delta, &[2], -1)- .map_err(err("bbox split"))?;- let prop_parts = ops::split_sections(&proposals, &[2], -1)- .map_err(err("prop split"))?;+ let parts = ops::split_sections(&enc_bbox_delta, &[2], -1).map_err(err("bbox split"))?;+ let prop_parts = ops::split_sections(&proposals, &[2], -1).map_err(err("prop split"))?;let cxcy = parts[0].multiply(&prop_parts[1]).map_err(err("delta cxcy mul"))?@@ -617,8 +631,8 @@ impl Decoder {// shape, broadcast over batch.let learned = self.refpoint_embed.clone(); // (1, 300, 4) — refcountlet lr_parts = ops::split_sections(&learned, &[2], -1).map_err(err("learned split"))?;- let ts_parts = ops::split_sections(&refpoint_embed_ts, &[2], -1)- .map_err(err("ts split"))?;+ let ts_parts =+ ops::split_sections(&refpoint_embed_ts, &[2], -1).map_err(err("ts split"))?;let new_cxcy = lr_parts[0].multiply(&ts_parts[1]).map_err(err("rp cxcy mul"))?@@ -627,8 +641,8 @@ impl Decoder {let new_wh = exp_(&lr_parts[1])?.multiply(&ts_parts[1]).map_err(err("rp wh mul"))?;- let refpoint_embed = ops::concatenate_axis(&[&new_cxcy, &new_wh], -1)- .map_err(err("rp concat"))?;+ let refpoint_embed =+ ops::concatenate_axis(&[&new_cxcy, &new_wh], -1).map_err(err("rp concat"))?;// Initial decoder query content = query_feat (1, 300, 256).// `clone` is a refcount bump — `output` is reassigned each layer,// so we never write through this handle.@@ -642,7 +656,7 @@ impl Decoder {// query_sine_embed from refpoints (cxcywh).let q_sine = gen_sineembed_4d(&refpoint_embed, 128)?; // (B, 300, 512)- // ref_point_head: 2-layer MLP with ReLU between (per upstream MLP class).+ // ref_point_head: 2-layer MLP with ReLU between (per upstream MLP class).let qp0 = linear(&q_sine, &self.ref_point_head_w0, &self.ref_point_head_b0)?;let qp0a = relu(&qp0)?;let query_pos = linear(&qp0a, &self.ref_point_head_w1, &self.ref_point_head_b1)?;@@ -662,8 +676,7 @@ impl Decoder {let logits = linear(&output, &self.class_head_w, &self.class_head_b)?;let bbox_delta = self.bbox_head.forward(&output)?;// Final bbox refinement vs. refpoint_embed (cxcywh).- let rb_parts = ops::split_sections(&refpoint_embed, &[2], -1)- .map_err(err("rb split"))?;+ let rb_parts = ops::split_sections(&refpoint_embed, &[2], -1).map_err(err("rb split"))?;let bd_parts = ops::split_sections(&bbox_delta, &[2], -1).map_err(err("bd split"))?;let final_cxcy = bd_parts[0].multiply(&rb_parts[1])@@ -673,8 +686,8 @@ impl Decoder {let final_wh = exp_(&bd_parts[1])?.multiply(&rb_parts[1]).map_err(err("final wh mul"))?;- let boxes = ops::concatenate_axis(&[&final_cxcy, &final_wh], -1)- .map_err(err("boxes cat"))?;+ let boxes =+ ops::concatenate_axis(&[&final_cxcy, &final_wh], -1).map_err(err("boxes cat"))?;Ok((boxes, logits))}@@ -686,11 +699,8 @@ impl Decoder {let (b, _len, _c) = (s[0], s[1], s[2]);let k = idx.shape()[1];// Broadcast idx (B, K) → (B, K, last_dim) so take_along_axis can gather.- let idx_3d = idx- .reshape(&[b, k, 1])- .map_err(err("idx 3d"))?;- let idx_bc = ops::broadcast_to(&idx_3d, &[b, k, last_dim])- .map_err(err("idx bc"))?;+ let idx_3d = idx.reshape(&[b, k, 1]).map_err(err("idx 3d"))?;+ let idx_bc = ops::broadcast_to(&idx_3d, &[b, k, last_dim]).map_err(err("idx bc"))?;x.take_along_axis(&idx_bc, 1).map_err(err("gather"))}}diff --git a/crates/screenpipe-rfdetr-mlx/src/deformable_attn/grid_sample.rs b/crates/screenpipe-rfdetr-mlx/src/deformable_attn/grid_sample.rsindex a8f8e4f73..7d7c0ed1e 100644--- a/crates/screenpipe-rfdetr-mlx/src/deformable_attn/grid_sample.rs+++ b/crates/screenpipe-rfdetr-mlx/src/deformable_attn/grid_sample.rs@@ -35,14 +35,8 @@ pub fn grid_sample_2d(input: &Array, grid: &Array) -> Result<Array> {let half = Array::from_f32(0.5);let w_f = Array::from_f32(w as f32);let h_f = Array::from_f32(h as f32);- let ix = mul(- &sub(&mul(&add(&gx, &one)?, &w_f)?, &one)?,- &half,- )?;- let iy = mul(- &sub(&mul(&add(&gy, &one)?, &h_f)?, &one)?,- &half,- )?;+ let ix = mul(&sub(&mul(&add(&gx, &one)?, &w_f)?, &one)?, &half)?;+ let iy = mul(&sub(&mul(&add(&gy, &one)?, &h_f)?, &one)?, &half)?;let ix0 = ops::floor(&ix).map_err(e("ix0 floor"))?;let iy0 = ops::floor(&iy).map_err(e("iy0 floor"))?;@@ -118,12 +112,13 @@ fn gather_corner(w_out: i32,) -> Result<Array> {let e = err_inf;- let idx_i = idx_f.as_dtype(mlx_rs::Dtype::Int32).map_err(e("idx cast"))?;+ let idx_i = idx_f+ .as_dtype(mlx_rs::Dtype::Int32)+ .map_err(e("idx cast"))?;let idx_b = idx_i.reshape(&[b, 1, h_out * w_out]).map_err(e("idx reshape"))?;- let idx_bc = ops::broadcast_to(&idx_b, &[b, c, h_out * w_out])- .map_err(e("idx broadcast"))?;+ let idx_bc = ops::broadcast_to(&idx_b, &[b, c, h_out * w_out]).map_err(e("idx broadcast"))?;let gathered = input_flat.take_along_axis(&idx_bc, 2).map_err(e("take_along_axis"))?;