// Synchronize fast and slow weights at a caller-selected Lookahead boundary and measure the correction. use graph_io; pub fn fd_lookahead_sync(rows: i64, width: i64) { println!("module {"); fd_line(" func.func @main(%fast: tensor, %slow: tensor, %alpha: tensor) -> (tensor, tensor) {", rows, width); fd_line(" %v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor", rows, width); fd_line(" %v1 = stablehlo.subtract %fast, %slow : tensor", rows, width); fd_line(" %v2 = stablehlo.multiply %alpha, %v1 : tensor", rows, width); fd_line(" %v3 = stablehlo.add %slow, %v2 : tensor", rows, width); // next_slow = slow+alpha*(fast-slow) fd_line(" %v4 = stablehlo.subtract %v3, %fast : tensor", rows, width); // correction = next_slow-fast fd_line(" return %v3, %v4 : tensor, tensor", rows, width); println!(" }"); println!("}"); }